open-agents-ai 0.187.310 → 0.187.312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +951 -882
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -277810,6 +277810,120 @@ var init_dist8 = __esm({
|
|
|
277810
277810
|
}
|
|
277811
277811
|
});
|
|
277812
277812
|
|
|
277813
|
+
// packages/cli/src/api/py-embed.ts
|
|
277814
|
+
var py_embed_exports = {};
|
|
277815
|
+
__export(py_embed_exports, {
|
|
277816
|
+
ensureEmbedDeps: () => ensureEmbedDeps,
|
|
277817
|
+
getVenvPython: () => getVenvPython,
|
|
277818
|
+
runEmbedAudio: () => runEmbedAudio,
|
|
277819
|
+
runEmbedImage: () => runEmbedImage,
|
|
277820
|
+
runEmbedText: () => runEmbedText,
|
|
277821
|
+
runTranscribeFile: () => runTranscribeFile
|
|
277822
|
+
});
|
|
277823
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
277824
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync28, writeFileSync as writeFileSync26 } from "node:fs";
|
|
277825
|
+
import { join as join68 } from "node:path";
|
|
277826
|
+
import { homedir as homedir23 } from "node:os";
|
|
277827
|
+
function getVenvDir() {
|
|
277828
|
+
return join68(homedir23(), ".open-agents", "venv");
|
|
277829
|
+
}
|
|
277830
|
+
function getVenvPython() {
|
|
277831
|
+
const base3 = getVenvDir();
|
|
277832
|
+
const bin = process.platform === "win32" ? "Scripts" : "bin";
|
|
277833
|
+
const exe = process.platform === "win32" ? "python.exe" : "python3";
|
|
277834
|
+
return join68(base3, bin, exe);
|
|
277835
|
+
}
|
|
277836
|
+
function ensureEmbedDeps() {
|
|
277837
|
+
const venv = getVenvDir();
|
|
277838
|
+
let log22 = "";
|
|
277839
|
+
try {
|
|
277840
|
+
mkdirSync28(venv, { recursive: true });
|
|
277841
|
+
} catch {
|
|
277842
|
+
}
|
|
277843
|
+
if (!existsSync52(getVenvPython())) {
|
|
277844
|
+
const mk = spawnSync5("python3", ["-m", "venv", venv], { encoding: "utf8" });
|
|
277845
|
+
log22 += mk.stdout + mk.stderr;
|
|
277846
|
+
}
|
|
277847
|
+
const pip = process.platform === "win32" ? join68(venv, "Scripts", "pip.exe") : join68(venv, "bin", "pip");
|
|
277848
|
+
const pkgs = [
|
|
277849
|
+
"open-clip-torch",
|
|
277850
|
+
"torch",
|
|
277851
|
+
"torchvision",
|
|
277852
|
+
"torchaudio",
|
|
277853
|
+
"Pillow",
|
|
277854
|
+
"speechbrain",
|
|
277855
|
+
"soundfile",
|
|
277856
|
+
"openai-whisper"
|
|
277857
|
+
];
|
|
277858
|
+
const ins = spawnSync5(pip, ["install", "--upgrade", ...pkgs], { encoding: "utf8", timeout: 9e5 });
|
|
277859
|
+
log22 += ins.stdout + ins.stderr;
|
|
277860
|
+
const ok2 = ins.status === 0;
|
|
277861
|
+
return { ok: ok2, log: log22 };
|
|
277862
|
+
}
|
|
277863
|
+
function runEmbedImage(input) {
|
|
277864
|
+
const py = getVenvPython();
|
|
277865
|
+
const script = locateScript("embed-image.py");
|
|
277866
|
+
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8" });
|
|
277867
|
+
try {
|
|
277868
|
+
const out = JSON.parse(p2.stdout || "{}");
|
|
277869
|
+
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
277870
|
+
} catch {
|
|
277871
|
+
}
|
|
277872
|
+
return null;
|
|
277873
|
+
}
|
|
277874
|
+
function runEmbedAudio(input) {
|
|
277875
|
+
const py = getVenvPython();
|
|
277876
|
+
const script = locateScript("embed-audio.py");
|
|
277877
|
+
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8" });
|
|
277878
|
+
try {
|
|
277879
|
+
const out = JSON.parse(p2.stdout || "{}");
|
|
277880
|
+
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
277881
|
+
} catch {
|
|
277882
|
+
}
|
|
277883
|
+
return null;
|
|
277884
|
+
}
|
|
277885
|
+
function runEmbedText(text) {
|
|
277886
|
+
const py = getVenvPython();
|
|
277887
|
+
const script = locateScript("embed-text.py");
|
|
277888
|
+
const p2 = spawnSync5(py, [script], { input: JSON.stringify({ text }), encoding: "utf8" });
|
|
277889
|
+
try {
|
|
277890
|
+
const out = JSON.parse(p2.stdout || "{}");
|
|
277891
|
+
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
277892
|
+
} catch {
|
|
277893
|
+
}
|
|
277894
|
+
return null;
|
|
277895
|
+
}
|
|
277896
|
+
function runTranscribeFile(input) {
|
|
277897
|
+
const py = getVenvPython();
|
|
277898
|
+
const script = locateScript("transcribe-file.py");
|
|
277899
|
+
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8", timeout: 6e5 });
|
|
277900
|
+
try {
|
|
277901
|
+
const out = JSON.parse(p2.stdout || "{}");
|
|
277902
|
+
if (typeof out.text === "string") return out.text;
|
|
277903
|
+
} catch {
|
|
277904
|
+
}
|
|
277905
|
+
return null;
|
|
277906
|
+
}
|
|
277907
|
+
function locateScript(name11) {
|
|
277908
|
+
const candidates = [
|
|
277909
|
+
join68(process.cwd(), "dist", "scripts", name11),
|
|
277910
|
+
join68(process.cwd(), name11),
|
|
277911
|
+
join68(process.cwd(), "scripts", name11)
|
|
277912
|
+
];
|
|
277913
|
+
for (const c7 of candidates) if (existsSync52(c7)) return c7;
|
|
277914
|
+
const fallback = join68(process.cwd(), name11);
|
|
277915
|
+
try {
|
|
277916
|
+
writeFileSync26(fallback, 'print("missing script")\n');
|
|
277917
|
+
} catch {
|
|
277918
|
+
}
|
|
277919
|
+
return fallback;
|
|
277920
|
+
}
|
|
277921
|
+
var init_py_embed = __esm({
|
|
277922
|
+
"packages/cli/src/api/py-embed.ts"() {
|
|
277923
|
+
"use strict";
|
|
277924
|
+
}
|
|
277925
|
+
});
|
|
277926
|
+
|
|
277813
277927
|
// packages/cli/src/tui/listen.ts
|
|
277814
277928
|
var listen_exports = {};
|
|
277815
277929
|
__export(listen_exports, {
|
|
@@ -277822,9 +277936,9 @@ __export(listen_exports, {
|
|
|
277822
277936
|
waitForTranscribeCli: () => waitForTranscribeCli
|
|
277823
277937
|
});
|
|
277824
277938
|
import { spawn as spawn18, execSync as execSync44 } from "node:child_process";
|
|
277825
|
-
import { existsSync as
|
|
277826
|
-
import { join as
|
|
277827
|
-
import { homedir as
|
|
277939
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync29, writeFileSync as writeFileSync27, readdirSync as readdirSync12 } from "node:fs";
|
|
277940
|
+
import { join as join69, dirname as dirname18 } from "node:path";
|
|
277941
|
+
import { homedir as homedir24 } from "node:os";
|
|
277828
277942
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
277829
277943
|
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
277830
277944
|
import { createInterface as createInterface2 } from "node:readline";
|
|
@@ -277909,15 +278023,15 @@ function findMicCaptureCommand() {
|
|
|
277909
278023
|
function findLiveWhisperScript() {
|
|
277910
278024
|
const thisDir = dirname18(fileURLToPath10(import.meta.url));
|
|
277911
278025
|
const candidates = [
|
|
277912
|
-
|
|
277913
|
-
|
|
277914
|
-
|
|
278026
|
+
join69(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
|
|
278027
|
+
join69(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
|
|
278028
|
+
join69(thisDir, "../../execution/scripts/live-whisper.py"),
|
|
277915
278029
|
// npm install layout — scripts bundled alongside dist
|
|
277916
|
-
|
|
277917
|
-
|
|
278030
|
+
join69(thisDir, "../scripts/live-whisper.py"),
|
|
278031
|
+
join69(thisDir, "../../scripts/live-whisper.py")
|
|
277918
278032
|
];
|
|
277919
278033
|
for (const p2 of candidates) {
|
|
277920
|
-
if (
|
|
278034
|
+
if (existsSync53(p2)) return p2;
|
|
277921
278035
|
}
|
|
277922
278036
|
try {
|
|
277923
278037
|
const globalRoot = execSync44("npm root -g", {
|
|
@@ -277926,20 +278040,20 @@ function findLiveWhisperScript() {
|
|
|
277926
278040
|
stdio: ["pipe", "pipe", "pipe"]
|
|
277927
278041
|
}).trim();
|
|
277928
278042
|
const candidates2 = [
|
|
277929
|
-
|
|
277930
|
-
|
|
278043
|
+
join69(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
|
|
278044
|
+
join69(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
|
|
277931
278045
|
];
|
|
277932
278046
|
for (const p2 of candidates2) {
|
|
277933
|
-
if (
|
|
278047
|
+
if (existsSync53(p2)) return p2;
|
|
277934
278048
|
}
|
|
277935
278049
|
} catch {
|
|
277936
278050
|
}
|
|
277937
|
-
const nvmBase =
|
|
277938
|
-
if (
|
|
278051
|
+
const nvmBase = join69(homedir24(), ".nvm", "versions", "node");
|
|
278052
|
+
if (existsSync53(nvmBase)) {
|
|
277939
278053
|
try {
|
|
277940
278054
|
for (const ver of readdirSync12(nvmBase)) {
|
|
277941
|
-
const p2 =
|
|
277942
|
-
if (
|
|
278055
|
+
const p2 = join69(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
|
|
278056
|
+
if (existsSync53(p2)) return p2;
|
|
277943
278057
|
}
|
|
277944
278058
|
} catch {
|
|
277945
278059
|
}
|
|
@@ -277955,7 +278069,7 @@ function ensureTranscribeCliBackground() {
|
|
|
277955
278069
|
timeout: 5e3,
|
|
277956
278070
|
stdio: ["pipe", "pipe", "pipe"]
|
|
277957
278071
|
}).trim();
|
|
277958
|
-
if (
|
|
278072
|
+
if (existsSync53(join69(globalRoot, "transcribe-cli", "dist", "index.js"))) {
|
|
277959
278073
|
return true;
|
|
277960
278074
|
}
|
|
277961
278075
|
} catch {
|
|
@@ -278025,18 +278139,59 @@ var init_listen = __esm({
|
|
|
278025
278139
|
const timeout2 = setTimeout(() => {
|
|
278026
278140
|
reject(new Error("Whisper fallback: model load timeout (5 min). First run downloads the model."));
|
|
278027
278141
|
}, 3e5);
|
|
278028
|
-
|
|
278029
|
-
|
|
278030
|
-
|
|
278031
|
-
|
|
278032
|
-
|
|
278033
|
-
|
|
278034
|
-
|
|
278035
|
-
|
|
278036
|
-
|
|
278037
|
-
|
|
278038
|
-
|
|
278039
|
-
|
|
278142
|
+
(async () => {
|
|
278143
|
+
try {
|
|
278144
|
+
const mod2 = await Promise.resolve().then(() => (init_py_embed(), py_embed_exports));
|
|
278145
|
+
const ensure = mod2.ensureEmbedDeps;
|
|
278146
|
+
const getPy = mod2.getVenvPython;
|
|
278147
|
+
if (typeof ensure === "function" && typeof getPy === "function") {
|
|
278148
|
+
try {
|
|
278149
|
+
const res = ensure();
|
|
278150
|
+
if (res?.log) this.emit("status", res.log.slice(-500));
|
|
278151
|
+
} catch {
|
|
278152
|
+
}
|
|
278153
|
+
const pyPath = getPy();
|
|
278154
|
+
this.process = spawn18(pyPath, [
|
|
278155
|
+
this.scriptPath,
|
|
278156
|
+
"--model",
|
|
278157
|
+
this.model,
|
|
278158
|
+
"--chunk-seconds",
|
|
278159
|
+
"3",
|
|
278160
|
+
"--window-seconds",
|
|
278161
|
+
"10"
|
|
278162
|
+
], {
|
|
278163
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
278164
|
+
env: { ...process.env }
|
|
278165
|
+
});
|
|
278166
|
+
} else {
|
|
278167
|
+
this.process = spawn18("python3", [
|
|
278168
|
+
this.scriptPath,
|
|
278169
|
+
"--model",
|
|
278170
|
+
this.model,
|
|
278171
|
+
"--chunk-seconds",
|
|
278172
|
+
"3",
|
|
278173
|
+
"--window-seconds",
|
|
278174
|
+
"10"
|
|
278175
|
+
], {
|
|
278176
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
278177
|
+
env: { ...process.env }
|
|
278178
|
+
});
|
|
278179
|
+
}
|
|
278180
|
+
} catch {
|
|
278181
|
+
this.process = spawn18("python3", [
|
|
278182
|
+
this.scriptPath,
|
|
278183
|
+
"--model",
|
|
278184
|
+
this.model,
|
|
278185
|
+
"--chunk-seconds",
|
|
278186
|
+
"3",
|
|
278187
|
+
"--window-seconds",
|
|
278188
|
+
"10"
|
|
278189
|
+
], {
|
|
278190
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
278191
|
+
env: { ...process.env }
|
|
278192
|
+
});
|
|
278193
|
+
}
|
|
278194
|
+
})();
|
|
278040
278195
|
const rl = createInterface2({ input: this.process.stdout });
|
|
278041
278196
|
rl.on("line", (line) => {
|
|
278042
278197
|
try {
|
|
@@ -278174,24 +278329,24 @@ var init_listen = __esm({
|
|
|
278174
278329
|
timeout: 5e3,
|
|
278175
278330
|
stdio: ["pipe", "pipe", "pipe"]
|
|
278176
278331
|
}).trim();
|
|
278177
|
-
const tcPath =
|
|
278178
|
-
if (
|
|
278332
|
+
const tcPath = join69(globalRoot, "transcribe-cli");
|
|
278333
|
+
if (existsSync53(join69(tcPath, "dist", "index.js"))) {
|
|
278179
278334
|
const { createRequire: createRequire7 } = await import("node:module");
|
|
278180
278335
|
const req2 = createRequire7(import.meta.url);
|
|
278181
|
-
return req2(
|
|
278336
|
+
return req2(join69(tcPath, "dist", "index.js"));
|
|
278182
278337
|
}
|
|
278183
278338
|
} catch {
|
|
278184
278339
|
}
|
|
278185
|
-
const nvmBase =
|
|
278186
|
-
if (
|
|
278340
|
+
const nvmBase = join69(homedir24(), ".nvm", "versions", "node");
|
|
278341
|
+
if (existsSync53(nvmBase)) {
|
|
278187
278342
|
try {
|
|
278188
278343
|
const { readdirSync: readdirSync31 } = await import("node:fs");
|
|
278189
278344
|
for (const ver of readdirSync31(nvmBase)) {
|
|
278190
|
-
const tcPath =
|
|
278191
|
-
if (
|
|
278345
|
+
const tcPath = join69(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
|
|
278346
|
+
if (existsSync53(join69(tcPath, "dist", "index.js"))) {
|
|
278192
278347
|
const { createRequire: createRequire7 } = await import("node:module");
|
|
278193
278348
|
const req2 = createRequire7(import.meta.url);
|
|
278194
|
-
return req2(
|
|
278349
|
+
return req2(join69(tcPath, "dist", "index.js"));
|
|
278195
278350
|
}
|
|
278196
278351
|
}
|
|
278197
278352
|
} catch {
|
|
@@ -278465,10 +278620,10 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
278465
278620
|
});
|
|
278466
278621
|
if (outputDir) {
|
|
278467
278622
|
const { basename: basename19 } = await import("node:path");
|
|
278468
|
-
const transcriptDir =
|
|
278469
|
-
|
|
278470
|
-
const outFile =
|
|
278471
|
-
|
|
278623
|
+
const transcriptDir = join69(outputDir, ".oa", "transcripts");
|
|
278624
|
+
mkdirSync29(transcriptDir, { recursive: true });
|
|
278625
|
+
const outFile = join69(transcriptDir, `${basename19(filePath)}.txt`);
|
|
278626
|
+
writeFileSync27(outFile, result.text, "utf-8");
|
|
278472
278627
|
}
|
|
278473
278628
|
return {
|
|
278474
278629
|
text: result.text,
|
|
@@ -282894,14 +283049,14 @@ var init_render = __esm({
|
|
|
282894
283049
|
});
|
|
282895
283050
|
|
|
282896
283051
|
// packages/prompts/dist/promptLoader.js
|
|
282897
|
-
import { readFileSync as readFileSync40, existsSync as
|
|
282898
|
-
import { join as
|
|
283052
|
+
import { readFileSync as readFileSync40, existsSync as existsSync54 } from "node:fs";
|
|
283053
|
+
import { join as join70, dirname as dirname19 } from "node:path";
|
|
282899
283054
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
282900
283055
|
function loadPrompt2(promptPath, vars) {
|
|
282901
283056
|
let content = cache5.get(promptPath);
|
|
282902
283057
|
if (content === void 0) {
|
|
282903
|
-
const fullPath =
|
|
282904
|
-
if (!
|
|
283058
|
+
const fullPath = join70(PROMPTS_DIR2, promptPath);
|
|
283059
|
+
if (!existsSync54(fullPath)) {
|
|
282905
283060
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
282906
283061
|
}
|
|
282907
283062
|
content = readFileSync40(fullPath, "utf-8");
|
|
@@ -282917,9 +283072,9 @@ var init_promptLoader2 = __esm({
|
|
|
282917
283072
|
"use strict";
|
|
282918
283073
|
__filename4 = fileURLToPath11(import.meta.url);
|
|
282919
283074
|
__dirname6 = dirname19(__filename4);
|
|
282920
|
-
devPath =
|
|
282921
|
-
publishedPath =
|
|
282922
|
-
PROMPTS_DIR2 =
|
|
283075
|
+
devPath = join70(__dirname6, "..", "templates");
|
|
283076
|
+
publishedPath = join70(__dirname6, "..", "prompts", "templates");
|
|
283077
|
+
PROMPTS_DIR2 = existsSync54(devPath) ? devPath : publishedPath;
|
|
282923
283078
|
cache5 = /* @__PURE__ */ new Map();
|
|
282924
283079
|
}
|
|
282925
283080
|
});
|
|
@@ -283030,7 +283185,7 @@ var init_task_templates = __esm({
|
|
|
283030
283185
|
});
|
|
283031
283186
|
|
|
283032
283187
|
// packages/prompts/dist/index.js
|
|
283033
|
-
import { join as
|
|
283188
|
+
import { join as join71, dirname as dirname20 } from "node:path";
|
|
283034
283189
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
283035
283190
|
var _dir, _packageRoot;
|
|
283036
283191
|
var init_dist9 = __esm({
|
|
@@ -283041,7 +283196,7 @@ var init_dist9 = __esm({
|
|
|
283041
283196
|
init_task_templates();
|
|
283042
283197
|
init_render();
|
|
283043
283198
|
_dir = dirname20(fileURLToPath12(import.meta.url));
|
|
283044
|
-
_packageRoot =
|
|
283199
|
+
_packageRoot = join71(_dir, "..");
|
|
283045
283200
|
}
|
|
283046
283201
|
});
|
|
283047
283202
|
|
|
@@ -283080,21 +283235,21 @@ __export(oa_directory_exports, {
|
|
|
283080
283235
|
writeIndexData: () => writeIndexData,
|
|
283081
283236
|
writeIndexMeta: () => writeIndexMeta
|
|
283082
283237
|
});
|
|
283083
|
-
import { existsSync as
|
|
283084
|
-
import { join as
|
|
283085
|
-
import { homedir as
|
|
283238
|
+
import { existsSync as existsSync55, mkdirSync as mkdirSync30, readFileSync as readFileSync41, writeFileSync as writeFileSync28, readdirSync as readdirSync13, statSync as statSync15, unlinkSync as unlinkSync14 } from "node:fs";
|
|
283239
|
+
import { join as join72, relative as relative4, basename as basename12 } from "node:path";
|
|
283240
|
+
import { homedir as homedir25 } from "node:os";
|
|
283086
283241
|
function initOaDirectory(repoRoot) {
|
|
283087
|
-
const oaPath =
|
|
283242
|
+
const oaPath = join72(repoRoot, OA_DIR);
|
|
283088
283243
|
for (const sub of SUBDIRS) {
|
|
283089
|
-
|
|
283244
|
+
mkdirSync30(join72(oaPath, sub), { recursive: true });
|
|
283090
283245
|
}
|
|
283091
283246
|
try {
|
|
283092
|
-
const gitignorePath =
|
|
283247
|
+
const gitignorePath = join72(repoRoot, ".gitignore");
|
|
283093
283248
|
const settingsPattern = ".oa/settings.json";
|
|
283094
|
-
if (
|
|
283249
|
+
if (existsSync55(gitignorePath)) {
|
|
283095
283250
|
const content = readFileSync41(gitignorePath, "utf-8");
|
|
283096
283251
|
if (!content.includes(settingsPattern)) {
|
|
283097
|
-
|
|
283252
|
+
writeFileSync28(gitignorePath, content.trimEnd() + "\n" + settingsPattern + "\n", "utf-8");
|
|
283098
283253
|
}
|
|
283099
283254
|
}
|
|
283100
283255
|
} catch {
|
|
@@ -283102,12 +283257,12 @@ function initOaDirectory(repoRoot) {
|
|
|
283102
283257
|
return oaPath;
|
|
283103
283258
|
}
|
|
283104
283259
|
function hasOaDirectory(repoRoot) {
|
|
283105
|
-
return
|
|
283260
|
+
return existsSync55(join72(repoRoot, OA_DIR, "index"));
|
|
283106
283261
|
}
|
|
283107
283262
|
function loadProjectSettings(repoRoot) {
|
|
283108
|
-
const settingsPath =
|
|
283263
|
+
const settingsPath = join72(repoRoot, OA_DIR, "settings.json");
|
|
283109
283264
|
try {
|
|
283110
|
-
if (
|
|
283265
|
+
if (existsSync55(settingsPath)) {
|
|
283111
283266
|
return JSON.parse(readFileSync41(settingsPath, "utf-8"));
|
|
283112
283267
|
}
|
|
283113
283268
|
} catch {
|
|
@@ -283115,16 +283270,16 @@ function loadProjectSettings(repoRoot) {
|
|
|
283115
283270
|
return {};
|
|
283116
283271
|
}
|
|
283117
283272
|
function saveProjectSettings(repoRoot, settings) {
|
|
283118
|
-
const oaPath =
|
|
283119
|
-
|
|
283273
|
+
const oaPath = join72(repoRoot, OA_DIR);
|
|
283274
|
+
mkdirSync30(oaPath, { recursive: true });
|
|
283120
283275
|
const existing = loadProjectSettings(repoRoot);
|
|
283121
283276
|
const merged = { ...existing, ...settings };
|
|
283122
|
-
|
|
283277
|
+
writeFileSync28(join72(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
283123
283278
|
}
|
|
283124
283279
|
function loadGlobalSettings() {
|
|
283125
|
-
const settingsPath =
|
|
283280
|
+
const settingsPath = join72(homedir25(), ".open-agents", "settings.json");
|
|
283126
283281
|
try {
|
|
283127
|
-
if (
|
|
283282
|
+
if (existsSync55(settingsPath)) {
|
|
283128
283283
|
return JSON.parse(readFileSync41(settingsPath, "utf-8"));
|
|
283129
283284
|
}
|
|
283130
283285
|
} catch {
|
|
@@ -283132,11 +283287,11 @@ function loadGlobalSettings() {
|
|
|
283132
283287
|
return {};
|
|
283133
283288
|
}
|
|
283134
283289
|
function saveGlobalSettings(settings) {
|
|
283135
|
-
const dir =
|
|
283136
|
-
|
|
283290
|
+
const dir = join72(homedir25(), ".open-agents");
|
|
283291
|
+
mkdirSync30(dir, { recursive: true });
|
|
283137
283292
|
const existing = loadGlobalSettings();
|
|
283138
283293
|
const merged = { ...existing, ...settings };
|
|
283139
|
-
|
|
283294
|
+
writeFileSync28(join72(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
283140
283295
|
}
|
|
283141
283296
|
function resolveSettings(repoRoot) {
|
|
283142
283297
|
const global2 = loadGlobalSettings();
|
|
@@ -283151,9 +283306,9 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
283151
283306
|
while (dir && !visited.has(dir)) {
|
|
283152
283307
|
visited.add(dir);
|
|
283153
283308
|
for (const name11 of CONTEXT_FILES) {
|
|
283154
|
-
const filePath =
|
|
283309
|
+
const filePath = join72(dir, name11);
|
|
283155
283310
|
const normalizedName = name11.toLowerCase();
|
|
283156
|
-
if (
|
|
283311
|
+
if (existsSync55(filePath) && !seen.has(filePath)) {
|
|
283157
283312
|
seen.add(filePath);
|
|
283158
283313
|
try {
|
|
283159
283314
|
let content = readFileSync41(filePath, "utf-8");
|
|
@@ -283170,8 +283325,8 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
283170
283325
|
}
|
|
283171
283326
|
}
|
|
283172
283327
|
}
|
|
283173
|
-
const projectMap =
|
|
283174
|
-
if (
|
|
283328
|
+
const projectMap = join72(dir, OA_DIR, "context", "project-map.md");
|
|
283329
|
+
if (existsSync55(projectMap) && !seen.has(projectMap)) {
|
|
283175
283330
|
seen.add(projectMap);
|
|
283176
283331
|
try {
|
|
283177
283332
|
let content = readFileSync41(projectMap, "utf-8");
|
|
@@ -283186,7 +283341,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
283186
283341
|
} catch {
|
|
283187
283342
|
}
|
|
283188
283343
|
}
|
|
283189
|
-
const parent =
|
|
283344
|
+
const parent = join72(dir, "..");
|
|
283190
283345
|
if (parent === dir) break;
|
|
283191
283346
|
dir = parent;
|
|
283192
283347
|
}
|
|
@@ -283203,7 +283358,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
283203
283358
|
return found;
|
|
283204
283359
|
}
|
|
283205
283360
|
function readIndexMeta(repoRoot) {
|
|
283206
|
-
const metaPath =
|
|
283361
|
+
const metaPath = join72(repoRoot, OA_DIR, "index", "meta.json");
|
|
283207
283362
|
try {
|
|
283208
283363
|
return JSON.parse(readFileSync41(metaPath, "utf-8"));
|
|
283209
283364
|
} catch {
|
|
@@ -283211,12 +283366,12 @@ function readIndexMeta(repoRoot) {
|
|
|
283211
283366
|
}
|
|
283212
283367
|
}
|
|
283213
283368
|
function writeIndexMeta(repoRoot, meta) {
|
|
283214
|
-
const metaPath =
|
|
283215
|
-
|
|
283216
|
-
|
|
283369
|
+
const metaPath = join72(repoRoot, OA_DIR, "index", "meta.json");
|
|
283370
|
+
mkdirSync30(join72(repoRoot, OA_DIR, "index"), { recursive: true });
|
|
283371
|
+
writeFileSync28(metaPath, JSON.stringify(meta, null, 2), "utf-8");
|
|
283217
283372
|
}
|
|
283218
283373
|
function readIndexData(repoRoot, filename) {
|
|
283219
|
-
const filePath =
|
|
283374
|
+
const filePath = join72(repoRoot, OA_DIR, "index", filename);
|
|
283220
283375
|
try {
|
|
283221
283376
|
return JSON.parse(readFileSync41(filePath, "utf-8"));
|
|
283222
283377
|
} catch {
|
|
@@ -283224,9 +283379,9 @@ function readIndexData(repoRoot, filename) {
|
|
|
283224
283379
|
}
|
|
283225
283380
|
}
|
|
283226
283381
|
function writeIndexData(repoRoot, filename, data) {
|
|
283227
|
-
const filePath =
|
|
283228
|
-
|
|
283229
|
-
|
|
283382
|
+
const filePath = join72(repoRoot, OA_DIR, "index", filename);
|
|
283383
|
+
mkdirSync30(join72(repoRoot, OA_DIR, "index"), { recursive: true });
|
|
283384
|
+
writeFileSync28(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
283230
283385
|
}
|
|
283231
283386
|
function generateProjectMap(repoRoot) {
|
|
283232
283387
|
const sections = [];
|
|
@@ -283273,31 +283428,31 @@ ${tree2}\`\`\`
|
|
|
283273
283428
|
sections.push("");
|
|
283274
283429
|
}
|
|
283275
283430
|
const content = sections.join("\n");
|
|
283276
|
-
const contextDir =
|
|
283277
|
-
|
|
283278
|
-
|
|
283431
|
+
const contextDir = join72(repoRoot, OA_DIR, "context");
|
|
283432
|
+
mkdirSync30(contextDir, { recursive: true });
|
|
283433
|
+
writeFileSync28(join72(contextDir, "project-map.md"), content, "utf-8");
|
|
283279
283434
|
return content;
|
|
283280
283435
|
}
|
|
283281
283436
|
function saveSession(repoRoot, session) {
|
|
283282
|
-
const historyDir =
|
|
283283
|
-
|
|
283284
|
-
|
|
283285
|
-
|
|
283437
|
+
const historyDir = join72(repoRoot, OA_DIR, "history");
|
|
283438
|
+
mkdirSync30(historyDir, { recursive: true });
|
|
283439
|
+
writeFileSync28(
|
|
283440
|
+
join72(historyDir, `${session.id}.json`),
|
|
283286
283441
|
JSON.stringify(session, null, 2),
|
|
283287
283442
|
"utf-8"
|
|
283288
283443
|
);
|
|
283289
283444
|
}
|
|
283290
283445
|
function loadRecentSessions(repoRoot, limit = 5) {
|
|
283291
|
-
const historyDir =
|
|
283292
|
-
if (!
|
|
283446
|
+
const historyDir = join72(repoRoot, OA_DIR, "history");
|
|
283447
|
+
if (!existsSync55(historyDir)) return [];
|
|
283293
283448
|
try {
|
|
283294
283449
|
const files = readdirSync13(historyDir).filter((f2) => f2.endsWith(".json") && f2 !== "pending-task.json").map((f2) => {
|
|
283295
|
-
const stat6 = statSync15(
|
|
283450
|
+
const stat6 = statSync15(join72(historyDir, f2));
|
|
283296
283451
|
return { file: f2, mtime: stat6.mtimeMs };
|
|
283297
283452
|
}).sort((a2, b) => b.mtime - a2.mtime).slice(0, limit);
|
|
283298
283453
|
return files.map((f2) => {
|
|
283299
283454
|
try {
|
|
283300
|
-
return JSON.parse(readFileSync41(
|
|
283455
|
+
return JSON.parse(readFileSync41(join72(historyDir, f2.file), "utf-8"));
|
|
283301
283456
|
} catch {
|
|
283302
283457
|
return null;
|
|
283303
283458
|
}
|
|
@@ -283309,18 +283464,18 @@ function loadRecentSessions(repoRoot, limit = 5) {
|
|
|
283309
283464
|
}
|
|
283310
283465
|
}
|
|
283311
283466
|
function savePendingTask(repoRoot, task) {
|
|
283312
|
-
const historyDir =
|
|
283313
|
-
|
|
283314
|
-
|
|
283315
|
-
|
|
283467
|
+
const historyDir = join72(repoRoot, OA_DIR, "history");
|
|
283468
|
+
mkdirSync30(historyDir, { recursive: true });
|
|
283469
|
+
writeFileSync28(
|
|
283470
|
+
join72(historyDir, PENDING_TASK_FILE),
|
|
283316
283471
|
JSON.stringify(task, null, 2) + "\n",
|
|
283317
283472
|
"utf-8"
|
|
283318
283473
|
);
|
|
283319
283474
|
}
|
|
283320
283475
|
function loadPendingTask(repoRoot) {
|
|
283321
|
-
const filePath =
|
|
283476
|
+
const filePath = join72(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
|
|
283322
283477
|
try {
|
|
283323
|
-
if (!
|
|
283478
|
+
if (!existsSync55(filePath)) return null;
|
|
283324
283479
|
const data = JSON.parse(readFileSync41(filePath, "utf-8"));
|
|
283325
283480
|
try {
|
|
283326
283481
|
unlinkSync14(filePath);
|
|
@@ -283332,12 +283487,12 @@ function loadPendingTask(repoRoot) {
|
|
|
283332
283487
|
}
|
|
283333
283488
|
}
|
|
283334
283489
|
function saveSessionContext(repoRoot, entry) {
|
|
283335
|
-
const contextDir =
|
|
283336
|
-
|
|
283337
|
-
const filePath =
|
|
283490
|
+
const contextDir = join72(repoRoot, OA_DIR, "context");
|
|
283491
|
+
mkdirSync30(contextDir, { recursive: true });
|
|
283492
|
+
const filePath = join72(contextDir, CONTEXT_SAVE_FILE);
|
|
283338
283493
|
let ctx3;
|
|
283339
283494
|
try {
|
|
283340
|
-
if (
|
|
283495
|
+
if (existsSync55(filePath)) {
|
|
283341
283496
|
ctx3 = JSON.parse(readFileSync41(filePath, "utf-8"));
|
|
283342
283497
|
} else {
|
|
283343
283498
|
ctx3 = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
|
|
@@ -283350,10 +283505,10 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
283350
283505
|
ctx3.entries = ctx3.entries.slice(-ctx3.maxEntries);
|
|
283351
283506
|
}
|
|
283352
283507
|
ctx3.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
283353
|
-
|
|
283508
|
+
writeFileSync28(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
|
|
283354
283509
|
try {
|
|
283355
|
-
|
|
283356
|
-
|
|
283510
|
+
writeFileSync28(
|
|
283511
|
+
join72(contextDir, "session-diary.md"),
|
|
283357
283512
|
renderSessionDiary(ctx3.entries.slice(-10)),
|
|
283358
283513
|
"utf-8"
|
|
283359
283514
|
);
|
|
@@ -283416,9 +283571,9 @@ function renderSessionDiary(entries) {
|
|
|
283416
283571
|
return lines.join("\n");
|
|
283417
283572
|
}
|
|
283418
283573
|
function loadSessionContext(repoRoot) {
|
|
283419
|
-
const filePath =
|
|
283574
|
+
const filePath = join72(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
|
|
283420
283575
|
try {
|
|
283421
|
-
if (!
|
|
283576
|
+
if (!existsSync55(filePath)) return null;
|
|
283422
283577
|
return JSON.parse(readFileSync41(filePath, "utf-8"));
|
|
283423
283578
|
} catch {
|
|
283424
283579
|
return null;
|
|
@@ -283455,19 +283610,19 @@ function getLastTaskSummary(repoRoot) {
|
|
|
283455
283610
|
return clean3.length > 40 ? clean3.slice(0, 37) + "..." : clean3;
|
|
283456
283611
|
}
|
|
283457
283612
|
function saveSessionHistory(repoRoot, sessionId, contentLines, meta) {
|
|
283458
|
-
const sessDir =
|
|
283459
|
-
|
|
283613
|
+
const sessDir = join72(repoRoot, OA_DIR, SESSIONS_DIR);
|
|
283614
|
+
mkdirSync30(sessDir, { recursive: true });
|
|
283460
283615
|
const stripped = contentLines.map(
|
|
283461
283616
|
(line) => typeof line === "string" ? line.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "") : ""
|
|
283462
283617
|
);
|
|
283463
283618
|
const autoName = meta.name || generateSessionName(stripped);
|
|
283464
283619
|
const autoDesc = meta.description || generateSessionDescription(stripped);
|
|
283465
|
-
const contentPath =
|
|
283466
|
-
|
|
283467
|
-
const indexPath =
|
|
283620
|
+
const contentPath = join72(sessDir, `${sessionId}.jsonl`);
|
|
283621
|
+
writeFileSync28(contentPath, stripped.join("\n"), "utf-8");
|
|
283622
|
+
const indexPath = join72(sessDir, SESSIONS_INDEX);
|
|
283468
283623
|
let index = [];
|
|
283469
283624
|
try {
|
|
283470
|
-
if (
|
|
283625
|
+
if (existsSync55(indexPath)) {
|
|
283471
283626
|
index = JSON.parse(readFileSync41(indexPath, "utf-8"));
|
|
283472
283627
|
}
|
|
283473
283628
|
} catch {
|
|
@@ -283490,16 +283645,16 @@ function saveSessionHistory(repoRoot, sessionId, contentLines, meta) {
|
|
|
283490
283645
|
if (index.length > 50) {
|
|
283491
283646
|
const removed = index.shift();
|
|
283492
283647
|
try {
|
|
283493
|
-
unlinkSync14(
|
|
283648
|
+
unlinkSync14(join72(sessDir, `${removed.id}.jsonl`));
|
|
283494
283649
|
} catch {
|
|
283495
283650
|
}
|
|
283496
283651
|
}
|
|
283497
|
-
|
|
283652
|
+
writeFileSync28(indexPath, JSON.stringify(index, null, 2), "utf-8");
|
|
283498
283653
|
}
|
|
283499
283654
|
function listSessions(repoRoot) {
|
|
283500
|
-
const indexPath =
|
|
283655
|
+
const indexPath = join72(repoRoot, OA_DIR, SESSIONS_DIR, SESSIONS_INDEX);
|
|
283501
283656
|
try {
|
|
283502
|
-
if (!
|
|
283657
|
+
if (!existsSync55(indexPath)) return [];
|
|
283503
283658
|
const index = JSON.parse(readFileSync41(indexPath, "utf-8"));
|
|
283504
283659
|
return index.sort((a2, b) => b.updatedAt.localeCompare(a2.updatedAt));
|
|
283505
283660
|
} catch {
|
|
@@ -283507,24 +283662,24 @@ function listSessions(repoRoot) {
|
|
|
283507
283662
|
}
|
|
283508
283663
|
}
|
|
283509
283664
|
function loadSessionHistory(repoRoot, sessionId) {
|
|
283510
|
-
const contentPath =
|
|
283665
|
+
const contentPath = join72(repoRoot, OA_DIR, SESSIONS_DIR, `${sessionId}.jsonl`);
|
|
283511
283666
|
try {
|
|
283512
|
-
if (!
|
|
283667
|
+
if (!existsSync55(contentPath)) return null;
|
|
283513
283668
|
return readFileSync41(contentPath, "utf-8").split("\n");
|
|
283514
283669
|
} catch {
|
|
283515
283670
|
return null;
|
|
283516
283671
|
}
|
|
283517
283672
|
}
|
|
283518
283673
|
function deleteSession(repoRoot, sessionId) {
|
|
283519
|
-
const sessDir =
|
|
283520
|
-
const indexPath =
|
|
283674
|
+
const sessDir = join72(repoRoot, OA_DIR, SESSIONS_DIR);
|
|
283675
|
+
const indexPath = join72(sessDir, SESSIONS_INDEX);
|
|
283521
283676
|
try {
|
|
283522
|
-
const contentPath =
|
|
283523
|
-
if (
|
|
283524
|
-
if (
|
|
283677
|
+
const contentPath = join72(sessDir, `${sessionId}.jsonl`);
|
|
283678
|
+
if (existsSync55(contentPath)) unlinkSync14(contentPath);
|
|
283679
|
+
if (existsSync55(indexPath)) {
|
|
283525
283680
|
let index = JSON.parse(readFileSync41(indexPath, "utf-8"));
|
|
283526
283681
|
index = index.filter((s2) => s2.id !== sessionId);
|
|
283527
|
-
|
|
283682
|
+
writeFileSync28(indexPath, JSON.stringify(index, null, 2), "utf-8");
|
|
283528
283683
|
}
|
|
283529
283684
|
return true;
|
|
283530
283685
|
} catch {
|
|
@@ -283575,8 +283730,8 @@ function detectManifests(repoRoot) {
|
|
|
283575
283730
|
{ file: "docker-compose.yaml", type: "Docker Compose" }
|
|
283576
283731
|
];
|
|
283577
283732
|
for (const check of checks) {
|
|
283578
|
-
const filePath =
|
|
283579
|
-
if (
|
|
283733
|
+
const filePath = join72(repoRoot, check.file);
|
|
283734
|
+
if (existsSync55(filePath)) {
|
|
283580
283735
|
let name11;
|
|
283581
283736
|
if (check.nameField) {
|
|
283582
283737
|
try {
|
|
@@ -283609,7 +283764,7 @@ function findKeyFiles(repoRoot) {
|
|
|
283609
283764
|
{ pattern: "CLAUDE.md", description: "Claude Code context" }
|
|
283610
283765
|
];
|
|
283611
283766
|
for (const check of checks) {
|
|
283612
|
-
if (
|
|
283767
|
+
if (existsSync55(join72(repoRoot, check.pattern))) {
|
|
283613
283768
|
keyFiles.push({ path: check.pattern, description: check.description });
|
|
283614
283769
|
}
|
|
283615
283770
|
}
|
|
@@ -283632,12 +283787,12 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
283632
283787
|
if (entry.isDirectory()) {
|
|
283633
283788
|
let fileCount = 0;
|
|
283634
283789
|
try {
|
|
283635
|
-
fileCount = readdirSync13(
|
|
283790
|
+
fileCount = readdirSync13(join72(root, entry.name)).filter((f2) => !f2.startsWith(".")).length;
|
|
283636
283791
|
} catch {
|
|
283637
283792
|
}
|
|
283638
283793
|
result += `${prefix}${connector}${entry.name}/ (${fileCount})
|
|
283639
283794
|
`;
|
|
283640
|
-
result += buildDirTree(
|
|
283795
|
+
result += buildDirTree(join72(root, entry.name), maxDepth, childPrefix, depth + 1);
|
|
283641
283796
|
} else if (depth < maxDepth) {
|
|
283642
283797
|
result += `${prefix}${connector}${entry.name}
|
|
283643
283798
|
`;
|
|
@@ -283649,7 +283804,7 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
283649
283804
|
}
|
|
283650
283805
|
function loadUsageFile(filePath) {
|
|
283651
283806
|
try {
|
|
283652
|
-
if (
|
|
283807
|
+
if (existsSync55(filePath)) {
|
|
283653
283808
|
return JSON.parse(readFileSync41(filePath, "utf-8"));
|
|
283654
283809
|
}
|
|
283655
283810
|
} catch {
|
|
@@ -283657,9 +283812,9 @@ function loadUsageFile(filePath) {
|
|
|
283657
283812
|
return { records: [] };
|
|
283658
283813
|
}
|
|
283659
283814
|
function saveUsageFile(filePath, data) {
|
|
283660
|
-
const dir =
|
|
283661
|
-
|
|
283662
|
-
|
|
283815
|
+
const dir = join72(filePath, "..");
|
|
283816
|
+
mkdirSync30(dir, { recursive: true });
|
|
283817
|
+
writeFileSync28(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
283663
283818
|
}
|
|
283664
283819
|
function recordUsage(kind, value2, opts) {
|
|
283665
283820
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -283686,15 +283841,15 @@ function recordUsage(kind, value2, opts) {
|
|
|
283686
283841
|
}
|
|
283687
283842
|
saveUsageFile(filePath, data);
|
|
283688
283843
|
};
|
|
283689
|
-
update2(
|
|
283844
|
+
update2(join72(homedir25(), ".open-agents", USAGE_HISTORY_FILE));
|
|
283690
283845
|
if (opts?.repoRoot) {
|
|
283691
|
-
update2(
|
|
283846
|
+
update2(join72(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
283692
283847
|
}
|
|
283693
283848
|
}
|
|
283694
283849
|
function loadUsageHistory(kind, repoRoot) {
|
|
283695
|
-
const globalPath =
|
|
283850
|
+
const globalPath = join72(homedir25(), ".open-agents", USAGE_HISTORY_FILE);
|
|
283696
283851
|
const globalData = loadUsageFile(globalPath);
|
|
283697
|
-
const localData = repoRoot ? loadUsageFile(
|
|
283852
|
+
const localData = repoRoot ? loadUsageFile(join72(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
|
|
283698
283853
|
const map2 = /* @__PURE__ */ new Map();
|
|
283699
283854
|
for (const r2 of globalData.records) {
|
|
283700
283855
|
if (r2.kind !== kind) continue;
|
|
@@ -283723,9 +283878,9 @@ function deleteUsageRecord(kind, value2, repoRoot) {
|
|
|
283723
283878
|
saveUsageFile(filePath, data);
|
|
283724
283879
|
}
|
|
283725
283880
|
};
|
|
283726
|
-
remove(
|
|
283881
|
+
remove(join72(homedir25(), ".open-agents", USAGE_HISTORY_FILE));
|
|
283727
283882
|
if (repoRoot) {
|
|
283728
|
-
remove(
|
|
283883
|
+
remove(join72(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
283729
283884
|
}
|
|
283730
283885
|
}
|
|
283731
283886
|
var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SESSIONS_DIR, SESSIONS_INDEX, SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
@@ -284900,18 +285055,18 @@ __export(tui_tasks_renderer_exports, {
|
|
|
284900
285055
|
setTuiTasksSession: () => setTuiTasksSession,
|
|
284901
285056
|
teardownTuiTasks: () => teardownTuiTasks
|
|
284902
285057
|
});
|
|
284903
|
-
import { existsSync as
|
|
284904
|
-
import { join as
|
|
284905
|
-
import { homedir as
|
|
285058
|
+
import { existsSync as existsSync56, readFileSync as readFileSync42, watch as fsWatch2 } from "node:fs";
|
|
285059
|
+
import { join as join73 } from "node:path";
|
|
285060
|
+
import { homedir as homedir26 } from "node:os";
|
|
284906
285061
|
function panelEffectivelyVisible() {
|
|
284907
285062
|
return _enabled && !_scopeOverlayActive && !_scopeNeovimActive && !_scopePagerActive && _scopeMainViewActive;
|
|
284908
285063
|
}
|
|
284909
285064
|
function todoDir2() {
|
|
284910
|
-
return
|
|
285065
|
+
return join73(homedir26(), ".open-agents", "todos");
|
|
284911
285066
|
}
|
|
284912
285067
|
function todoPath2(sessionId) {
|
|
284913
285068
|
const safe = sessionId.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
284914
|
-
return
|
|
285069
|
+
return join73(todoDir2(), `${safe}.json`);
|
|
284915
285070
|
}
|
|
284916
285071
|
function setTuiTasksSession(sessionId) {
|
|
284917
285072
|
if (sessionId === _activeSessionId) return;
|
|
@@ -285020,7 +285175,7 @@ function loadTodos() {
|
|
|
285020
285175
|
}
|
|
285021
285176
|
try {
|
|
285022
285177
|
const fp = todoPath2(_activeSessionId);
|
|
285023
|
-
if (!
|
|
285178
|
+
if (!existsSync56(fp)) {
|
|
285024
285179
|
_lastTodos = [];
|
|
285025
285180
|
return;
|
|
285026
285181
|
}
|
|
@@ -288834,9 +288989,9 @@ __export(personaplex_exports, {
|
|
|
288834
288989
|
startPersonaPlexDaemon: () => startPersonaPlexDaemon,
|
|
288835
288990
|
stopPersonaPlex: () => stopPersonaPlex
|
|
288836
288991
|
});
|
|
288837
|
-
import { existsSync as
|
|
288838
|
-
import { join as
|
|
288839
|
-
import { homedir as
|
|
288992
|
+
import { existsSync as existsSync57, writeFileSync as writeFileSync29, readFileSync as readFileSync44, mkdirSync as mkdirSync31, copyFileSync as copyFileSync2, readdirSync as readdirSync14, statSync as statSync16 } from "node:fs";
|
|
288993
|
+
import { join as join74, dirname as dirname21 } from "node:path";
|
|
288994
|
+
import { homedir as homedir27 } from "node:os";
|
|
288840
288995
|
import { execSync as execSync46, spawn as spawn19 } from "node:child_process";
|
|
288841
288996
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
288842
288997
|
function execAsync(cmd, opts = {}) {
|
|
@@ -288945,7 +289100,7 @@ function fileLink(filePath, label) {
|
|
|
288945
289100
|
return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
|
|
288946
289101
|
}
|
|
288947
289102
|
function isPersonaPlexRunning() {
|
|
288948
|
-
if (!
|
|
289103
|
+
if (!existsSync57(PID_FILE)) return false;
|
|
288949
289104
|
const pid = parseInt(readFileSync44(PID_FILE, "utf8").trim(), 10);
|
|
288950
289105
|
if (isNaN(pid) || pid <= 0) return false;
|
|
288951
289106
|
try {
|
|
@@ -288957,22 +289112,22 @@ function isPersonaPlexRunning() {
|
|
|
288957
289112
|
}
|
|
288958
289113
|
function getPersonaPlexWSUrl() {
|
|
288959
289114
|
if (!isPersonaPlexRunning()) return null;
|
|
288960
|
-
if (!
|
|
289115
|
+
if (!existsSync57(PORT_FILE)) return null;
|
|
288961
289116
|
const port = parseInt(readFileSync44(PORT_FILE, "utf8").trim(), 10);
|
|
288962
289117
|
return isNaN(port) ? null : `wss://127.0.0.1:${port}`;
|
|
288963
289118
|
}
|
|
288964
289119
|
function isPersonaPlexInstalled() {
|
|
288965
|
-
return
|
|
289120
|
+
return existsSync57(join74(PERSONAPLEX_DIR, "model_ready"));
|
|
288966
289121
|
}
|
|
288967
289122
|
function getWeightTier() {
|
|
288968
289123
|
const detected = detectPersonaPlexCapability();
|
|
288969
|
-
const tierFile =
|
|
288970
|
-
if (
|
|
289124
|
+
const tierFile = join74(PERSONAPLEX_DIR, "weight_tier");
|
|
289125
|
+
if (existsSync57(tierFile)) {
|
|
288971
289126
|
const saved = readFileSync44(tierFile, "utf8").trim();
|
|
288972
289127
|
if (saved in WEIGHT_REPOS) {
|
|
288973
289128
|
const vram = detected.vramGB;
|
|
288974
289129
|
if (saved === "nf4-distilled" && vram < 24) {
|
|
288975
|
-
|
|
289130
|
+
writeFileSync29(tierFile, "nf4");
|
|
288976
289131
|
return "nf4";
|
|
288977
289132
|
}
|
|
288978
289133
|
return saved;
|
|
@@ -288986,7 +289141,7 @@ function getWeightRepoInfo(tier) {
|
|
|
288986
289141
|
async function installPersonaPlex(onInfo, weightTier) {
|
|
288987
289142
|
const log22 = onInfo ?? (() => {
|
|
288988
289143
|
});
|
|
288989
|
-
|
|
289144
|
+
mkdirSync31(PERSONAPLEX_DIR, { recursive: true });
|
|
288990
289145
|
let arch2 = "";
|
|
288991
289146
|
try {
|
|
288992
289147
|
arch2 = execSync46("uname -m", { encoding: "utf8", timeout: 3e3, stdio: "pipe" }).trim();
|
|
@@ -288994,8 +289149,8 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
288994
289149
|
}
|
|
288995
289150
|
const isAarch64 = arch2 === "aarch64" || arch2 === "arm64";
|
|
288996
289151
|
if (isAarch64) log22(`Detected ARM64 platform (${arch2}) — Jetson/ARM install path`);
|
|
288997
|
-
const venvDir =
|
|
288998
|
-
if (!
|
|
289152
|
+
const venvDir = join74(PERSONAPLEX_DIR, "venv");
|
|
289153
|
+
if (!existsSync57(venvDir)) {
|
|
288999
289154
|
log22("Creating Python virtual environment...");
|
|
289000
289155
|
try {
|
|
289001
289156
|
const ssp = isAarch64 ? " --system-site-packages" : "";
|
|
@@ -289005,8 +289160,8 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
289005
289160
|
return false;
|
|
289006
289161
|
}
|
|
289007
289162
|
}
|
|
289008
|
-
const pip = process.platform === "win32" ?
|
|
289009
|
-
const python = process.platform === "win32" ?
|
|
289163
|
+
const pip = process.platform === "win32" ? join74(venvDir, "Scripts", "pip.exe") : join74(venvDir, "bin", "pip");
|
|
289164
|
+
const python = process.platform === "win32" ? join74(venvDir, "Scripts", "python.exe") : join74(venvDir, "bin", "python3");
|
|
289010
289165
|
log22("Checking system dependencies (libopus)...");
|
|
289011
289166
|
try {
|
|
289012
289167
|
if (process.platform === "linux") {
|
|
@@ -289036,9 +289191,9 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
289036
289191
|
}
|
|
289037
289192
|
}
|
|
289038
289193
|
log22("Installing PersonaPlex (moshi package)...");
|
|
289039
|
-
const repoDir =
|
|
289194
|
+
const repoDir = join74(PERSONAPLEX_DIR, "personaplex-repo");
|
|
289040
289195
|
try {
|
|
289041
|
-
if (!
|
|
289196
|
+
if (!existsSync57(repoDir)) {
|
|
289042
289197
|
await execAsync(
|
|
289043
289198
|
`git clone https://github.com/NVIDIA/personaplex.git "${repoDir}"`,
|
|
289044
289199
|
{ timeout: 12e4 }
|
|
@@ -289062,7 +289217,7 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
289062
289217
|
if (isAarch64) {
|
|
289063
289218
|
log22("ARM64: Installing moshi (--no-deps to preserve JetPack torch)...");
|
|
289064
289219
|
await execAsync(
|
|
289065
|
-
`"${pip}" install --quiet --no-deps "${
|
|
289220
|
+
`"${pip}" install --quiet --no-deps "${join74(repoDir, "moshi")}/."`,
|
|
289066
289221
|
{ timeout: 3e5 }
|
|
289067
289222
|
);
|
|
289068
289223
|
log22("ARM64: Installing remaining moshi dependencies...");
|
|
@@ -289072,7 +289227,7 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
289072
289227
|
);
|
|
289073
289228
|
} else {
|
|
289074
289229
|
await execAsync(
|
|
289075
|
-
`"${pip}" install --quiet "${
|
|
289230
|
+
`"${pip}" install --quiet "${join74(repoDir, "moshi")}/."`,
|
|
289076
289231
|
{ timeout: 6e5 }
|
|
289077
289232
|
// 10 min — torch download is ~2.5GB
|
|
289078
289233
|
);
|
|
@@ -289090,19 +289245,19 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
289090
289245
|
}
|
|
289091
289246
|
return false;
|
|
289092
289247
|
}
|
|
289093
|
-
const serverPy =
|
|
289248
|
+
const serverPy = join74(venvDir, "lib", `python3.${process.versions.node ? "12" : "10"}`, "site-packages", "moshi", "server.py");
|
|
289094
289249
|
try {
|
|
289095
289250
|
const sitePackages = execSync46(`"${python}" -c "import moshi, os; print(os.path.dirname(moshi.__file__))"`, {
|
|
289096
289251
|
encoding: "utf8",
|
|
289097
289252
|
timeout: 5e3,
|
|
289098
289253
|
stdio: "pipe"
|
|
289099
289254
|
}).trim();
|
|
289100
|
-
const serverFile =
|
|
289101
|
-
if (
|
|
289255
|
+
const serverFile = join74(sitePackages, "server.py");
|
|
289256
|
+
if (existsSync57(serverFile)) {
|
|
289102
289257
|
let src2 = readFileSync44(serverFile, "utf8");
|
|
289103
289258
|
if (src2.includes('int(request["seed"])')) {
|
|
289104
289259
|
src2 = src2.replace('int(request["seed"])', 'int(request.query["seed"])');
|
|
289105
|
-
|
|
289260
|
+
writeFileSync29(serverFile, src2);
|
|
289106
289261
|
log22("Applied seed parameter bug fix to moshi server.");
|
|
289107
289262
|
}
|
|
289108
289263
|
}
|
|
@@ -289114,8 +289269,8 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
289114
289269
|
timeout: 5e3,
|
|
289115
289270
|
stdio: "pipe"
|
|
289116
289271
|
}).trim();
|
|
289117
|
-
const loadersFile =
|
|
289118
|
-
if (
|
|
289272
|
+
const loadersFile = join74(sitePackages, "models", "loaders.py");
|
|
289273
|
+
if (existsSync57(loadersFile)) {
|
|
289119
289274
|
let src2 = readFileSync44(loadersFile, "utf8");
|
|
289120
289275
|
if (!src2.includes("_dequantize_2bit_state_dict")) {
|
|
289121
289276
|
const dequantPatch = `
|
|
@@ -289206,7 +289361,7 @@ $2if filename.endswith(".safetensors"):`
|
|
|
289206
289361
|
${patchPoint}`
|
|
289207
289362
|
);
|
|
289208
289363
|
}
|
|
289209
|
-
|
|
289364
|
+
writeFileSync29(loadersFile, src2);
|
|
289210
289365
|
log22("Patched loaders.py with 2-bit TurboQuant native dequant support.");
|
|
289211
289366
|
}
|
|
289212
289367
|
}
|
|
@@ -289218,16 +289373,16 @@ $2if filename.endswith(".safetensors"):`
|
|
|
289218
289373
|
timeout: 5e3,
|
|
289219
289374
|
stdio: "pipe"
|
|
289220
289375
|
}).trim();
|
|
289221
|
-
const hybridDest =
|
|
289222
|
-
const serverDest =
|
|
289223
|
-
if (!
|
|
289376
|
+
const hybridDest = join74(sitePackages2, "hybrid_agent.py");
|
|
289377
|
+
const serverDest = join74(sitePackages2, "server.py");
|
|
289378
|
+
if (!existsSync57(hybridDest) || !readFileSync44(hybridDest, "utf8").includes("OA_API_BASE")) {
|
|
289224
289379
|
log22("Deploying hybrid_agent.py (OA API integration)...");
|
|
289225
289380
|
try {
|
|
289226
289381
|
await execAsync(
|
|
289227
289382
|
`curl -sL "https://raw.githubusercontent.com/robit-man/personaplex/main/personaplex-setup/moshi/moshi/hybrid_agent.py" -o "${hybridDest}"`,
|
|
289228
289383
|
{ timeout: 3e4 }
|
|
289229
289384
|
);
|
|
289230
|
-
if (
|
|
289385
|
+
if (existsSync57(hybridDest) && readFileSync44(hybridDest, "utf8").includes("OA_API_BASE")) {
|
|
289231
289386
|
log22("hybrid_agent.py deployed (OA API + Ollama fallback).");
|
|
289232
289387
|
}
|
|
289233
289388
|
} catch {
|
|
@@ -289304,7 +289459,7 @@ $2if filename.endswith(".safetensors"):`
|
|
|
289304
289459
|
await execAsync(`"${python}" -c "from huggingface_hub import hf_hub_download; hf_hub_download('${nf4.repo}', '${nf4.file}', token=False)"`, {
|
|
289305
289460
|
timeout: 6e5
|
|
289306
289461
|
});
|
|
289307
|
-
|
|
289462
|
+
writeFileSync29(join74(PERSONAPLEX_DIR, "weight_tier"), "nf4");
|
|
289308
289463
|
log22(`Downloaded INT4 weights instead (${nf4.sizeGB}GB, public).`);
|
|
289309
289464
|
} catch {
|
|
289310
289465
|
log22("Weight download failed.");
|
|
@@ -289316,8 +289471,8 @@ $2if filename.endswith(".safetensors"):`
|
|
|
289316
289471
|
log22("Weights will download on first server launch.");
|
|
289317
289472
|
}
|
|
289318
289473
|
}
|
|
289319
|
-
|
|
289320
|
-
|
|
289474
|
+
writeFileSync29(join74(PERSONAPLEX_DIR, "weight_tier"), tier);
|
|
289475
|
+
writeFileSync29(join74(PERSONAPLEX_DIR, "model_ready"), (/* @__PURE__ */ new Date()).toISOString());
|
|
289321
289476
|
log22(`PersonaPlex installed (${tier} tier). Use /call to start voice session.`);
|
|
289322
289477
|
return true;
|
|
289323
289478
|
}
|
|
@@ -289336,15 +289491,15 @@ async function startPersonaPlexDaemon(onInfo) {
|
|
|
289336
289491
|
log22("PersonaPlex not installed. Run /voice personaplex to set up.");
|
|
289337
289492
|
return null;
|
|
289338
289493
|
}
|
|
289339
|
-
|
|
289340
|
-
const venvPython2 = process.platform === "win32" ?
|
|
289341
|
-
const sslDir =
|
|
289342
|
-
|
|
289494
|
+
mkdirSync31(PERSONAPLEX_DIR, { recursive: true });
|
|
289495
|
+
const venvPython2 = process.platform === "win32" ? join74(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join74(PERSONAPLEX_DIR, "venv", "bin", "python3");
|
|
289496
|
+
const sslDir = join74(PERSONAPLEX_DIR, "ssl");
|
|
289497
|
+
mkdirSync31(sslDir, { recursive: true });
|
|
289343
289498
|
const tier = getWeightTier();
|
|
289344
289499
|
const repoInfo = WEIGHT_REPOS[tier];
|
|
289345
289500
|
const extraArgs = [];
|
|
289346
289501
|
if (tier !== "original") {
|
|
289347
|
-
const cachedBf16 =
|
|
289502
|
+
const cachedBf16 = join74(PERSONAPLEX_DIR, "model-bf16-cache.safetensors");
|
|
289348
289503
|
if (tier === "nf4-distilled") {
|
|
289349
289504
|
log22(`Weight tier: ${tier} — distilled NF4 (90% token match, ${repoInfo.sizeGB}GB)...`);
|
|
289350
289505
|
try {
|
|
@@ -289352,8 +289507,8 @@ async function startPersonaPlexDaemon(onInfo) {
|
|
|
289352
289507
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', '${repoInfo.file}', token=False))"`,
|
|
289353
289508
|
{ encoding: "utf8", timeout: 6e4, stdio: "pipe" }
|
|
289354
289509
|
).trim();
|
|
289355
|
-
if (
|
|
289356
|
-
if (!
|
|
289510
|
+
if (existsSync57(weightPath)) {
|
|
289511
|
+
if (!existsSync57(cachedBf16)) {
|
|
289357
289512
|
log22("Converting .pt checkpoint to safetensors (one-time)...");
|
|
289358
289513
|
execSync46(
|
|
289359
289514
|
`"${venvPython2}" -c "
|
|
@@ -289366,7 +289521,7 @@ print('Converted')
|
|
|
289366
289521
|
{ timeout: 18e4, stdio: "pipe" }
|
|
289367
289522
|
);
|
|
289368
289523
|
}
|
|
289369
|
-
if (
|
|
289524
|
+
if (existsSync57(cachedBf16)) {
|
|
289370
289525
|
extraArgs.push("--moshi-weight", cachedBf16);
|
|
289371
289526
|
log22(`Using distilled weights: ${(statSync16(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
|
|
289372
289527
|
} else {
|
|
@@ -289378,12 +289533,12 @@ print('Converted')
|
|
|
289378
289533
|
}
|
|
289379
289534
|
} else {
|
|
289380
289535
|
log22(`Weight tier: ${tier} (${repoInfo.sizeGB}GB) — dequantizing to bf16 cache...`);
|
|
289381
|
-
const dequantScript =
|
|
289382
|
-
if (!
|
|
289536
|
+
const dequantScript = join74(PERSONAPLEX_DIR, "dequant-loader.py");
|
|
289537
|
+
if (!existsSync57(dequantScript)) {
|
|
289383
289538
|
const shipped = getShippedVoicesDir();
|
|
289384
289539
|
if (shipped) {
|
|
289385
|
-
const src2 =
|
|
289386
|
-
if (
|
|
289540
|
+
const src2 = join74(shipped, "dequant-loader.py");
|
|
289541
|
+
if (existsSync57(src2)) copyFileSync2(src2, dequantScript);
|
|
289387
289542
|
}
|
|
289388
289543
|
}
|
|
289389
289544
|
try {
|
|
@@ -289391,13 +289546,13 @@ print('Converted')
|
|
|
289391
289546
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', '${repoInfo.file}'${repoInfo.needsToken ? "" : ", token=False"}))"`,
|
|
289392
289547
|
{ encoding: "utf8", timeout: 3e4, stdio: "pipe" }
|
|
289393
289548
|
).trim();
|
|
289394
|
-
if (
|
|
289549
|
+
if (existsSync57(dequantScript) && existsSync57(weightPath)) {
|
|
289395
289550
|
try {
|
|
289396
289551
|
execSync46(
|
|
289397
289552
|
`"${venvPython2}" "${dequantScript}" --input "${weightPath}" --output "${cachedBf16}"`,
|
|
289398
289553
|
{ timeout: 3e5, stdio: "pipe" }
|
|
289399
289554
|
);
|
|
289400
|
-
if (
|
|
289555
|
+
if (existsSync57(cachedBf16)) {
|
|
289401
289556
|
extraArgs.push("--moshi-weight", cachedBf16);
|
|
289402
289557
|
log22(`Using dequantized cache: ${(statSync16(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
|
|
289403
289558
|
}
|
|
@@ -289410,7 +289565,7 @@ print('Converted')
|
|
|
289410
289565
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', 'tokenizer-e351c8d8-checkpoint125.safetensors', token=False))"`,
|
|
289411
289566
|
{ encoding: "utf8", timeout: 3e4, stdio: "pipe" }
|
|
289412
289567
|
).trim();
|
|
289413
|
-
if (
|
|
289568
|
+
if (existsSync57(mimiPath)) extraArgs.push("--mimi-weight", mimiPath);
|
|
289414
289569
|
} catch {
|
|
289415
289570
|
}
|
|
289416
289571
|
try {
|
|
@@ -289418,7 +289573,7 @@ print('Converted')
|
|
|
289418
289573
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', 'tokenizer_spm_32k_3.model', token=False))"`,
|
|
289419
289574
|
{ encoding: "utf8", timeout: 3e4, stdio: "pipe" }
|
|
289420
289575
|
).trim();
|
|
289421
|
-
if (
|
|
289576
|
+
if (existsSync57(tokPath)) extraArgs.push("--tokenizer", tokPath);
|
|
289422
289577
|
} catch {
|
|
289423
289578
|
}
|
|
289424
289579
|
} catch {
|
|
@@ -289431,7 +289586,7 @@ print('Converted')
|
|
|
289431
289586
|
let ollamaModel = process.env["HYBRID_LLM_MODEL"] || "";
|
|
289432
289587
|
if (!ollamaModel) {
|
|
289433
289588
|
try {
|
|
289434
|
-
const oaConfig = JSON.parse(readFileSync44(
|
|
289589
|
+
const oaConfig = JSON.parse(readFileSync44(join74(homedir27(), ".open-agents", "config.json"), "utf8"));
|
|
289435
289590
|
if (oaConfig.model) ollamaModel = oaConfig.model;
|
|
289436
289591
|
} catch {
|
|
289437
289592
|
}
|
|
@@ -289484,8 +289639,8 @@ print('Converted')
|
|
|
289484
289639
|
cwd: PERSONAPLEX_DIR
|
|
289485
289640
|
});
|
|
289486
289641
|
if (child.pid) {
|
|
289487
|
-
|
|
289488
|
-
|
|
289642
|
+
writeFileSync29(PID_FILE, String(child.pid));
|
|
289643
|
+
writeFileSync29(PORT_FILE, String(PORT));
|
|
289489
289644
|
registry2.register({
|
|
289490
289645
|
name: "PersonaPlex",
|
|
289491
289646
|
pid: child.pid,
|
|
@@ -289530,7 +289685,7 @@ print('Converted')
|
|
|
289530
289685
|
return null;
|
|
289531
289686
|
}
|
|
289532
289687
|
function stopPersonaPlex() {
|
|
289533
|
-
if (!
|
|
289688
|
+
if (!existsSync57(PID_FILE)) return;
|
|
289534
289689
|
const pid = parseInt(readFileSync44(PID_FILE, "utf8").trim(), 10);
|
|
289535
289690
|
if (isNaN(pid) || pid <= 0) return;
|
|
289536
289691
|
try {
|
|
@@ -289567,12 +289722,12 @@ function listPersonaPlexVoices() {
|
|
|
289567
289722
|
for (const name11 of builtins) {
|
|
289568
289723
|
voices.push({ name: name11, type: "builtin", path: `${name11}.pt` });
|
|
289569
289724
|
}
|
|
289570
|
-
if (
|
|
289725
|
+
if (existsSync57(CUSTOM_VOICES_DIR)) {
|
|
289571
289726
|
try {
|
|
289572
289727
|
for (const f2 of readdirSync14(CUSTOM_VOICES_DIR)) {
|
|
289573
289728
|
if (f2.endsWith(".pt")) {
|
|
289574
289729
|
const name11 = f2.replace(/\.pt$/, "");
|
|
289575
|
-
voices.push({ name: name11, type: "custom", path:
|
|
289730
|
+
voices.push({ name: name11, type: "custom", path: join74(CUSTOM_VOICES_DIR, f2) });
|
|
289576
289731
|
}
|
|
289577
289732
|
}
|
|
289578
289733
|
} catch {
|
|
@@ -289587,19 +289742,19 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
289587
289742
|
log22("PersonaPlex not installed. Run /voice personaplex first.");
|
|
289588
289743
|
return null;
|
|
289589
289744
|
}
|
|
289590
|
-
if (!
|
|
289745
|
+
if (!existsSync57(inputWav)) {
|
|
289591
289746
|
log22(`Input WAV not found: ${inputWav}`);
|
|
289592
289747
|
return null;
|
|
289593
289748
|
}
|
|
289594
|
-
|
|
289595
|
-
const outputPt =
|
|
289596
|
-
if (
|
|
289749
|
+
mkdirSync31(CUSTOM_VOICES_DIR, { recursive: true });
|
|
289750
|
+
const outputPt = join74(CUSTOM_VOICES_DIR, `${voiceName}.pt`);
|
|
289751
|
+
if (existsSync57(outputPt)) {
|
|
289597
289752
|
log22(`Voice "${voiceName}" already exists. Delete ${outputPt} to re-clone.`);
|
|
289598
289753
|
return outputPt;
|
|
289599
289754
|
}
|
|
289600
|
-
const venvPython2 = process.platform === "win32" ?
|
|
289601
|
-
const cloneScript =
|
|
289602
|
-
if (!
|
|
289755
|
+
const venvPython2 = process.platform === "win32" ? join74(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join74(PERSONAPLEX_DIR, "venv", "bin", "python3");
|
|
289756
|
+
const cloneScript = join74(PERSONAPLEX_DIR, "clone-voice.py");
|
|
289757
|
+
if (!existsSync57(cloneScript)) {
|
|
289603
289758
|
log22("clone-voice.py not found. Reinstall PersonaPlex.");
|
|
289604
289759
|
return null;
|
|
289605
289760
|
}
|
|
@@ -289631,7 +289786,7 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
289631
289786
|
output += d2.toString();
|
|
289632
289787
|
});
|
|
289633
289788
|
child.on("close", (code8) => {
|
|
289634
|
-
if (code8 === 0 &&
|
|
289789
|
+
if (code8 === 0 && existsSync57(outputPt)) {
|
|
289635
289790
|
log22(`Voice "${voiceName}" cloned successfully.`);
|
|
289636
289791
|
resolve40(outputPt);
|
|
289637
289792
|
} else {
|
|
@@ -289643,19 +289798,19 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
289643
289798
|
}
|
|
289644
289799
|
function getShippedVoicesDir() {
|
|
289645
289800
|
const candidates = [
|
|
289646
|
-
|
|
289801
|
+
join74(PERSONAPLEX_DIR, "shipped_voices"),
|
|
289647
289802
|
// cached copy
|
|
289648
|
-
|
|
289803
|
+
join74(process.cwd(), "voices", "personaplex")
|
|
289649
289804
|
// repo root
|
|
289650
289805
|
];
|
|
289651
289806
|
try {
|
|
289652
289807
|
const modDir = dirname21(fileURLToPath13(import.meta.url));
|
|
289653
|
-
candidates.push(
|
|
289654
|
-
candidates.push(
|
|
289808
|
+
candidates.push(join74(modDir, "..", "..", "..", "voices", "personaplex"));
|
|
289809
|
+
candidates.push(join74(modDir, "..", "..", "..", "..", "voices", "personaplex"));
|
|
289655
289810
|
} catch {
|
|
289656
289811
|
}
|
|
289657
289812
|
for (const dir of candidates) {
|
|
289658
|
-
if (
|
|
289813
|
+
if (existsSync57(dir)) {
|
|
289659
289814
|
try {
|
|
289660
289815
|
const files = readdirSync14(dir);
|
|
289661
289816
|
if (files.some((f2) => f2.endsWith(".pt"))) return dir;
|
|
@@ -289671,19 +289826,19 @@ function provisionShippedVoices(onInfo) {
|
|
|
289671
289826
|
const shippedDir = getShippedVoicesDir();
|
|
289672
289827
|
if (!shippedDir) return 0;
|
|
289673
289828
|
const hfVoicesDir = getHFVoicesDir();
|
|
289674
|
-
|
|
289829
|
+
mkdirSync31(CUSTOM_VOICES_DIR, { recursive: true });
|
|
289675
289830
|
let deployed = 0;
|
|
289676
289831
|
try {
|
|
289677
289832
|
for (const f2 of readdirSync14(shippedDir)) {
|
|
289678
289833
|
if (!f2.endsWith(".pt")) continue;
|
|
289679
|
-
const customDst =
|
|
289680
|
-
if (!
|
|
289681
|
-
copyFileSync2(
|
|
289834
|
+
const customDst = join74(CUSTOM_VOICES_DIR, f2);
|
|
289835
|
+
if (!existsSync57(customDst)) {
|
|
289836
|
+
copyFileSync2(join74(shippedDir, f2), customDst);
|
|
289682
289837
|
}
|
|
289683
289838
|
if (hfVoicesDir) {
|
|
289684
|
-
const hfDst =
|
|
289685
|
-
if (!
|
|
289686
|
-
copyFileSync2(
|
|
289839
|
+
const hfDst = join74(hfVoicesDir, f2);
|
|
289840
|
+
if (!existsSync57(hfDst)) {
|
|
289841
|
+
copyFileSync2(join74(shippedDir, f2), hfDst);
|
|
289687
289842
|
log22(`Deployed voice: ${f2.replace(".pt", "")}`);
|
|
289688
289843
|
deployed++;
|
|
289689
289844
|
}
|
|
@@ -289691,9 +289846,9 @@ function provisionShippedVoices(onInfo) {
|
|
|
289691
289846
|
}
|
|
289692
289847
|
} catch {
|
|
289693
289848
|
}
|
|
289694
|
-
const shippedScript =
|
|
289695
|
-
const targetScript =
|
|
289696
|
-
if (
|
|
289849
|
+
const shippedScript = join74(shippedDir, "clone-voice.py");
|
|
289850
|
+
const targetScript = join74(PERSONAPLEX_DIR, "clone-voice.py");
|
|
289851
|
+
if (existsSync57(shippedScript) && !existsSync57(targetScript)) {
|
|
289697
289852
|
try {
|
|
289698
289853
|
copyFileSync2(shippedScript, targetScript);
|
|
289699
289854
|
} catch {
|
|
@@ -289702,14 +289857,14 @@ function provisionShippedVoices(onInfo) {
|
|
|
289702
289857
|
return deployed;
|
|
289703
289858
|
}
|
|
289704
289859
|
function getHFVoicesDir() {
|
|
289705
|
-
const hfBase =
|
|
289706
|
-
if (!
|
|
289860
|
+
const hfBase = join74(homedir27(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
|
|
289861
|
+
if (!existsSync57(hfBase)) return null;
|
|
289707
289862
|
try {
|
|
289708
|
-
const snapshots =
|
|
289709
|
-
if (!
|
|
289863
|
+
const snapshots = join74(hfBase, "snapshots");
|
|
289864
|
+
if (!existsSync57(snapshots)) return null;
|
|
289710
289865
|
for (const snap of readdirSync14(snapshots)) {
|
|
289711
|
-
const voicesDir =
|
|
289712
|
-
if (
|
|
289866
|
+
const voicesDir = join74(snapshots, snap, "voices");
|
|
289867
|
+
if (existsSync57(voicesDir)) return voicesDir;
|
|
289713
289868
|
}
|
|
289714
289869
|
} catch {
|
|
289715
289870
|
}
|
|
@@ -289718,19 +289873,19 @@ function getHFVoicesDir() {
|
|
|
289718
289873
|
function patchFrontendVoiceList(onInfo) {
|
|
289719
289874
|
const log22 = onInfo ?? (() => {
|
|
289720
289875
|
});
|
|
289721
|
-
const hfBase =
|
|
289722
|
-
if (!
|
|
289876
|
+
const hfBase = join74(homedir27(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
|
|
289877
|
+
if (!existsSync57(hfBase)) return;
|
|
289723
289878
|
try {
|
|
289724
|
-
const snapshots =
|
|
289879
|
+
const snapshots = join74(hfBase, "snapshots");
|
|
289725
289880
|
for (const snap of readdirSync14(snapshots)) {
|
|
289726
|
-
const distDir =
|
|
289727
|
-
if (!
|
|
289881
|
+
const distDir = join74(snapshots, snap, "dist", "assets");
|
|
289882
|
+
if (!existsSync57(distDir)) continue;
|
|
289728
289883
|
for (const f2 of readdirSync14(distDir)) {
|
|
289729
289884
|
if (!f2.startsWith("index-") || !f2.endsWith(".js")) continue;
|
|
289730
|
-
const jsPath =
|
|
289885
|
+
const jsPath = join74(distDir, f2);
|
|
289731
289886
|
let js = readFileSync44(jsPath, "utf8");
|
|
289732
289887
|
const customVoices = [];
|
|
289733
|
-
if (
|
|
289888
|
+
if (existsSync57(CUSTOM_VOICES_DIR)) {
|
|
289734
289889
|
for (const vf of readdirSync14(CUSTOM_VOICES_DIR)) {
|
|
289735
289890
|
if (vf.endsWith(".pt")) {
|
|
289736
289891
|
const name11 = vf.replace(".pt", "");
|
|
@@ -289745,7 +289900,7 @@ function patchFrontendVoiceList(onInfo) {
|
|
|
289745
289900
|
if (js.includes(needle)) {
|
|
289746
289901
|
const additions = customVoices.map((v) => `"${v}"`).join(", ");
|
|
289747
289902
|
js = js.replace(needle, `"VARM4.pt", ${additions}]`);
|
|
289748
|
-
|
|
289903
|
+
writeFileSync29(jsPath, js);
|
|
289749
289904
|
log22(`Added ${customVoices.length} custom voice(s) to frontend: ${customVoices.map((v) => v.replace(".pt", "")).join(", ")}`);
|
|
289750
289905
|
}
|
|
289751
289906
|
}
|
|
@@ -289796,11 +289951,11 @@ var init_personaplex = __esm({
|
|
|
289796
289951
|
nf4: { repo: "cudabenchmarktest/personaplex-7b-nf4", file: "model-nf4.safetensors", sizeGB: 4.1, needsToken: false },
|
|
289797
289952
|
"nf4-distilled": { repo: "cudabenchmarktest/personaplex-7b-nf4-distilled", file: "student_best.pt", sizeGB: 16.7, needsToken: false }
|
|
289798
289953
|
};
|
|
289799
|
-
PERSONAPLEX_DIR =
|
|
289800
|
-
PID_FILE =
|
|
289801
|
-
PORT_FILE =
|
|
289802
|
-
LOG_FILE =
|
|
289803
|
-
CUSTOM_VOICES_DIR =
|
|
289954
|
+
PERSONAPLEX_DIR = join74(homedir27(), ".open-agents", "voice", "personaplex");
|
|
289955
|
+
PID_FILE = join74(PERSONAPLEX_DIR, "daemon.pid");
|
|
289956
|
+
PORT_FILE = join74(PERSONAPLEX_DIR, "daemon.port");
|
|
289957
|
+
LOG_FILE = join74(PERSONAPLEX_DIR, "daemon.log");
|
|
289958
|
+
CUSTOM_VOICES_DIR = join74(PERSONAPLEX_DIR, "custom_voices");
|
|
289804
289959
|
}
|
|
289805
289960
|
});
|
|
289806
289961
|
|
|
@@ -289842,9 +289997,9 @@ __export(setup_exports, {
|
|
|
289842
289997
|
import * as readline from "node:readline";
|
|
289843
289998
|
import { execSync as execSync47, spawn as spawn20, exec as exec3 } from "node:child_process";
|
|
289844
289999
|
import { promisify as promisify7 } from "node:util";
|
|
289845
|
-
import { existsSync as
|
|
289846
|
-
import { join as
|
|
289847
|
-
import { homedir as
|
|
290000
|
+
import { existsSync as existsSync58, writeFileSync as writeFileSync30, readFileSync as readFileSync45, appendFileSync as appendFileSync2, mkdirSync as mkdirSync32 } from "node:fs";
|
|
290001
|
+
import { join as join75 } from "node:path";
|
|
290002
|
+
import { homedir as homedir28, platform as platform3 } from "node:os";
|
|
289848
290003
|
async function checkToolSupport(modelName, backendUrl = "http://localhost:11434") {
|
|
289849
290004
|
if (_toolSupportCache.has(modelName)) return _toolSupportCache.get(modelName);
|
|
289850
290005
|
try {
|
|
@@ -290166,7 +290321,7 @@ function detectAskpassHelper() {
|
|
|
290166
290321
|
if (process.platform === "linux") {
|
|
290167
290322
|
for (const path5 of linuxHelpers) {
|
|
290168
290323
|
try {
|
|
290169
|
-
if (
|
|
290324
|
+
if (existsSync58(path5)) return path5;
|
|
290170
290325
|
} catch {
|
|
290171
290326
|
}
|
|
290172
290327
|
}
|
|
@@ -290183,12 +290338,12 @@ function detectAskpassHelper() {
|
|
|
290183
290338
|
return null;
|
|
290184
290339
|
}
|
|
290185
290340
|
function writeAskpassHelper() {
|
|
290186
|
-
const tmpDir =
|
|
290341
|
+
const tmpDir = join75(homedir28(), ".open-agents");
|
|
290187
290342
|
try {
|
|
290188
|
-
|
|
290343
|
+
mkdirSync32(tmpDir, { recursive: true });
|
|
290189
290344
|
} catch {
|
|
290190
290345
|
}
|
|
290191
|
-
const helperPath =
|
|
290346
|
+
const helperPath = join75(tmpDir, "askpass-helper.sh");
|
|
290192
290347
|
let body = "";
|
|
290193
290348
|
if (process.platform === "darwin") {
|
|
290194
290349
|
body = `#!/bin/sh
|
|
@@ -290215,7 +290370,7 @@ osascript -e 'Tell application "System Events" to display dialog "Open Agents ne
|
|
|
290215
290370
|
return null;
|
|
290216
290371
|
}
|
|
290217
290372
|
try {
|
|
290218
|
-
|
|
290373
|
+
writeFileSync30(helperPath, body, { mode: 448 });
|
|
290219
290374
|
execSync47(`chmod 700 "${helperPath}"`, { stdio: "ignore" });
|
|
290220
290375
|
return helperPath;
|
|
290221
290376
|
} catch {
|
|
@@ -290387,7 +290542,7 @@ async function installOllamaMac(_rl) {
|
|
|
290387
290542
|
);
|
|
290388
290543
|
if (!hasCmd("brew")) {
|
|
290389
290544
|
try {
|
|
290390
|
-
const brewPrefix =
|
|
290545
|
+
const brewPrefix = existsSync58("/opt/homebrew/bin/brew") ? "/opt/homebrew" : "/usr/local";
|
|
290391
290546
|
process.env["PATH"] = `${brewPrefix}/bin:${process.env["PATH"]}`;
|
|
290392
290547
|
} catch {
|
|
290393
290548
|
}
|
|
@@ -291172,10 +291327,10 @@ async function doSetup(config, rl) {
|
|
|
291172
291327
|
`PARAMETER num_predict ${numPredict}`,
|
|
291173
291328
|
`PARAMETER stop "<|endoftext|>"`
|
|
291174
291329
|
].join("\n");
|
|
291175
|
-
const modelDir2 =
|
|
291176
|
-
|
|
291177
|
-
const modelfilePath =
|
|
291178
|
-
|
|
291330
|
+
const modelDir2 = join75(homedir28(), ".open-agents", "models");
|
|
291331
|
+
mkdirSync32(modelDir2, { recursive: true });
|
|
291332
|
+
const modelfilePath = join75(modelDir2, `Modelfile.${customName}`);
|
|
291333
|
+
writeFileSync30(modelfilePath, modelfileContent + "\n", "utf8");
|
|
291179
291334
|
process.stdout.write(` ${c3.dim("Creating model...")} `);
|
|
291180
291335
|
execSync47(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
291181
291336
|
stdio: "pipe",
|
|
@@ -291220,7 +291375,7 @@ async function isModelAvailable(config) {
|
|
|
291220
291375
|
}
|
|
291221
291376
|
function isFirstRun() {
|
|
291222
291377
|
try {
|
|
291223
|
-
return !
|
|
291378
|
+
return !existsSync58(join75(homedir28(), ".open-agents", "config.json"));
|
|
291224
291379
|
} catch {
|
|
291225
291380
|
return true;
|
|
291226
291381
|
}
|
|
@@ -291267,8 +291422,8 @@ function detectPkgManager() {
|
|
|
291267
291422
|
if (hasCmd("brew")) return "brew";
|
|
291268
291423
|
return null;
|
|
291269
291424
|
}
|
|
291270
|
-
function
|
|
291271
|
-
return
|
|
291425
|
+
function getVenvDir2() {
|
|
291426
|
+
return join75(homedir28(), ".open-agents", "venv");
|
|
291272
291427
|
}
|
|
291273
291428
|
function hasVenvModule() {
|
|
291274
291429
|
try {
|
|
@@ -291279,12 +291434,12 @@ function hasVenvModule() {
|
|
|
291279
291434
|
}
|
|
291280
291435
|
}
|
|
291281
291436
|
function ensureVenv(log22) {
|
|
291282
|
-
const venvDir =
|
|
291437
|
+
const venvDir = getVenvDir2();
|
|
291283
291438
|
const isWin2 = process.platform === "win32";
|
|
291284
|
-
const pipPath = isWin2 ?
|
|
291285
|
-
const venvPyPath = isWin2 ?
|
|
291439
|
+
const pipPath = isWin2 ? join75(venvDir, "Scripts", "pip.exe") : join75(venvDir, "bin", "pip");
|
|
291440
|
+
const venvPyPath = isWin2 ? join75(venvDir, "Scripts", "python.exe") : join75(venvDir, "bin", "python3");
|
|
291286
291441
|
const pythonCmd = isWin2 ? "python" : "python3";
|
|
291287
|
-
if (
|
|
291442
|
+
if (existsSync58(pipPath)) {
|
|
291288
291443
|
try {
|
|
291289
291444
|
execSync47(`"${venvPyPath}" -m pip --version`, { stdio: "pipe", timeout: 1e4 });
|
|
291290
291445
|
return venvDir;
|
|
@@ -291315,7 +291470,7 @@ function ensureVenv(log22) {
|
|
|
291315
291470
|
return null;
|
|
291316
291471
|
}
|
|
291317
291472
|
try {
|
|
291318
|
-
|
|
291473
|
+
mkdirSync32(join75(homedir28(), ".open-agents"), { recursive: true });
|
|
291319
291474
|
const pyCmd = hasCmd(pythonCmd) ? pythonCmd : "python3";
|
|
291320
291475
|
execSync47(`${pyCmd} -m venv --clear "${venvDir}"`, { stdio: "pipe", timeout: 3e4 });
|
|
291321
291476
|
try {
|
|
@@ -291424,11 +291579,11 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
291424
291579
|
];
|
|
291425
291580
|
{
|
|
291426
291581
|
const pm2 = detectPkgManager();
|
|
291427
|
-
const _visionMarkerDir =
|
|
291428
|
-
const _visionMarkerFile =
|
|
291582
|
+
const _visionMarkerDir = join75(homedir28(), ".open-agents");
|
|
291583
|
+
const _visionMarkerFile = join75(_visionMarkerDir, "vision-deps-installed.json");
|
|
291429
291584
|
let _visionPreviouslyInstalled = /* @__PURE__ */ new Set();
|
|
291430
291585
|
try {
|
|
291431
|
-
if (
|
|
291586
|
+
if (existsSync58(_visionMarkerFile)) {
|
|
291432
291587
|
const _vm = JSON.parse(readFileSync45(_visionMarkerFile, "utf8"));
|
|
291433
291588
|
_visionPreviouslyInstalled = new Set(_vm.installed || []);
|
|
291434
291589
|
}
|
|
@@ -291542,8 +291697,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
291542
291697
|
}
|
|
291543
291698
|
}
|
|
291544
291699
|
try {
|
|
291545
|
-
|
|
291546
|
-
|
|
291700
|
+
mkdirSync32(_visionMarkerDir, { recursive: true });
|
|
291701
|
+
writeFileSync30(_visionMarkerFile, JSON.stringify({
|
|
291547
291702
|
installed: [..._visionPreviouslyInstalled],
|
|
291548
291703
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
291549
291704
|
}, null, 2));
|
|
@@ -291593,17 +291748,17 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
291593
291748
|
}
|
|
291594
291749
|
}
|
|
291595
291750
|
}
|
|
291596
|
-
const venvDir =
|
|
291751
|
+
const venvDir = getVenvDir2();
|
|
291597
291752
|
const isWin2 = process.platform === "win32";
|
|
291598
|
-
const venvBin =
|
|
291599
|
-
const venvMoondream =
|
|
291753
|
+
const venvBin = join75(venvDir, isWin2 ? "Scripts" : "bin");
|
|
291754
|
+
const venvMoondream = join75(venvBin, isWin2 ? "moondream-station.exe" : "moondream-station");
|
|
291600
291755
|
const venv = ensureVenv(log22);
|
|
291601
|
-
if (venv && !hasCmd("moondream-station") && !
|
|
291602
|
-
const venvPip2 =
|
|
291756
|
+
if (venv && !hasCmd("moondream-station") && !existsSync58(venvMoondream)) {
|
|
291757
|
+
const venvPip2 = join75(venvBin, "pip");
|
|
291603
291758
|
log22("Installing moondream-station in ~/.open-agents/venv...");
|
|
291604
291759
|
try {
|
|
291605
291760
|
execSync47(`"${venvPip2}" install moondream-station`, { stdio: "pipe", timeout: 3e5 });
|
|
291606
|
-
if (
|
|
291761
|
+
if (existsSync58(venvMoondream)) {
|
|
291607
291762
|
log22("moondream-station installed successfully.");
|
|
291608
291763
|
} else {
|
|
291609
291764
|
try {
|
|
@@ -291620,8 +291775,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
291620
291775
|
}
|
|
291621
291776
|
}
|
|
291622
291777
|
if (venv) {
|
|
291623
|
-
const venvPython2 =
|
|
291624
|
-
const venvPip2 =
|
|
291778
|
+
const venvPython2 = join75(venvBin, isWin2 ? "python.exe" : "python");
|
|
291779
|
+
const venvPip2 = join75(venvBin, isWin2 ? "pip.exe" : "pip");
|
|
291625
291780
|
let ocrStackInstalled = false;
|
|
291626
291781
|
try {
|
|
291627
291782
|
execSync47(
|
|
@@ -291677,11 +291832,11 @@ function ensureCloudflaredBackground(onInfo) {
|
|
|
291677
291832
|
const cfArch = archMap[arch2] ?? "amd64";
|
|
291678
291833
|
try {
|
|
291679
291834
|
execSync47(
|
|
291680
|
-
`curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${cfArch}" -o /tmp/cloudflared && chmod +x /tmp/cloudflared && mkdir -p "${
|
|
291835
|
+
`curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${cfArch}" -o /tmp/cloudflared && chmod +x /tmp/cloudflared && mkdir -p "${homedir28()}/.local/bin" && mv /tmp/cloudflared "${homedir28()}/.local/bin/cloudflared"`,
|
|
291681
291836
|
{ stdio: "pipe", timeout: 6e4 }
|
|
291682
291837
|
);
|
|
291683
|
-
if (!process.env.PATH?.includes(`${
|
|
291684
|
-
process.env.PATH = `${
|
|
291838
|
+
if (!process.env.PATH?.includes(`${homedir28()}/.local/bin`)) {
|
|
291839
|
+
process.env.PATH = `${homedir28()}/.local/bin:${process.env.PATH}`;
|
|
291685
291840
|
}
|
|
291686
291841
|
if (hasCmd("cloudflared")) {
|
|
291687
291842
|
log22("cloudflared installed.");
|
|
@@ -291778,10 +291933,10 @@ function createExpandedVariant(baseModel, specs, sizeGB, kvBytesPerToken, archMa
|
|
|
291778
291933
|
`PARAMETER num_predict ${numPredict}`,
|
|
291779
291934
|
`PARAMETER stop "<|endoftext|>"`
|
|
291780
291935
|
].join("\n");
|
|
291781
|
-
const modelDir2 =
|
|
291782
|
-
|
|
291783
|
-
const modelfilePath =
|
|
291784
|
-
|
|
291936
|
+
const modelDir2 = join75(homedir28(), ".open-agents", "models");
|
|
291937
|
+
mkdirSync32(modelDir2, { recursive: true });
|
|
291938
|
+
const modelfilePath = join75(modelDir2, `Modelfile.${customName}`);
|
|
291939
|
+
writeFileSync30(modelfilePath, modelfileContent + "\n", "utf8");
|
|
291785
291940
|
execSync47(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
291786
291941
|
stdio: "pipe",
|
|
291787
291942
|
timeout: 12e4
|
|
@@ -291803,10 +291958,10 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
|
|
|
291803
291958
|
`PARAMETER num_predict ${numPredict}`,
|
|
291804
291959
|
`PARAMETER stop "<|endoftext|>"`
|
|
291805
291960
|
].join("\n");
|
|
291806
|
-
const modelDir2 =
|
|
291807
|
-
|
|
291808
|
-
const modelfilePath =
|
|
291809
|
-
|
|
291961
|
+
const modelDir2 = join75(homedir28(), ".open-agents", "models");
|
|
291962
|
+
mkdirSync32(modelDir2, { recursive: true });
|
|
291963
|
+
const modelfilePath = join75(modelDir2, `Modelfile.${customName}`);
|
|
291964
|
+
writeFileSync30(modelfilePath, modelfileContent + "\n", "utf8");
|
|
291810
291965
|
await execAsync2(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
291811
291966
|
timeout: 12e4
|
|
291812
291967
|
});
|
|
@@ -291879,10 +292034,10 @@ async function ensureNeovim() {
|
|
|
291879
292034
|
const platform6 = process.platform;
|
|
291880
292035
|
const arch2 = process.arch;
|
|
291881
292036
|
if (platform6 === "linux") {
|
|
291882
|
-
const binDir =
|
|
291883
|
-
const nvimDest =
|
|
292037
|
+
const binDir = join75(homedir28(), ".local", "bin");
|
|
292038
|
+
const nvimDest = join75(binDir, "nvim");
|
|
291884
292039
|
try {
|
|
291885
|
-
|
|
292040
|
+
mkdirSync32(binDir, { recursive: true });
|
|
291886
292041
|
} catch {
|
|
291887
292042
|
}
|
|
291888
292043
|
const appImageName = arch2 === "arm64" ? "nvim-linux-arm64.appimage" : "nvim-linux-x86_64.appimage";
|
|
@@ -291951,9 +292106,9 @@ async function ensureNeovim() {
|
|
|
291951
292106
|
}
|
|
291952
292107
|
function ensurePathInShellRc(binDir) {
|
|
291953
292108
|
const shell = process.env.SHELL ?? "";
|
|
291954
|
-
const rcFile = shell.includes("zsh") ?
|
|
292109
|
+
const rcFile = shell.includes("zsh") ? join75(homedir28(), ".zshrc") : join75(homedir28(), ".bashrc");
|
|
291955
292110
|
try {
|
|
291956
|
-
const rcContent =
|
|
292111
|
+
const rcContent = existsSync58(rcFile) ? readFileSync45(rcFile, "utf8") : "";
|
|
291957
292112
|
if (rcContent.includes(binDir)) return;
|
|
291958
292113
|
const exportLine = `
|
|
291959
292114
|
export PATH="${binDir}:$PATH" # Added by open-agents for nvim
|
|
@@ -291990,7 +292145,7 @@ var init_setup = __esm({
|
|
|
291990
292145
|
});
|
|
291991
292146
|
|
|
291992
292147
|
// packages/cli/src/tui/drop-panel.ts
|
|
291993
|
-
import { existsSync as
|
|
292148
|
+
import { existsSync as existsSync59 } from "node:fs";
|
|
291994
292149
|
import { extname as extname10, resolve as resolve32 } from "node:path";
|
|
291995
292150
|
function ansi3(code8, text) {
|
|
291996
292151
|
return isTTY3 ? `\x1B[${code8}m${text}\x1B[0m` : text;
|
|
@@ -292111,7 +292266,7 @@ function showDropPanel(opts) {
|
|
|
292111
292266
|
filePath = decodeURIComponent(filePath.slice(7));
|
|
292112
292267
|
}
|
|
292113
292268
|
filePath = resolve32(filePath);
|
|
292114
|
-
if (!
|
|
292269
|
+
if (!existsSync59(filePath)) {
|
|
292115
292270
|
errorMsg = `File not found: ${filePath}`;
|
|
292116
292271
|
render2();
|
|
292117
292272
|
return;
|
|
@@ -292183,9 +292338,9 @@ var init_drop_panel = __esm({
|
|
|
292183
292338
|
});
|
|
292184
292339
|
|
|
292185
292340
|
// packages/cli/src/tui/neovim-mode.ts
|
|
292186
|
-
import { existsSync as
|
|
292341
|
+
import { existsSync as existsSync60, unlinkSync as unlinkSync15 } from "node:fs";
|
|
292187
292342
|
import { tmpdir as tmpdir18 } from "node:os";
|
|
292188
|
-
import { join as
|
|
292343
|
+
import { join as join76 } from "node:path";
|
|
292189
292344
|
import { execSync as execSync48 } from "node:child_process";
|
|
292190
292345
|
function isNeovimActive() {
|
|
292191
292346
|
return _state !== null && !_state.cleanedUp;
|
|
@@ -292231,9 +292386,9 @@ async function startNeovimMode(opts) {
|
|
|
292231
292386
|
);
|
|
292232
292387
|
} catch {
|
|
292233
292388
|
}
|
|
292234
|
-
const socketPath =
|
|
292389
|
+
const socketPath = join76(tmpdir18(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
|
|
292235
292390
|
try {
|
|
292236
|
-
if (
|
|
292391
|
+
if (existsSync60(socketPath)) unlinkSync15(socketPath);
|
|
292237
292392
|
} catch {
|
|
292238
292393
|
}
|
|
292239
292394
|
const ptyCols = opts.cols;
|
|
@@ -292480,12 +292635,12 @@ function resizeNeovim(cols, contentRows) {
|
|
|
292480
292635
|
}
|
|
292481
292636
|
async function connectRPC(state, neovimPkg, cols) {
|
|
292482
292637
|
let attempts = 0;
|
|
292483
|
-
while (!
|
|
292638
|
+
while (!existsSync60(state.socketPath) && attempts < 30) {
|
|
292484
292639
|
await new Promise((r2) => setTimeout(r2, 200));
|
|
292485
292640
|
attempts++;
|
|
292486
292641
|
if (state.cleanedUp) return;
|
|
292487
292642
|
}
|
|
292488
|
-
if (!
|
|
292643
|
+
if (!existsSync60(state.socketPath)) return;
|
|
292489
292644
|
const nvim = neovimPkg.attach({ socket: state.socketPath });
|
|
292490
292645
|
state.nvim = nvim;
|
|
292491
292646
|
await new Promise((r2) => setTimeout(r2, 300));
|
|
@@ -292622,7 +292777,7 @@ function doCleanup(state) {
|
|
|
292622
292777
|
state.pty = null;
|
|
292623
292778
|
}
|
|
292624
292779
|
try {
|
|
292625
|
-
if (
|
|
292780
|
+
if (existsSync60(state.socketPath)) unlinkSync15(state.socketPath);
|
|
292626
292781
|
} catch {
|
|
292627
292782
|
}
|
|
292628
292783
|
if (state.stdinHandler) {
|
|
@@ -292692,9 +292847,9 @@ __export(daemon_exports, {
|
|
|
292692
292847
|
stopDaemon: () => stopDaemon
|
|
292693
292848
|
});
|
|
292694
292849
|
import { spawn as spawn21 } from "node:child_process";
|
|
292695
|
-
import { existsSync as
|
|
292696
|
-
import { join as
|
|
292697
|
-
import { homedir as
|
|
292850
|
+
import { existsSync as existsSync61, readFileSync as readFileSync46, writeFileSync as writeFileSync31, mkdirSync as mkdirSync33, unlinkSync as unlinkSync16 } from "node:fs";
|
|
292851
|
+
import { join as join77 } from "node:path";
|
|
292852
|
+
import { homedir as homedir29 } from "node:os";
|
|
292698
292853
|
import { fileURLToPath as fileURLToPath14 } from "node:url";
|
|
292699
292854
|
import { dirname as dirname22 } from "node:path";
|
|
292700
292855
|
function getDaemonPort() {
|
|
@@ -292718,7 +292873,7 @@ async function isDaemonRunning(port) {
|
|
|
292718
292873
|
}
|
|
292719
292874
|
}
|
|
292720
292875
|
function getDaemonPid() {
|
|
292721
|
-
if (!
|
|
292876
|
+
if (!existsSync61(PID_FILE2)) return null;
|
|
292722
292877
|
try {
|
|
292723
292878
|
const pid = parseInt(readFileSync46(PID_FILE2, "utf8").trim(), 10);
|
|
292724
292879
|
if (!pid || pid <= 0) return null;
|
|
@@ -292733,7 +292888,7 @@ function getDaemonPid() {
|
|
|
292733
292888
|
}
|
|
292734
292889
|
}
|
|
292735
292890
|
async function startDaemon() {
|
|
292736
|
-
|
|
292891
|
+
mkdirSync33(OA_DIR2, { recursive: true });
|
|
292737
292892
|
const nodeExe = process.execPath;
|
|
292738
292893
|
let oaScript = process.argv[1];
|
|
292739
292894
|
if (!oaScript) {
|
|
@@ -292746,8 +292901,8 @@ async function startDaemon() {
|
|
|
292746
292901
|
}
|
|
292747
292902
|
if (!oaScript) {
|
|
292748
292903
|
const thisDir = dirname22(fileURLToPath14(import.meta.url));
|
|
292749
|
-
const indexJs =
|
|
292750
|
-
if (
|
|
292904
|
+
const indexJs = join77(thisDir, "index.js");
|
|
292905
|
+
if (existsSync61(indexJs)) oaScript = indexJs;
|
|
292751
292906
|
}
|
|
292752
292907
|
if (!oaScript) return null;
|
|
292753
292908
|
try {
|
|
@@ -292763,7 +292918,7 @@ async function startDaemon() {
|
|
|
292763
292918
|
child.unref();
|
|
292764
292919
|
const pid = child.pid ?? null;
|
|
292765
292920
|
if (pid) {
|
|
292766
|
-
|
|
292921
|
+
writeFileSync31(PID_FILE2, String(pid), "utf8");
|
|
292767
292922
|
}
|
|
292768
292923
|
return pid;
|
|
292769
292924
|
} catch {
|
|
@@ -292845,8 +293000,8 @@ var OA_DIR2, PID_FILE2, DEFAULT_PORT2;
|
|
|
292845
293000
|
var init_daemon = __esm({
|
|
292846
293001
|
"packages/cli/src/daemon.ts"() {
|
|
292847
293002
|
"use strict";
|
|
292848
|
-
OA_DIR2 =
|
|
292849
|
-
PID_FILE2 =
|
|
293003
|
+
OA_DIR2 = join77(homedir29(), ".open-agents");
|
|
293004
|
+
PID_FILE2 = join77(OA_DIR2, "daemon.pid");
|
|
292850
293005
|
DEFAULT_PORT2 = 11435;
|
|
292851
293006
|
}
|
|
292852
293007
|
});
|
|
@@ -293231,8 +293386,8 @@ __export(sponsor_wizard_exports, {
|
|
|
293231
293386
|
saveSponsorConfig: () => saveSponsorConfig,
|
|
293232
293387
|
showSponsorDashboard: () => showSponsorDashboard
|
|
293233
293388
|
});
|
|
293234
|
-
import { existsSync as
|
|
293235
|
-
import { join as
|
|
293389
|
+
import { existsSync as existsSync62, readFileSync as readFileSync47, writeFileSync as writeFileSync32, mkdirSync as mkdirSync34 } from "node:fs";
|
|
293390
|
+
import { join as join78 } from "node:path";
|
|
293236
293391
|
function colorPreview(code8) {
|
|
293237
293392
|
return `\x1B[38;5;${code8}m████\x1B[0m (${code8})`;
|
|
293238
293393
|
}
|
|
@@ -293245,14 +293400,14 @@ function gradientPreview(start2, end) {
|
|
|
293245
293400
|
return s2;
|
|
293246
293401
|
}
|
|
293247
293402
|
function sponsorDir(projectDir) {
|
|
293248
|
-
return
|
|
293403
|
+
return join78(projectDir, ".oa", "sponsor");
|
|
293249
293404
|
}
|
|
293250
293405
|
function configPath(projectDir) {
|
|
293251
|
-
return
|
|
293406
|
+
return join78(sponsorDir(projectDir), "config.json");
|
|
293252
293407
|
}
|
|
293253
293408
|
function loadSponsorConfig(projectDir) {
|
|
293254
293409
|
const p2 = configPath(projectDir);
|
|
293255
|
-
if (!
|
|
293410
|
+
if (!existsSync62(p2)) return null;
|
|
293256
293411
|
try {
|
|
293257
293412
|
return JSON.parse(readFileSync47(p2, "utf8"));
|
|
293258
293413
|
} catch {
|
|
@@ -293261,9 +293416,9 @@ function loadSponsorConfig(projectDir) {
|
|
|
293261
293416
|
}
|
|
293262
293417
|
function saveSponsorConfig(projectDir, config) {
|
|
293263
293418
|
const dir = sponsorDir(projectDir);
|
|
293264
|
-
|
|
293419
|
+
mkdirSync34(dir, { recursive: true });
|
|
293265
293420
|
config.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
293266
|
-
|
|
293421
|
+
writeFileSync32(configPath(projectDir), JSON.stringify(config, null, 2), "utf8");
|
|
293267
293422
|
}
|
|
293268
293423
|
function defaultConfig2() {
|
|
293269
293424
|
return {
|
|
@@ -294143,9 +294298,9 @@ __export(voice_exports, {
|
|
|
294143
294298
|
registerCustomOnnxModel: () => registerCustomOnnxModel,
|
|
294144
294299
|
resetNarrationContext: () => resetNarrationContext
|
|
294145
294300
|
});
|
|
294146
|
-
import { existsSync as
|
|
294147
|
-
import { join as
|
|
294148
|
-
import { homedir as
|
|
294301
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync35, writeFileSync as writeFileSync33, readFileSync as readFileSync48, unlinkSync as unlinkSync17, readdirSync as readdirSync15, statSync as statSync17 } from "node:fs";
|
|
294302
|
+
import { join as join79, dirname as dirname23 } from "node:path";
|
|
294303
|
+
import { homedir as homedir30, tmpdir as tmpdir19, platform as platform4 } from "node:os";
|
|
294149
294304
|
import { execSync as execSync49, spawn as nodeSpawn } from "node:child_process";
|
|
294150
294305
|
import { createRequire as createRequire3 } from "node:module";
|
|
294151
294306
|
function sanitizeForTTS(text) {
|
|
@@ -294169,39 +294324,39 @@ function listVoiceModels() {
|
|
|
294169
294324
|
}));
|
|
294170
294325
|
}
|
|
294171
294326
|
function voiceDir() {
|
|
294172
|
-
return
|
|
294327
|
+
return join79(homedir30(), ".open-agents", "voice");
|
|
294173
294328
|
}
|
|
294174
294329
|
function modelsDir() {
|
|
294175
|
-
return
|
|
294330
|
+
return join79(voiceDir(), "models");
|
|
294176
294331
|
}
|
|
294177
294332
|
function modelDir(id) {
|
|
294178
|
-
return
|
|
294333
|
+
return join79(modelsDir(), id);
|
|
294179
294334
|
}
|
|
294180
294335
|
function modelOnnxPath(id) {
|
|
294181
|
-
return
|
|
294336
|
+
return join79(modelDir(id), "model.onnx");
|
|
294182
294337
|
}
|
|
294183
294338
|
function modelConfigPath(id) {
|
|
294184
|
-
return
|
|
294339
|
+
return join79(modelDir(id), "config.json");
|
|
294185
294340
|
}
|
|
294186
294341
|
function luxttsVenvDir() {
|
|
294187
|
-
return
|
|
294342
|
+
return join79(voiceDir(), "luxtts-venv");
|
|
294188
294343
|
}
|
|
294189
294344
|
function luxttsVenvPy() {
|
|
294190
|
-
return platform4() === "win32" ?
|
|
294345
|
+
return platform4() === "win32" ? join79(luxttsVenvDir(), "Scripts", "python.exe") : join79(luxttsVenvDir(), "bin", "python3");
|
|
294191
294346
|
}
|
|
294192
294347
|
function luxttsRepoDir() {
|
|
294193
|
-
return
|
|
294348
|
+
return join79(voiceDir(), "LuxTTS");
|
|
294194
294349
|
}
|
|
294195
294350
|
function luxttsCloneRefsDir() {
|
|
294196
|
-
return
|
|
294351
|
+
return join79(voiceDir(), "clone-refs");
|
|
294197
294352
|
}
|
|
294198
294353
|
function luxttsInferScript() {
|
|
294199
|
-
return
|
|
294354
|
+
return join79(voiceDir(), "luxtts-infer.py");
|
|
294200
294355
|
}
|
|
294201
294356
|
function writeDetectTorchScript(targetPath) {
|
|
294202
|
-
if (
|
|
294357
|
+
if (existsSync63(targetPath)) return;
|
|
294203
294358
|
try {
|
|
294204
|
-
|
|
294359
|
+
mkdirSync35(dirname23(targetPath), { recursive: true });
|
|
294205
294360
|
} catch {
|
|
294206
294361
|
}
|
|
294207
294362
|
const script = `#!/usr/bin/env python3
|
|
@@ -294274,7 +294429,7 @@ def main():
|
|
|
294274
294429
|
if __name__ == "__main__": main()
|
|
294275
294430
|
`;
|
|
294276
294431
|
try {
|
|
294277
|
-
|
|
294432
|
+
writeFileSync33(targetPath, script, { mode: 493 });
|
|
294278
294433
|
} catch {
|
|
294279
294434
|
}
|
|
294280
294435
|
}
|
|
@@ -295027,8 +295182,8 @@ var init_voice = __esm({
|
|
|
295027
295182
|
const refsDir = luxttsCloneRefsDir();
|
|
295028
295183
|
const targets = ["glados", "overwatch"];
|
|
295029
295184
|
for (const modelId of targets) {
|
|
295030
|
-
const refFile =
|
|
295031
|
-
if (
|
|
295185
|
+
const refFile = join79(refsDir, `${modelId}-ref.wav`);
|
|
295186
|
+
if (existsSync63(refFile)) continue;
|
|
295032
295187
|
try {
|
|
295033
295188
|
await this.generateCloneRef(modelId);
|
|
295034
295189
|
const meta = this.loadCloneMeta();
|
|
@@ -295104,23 +295259,23 @@ var init_voice = __esm({
|
|
|
295104
295259
|
}
|
|
295105
295260
|
p2 = p2.replace(/\\ /g, " ");
|
|
295106
295261
|
if (p2.startsWith("~/") || p2 === "~") {
|
|
295107
|
-
p2 =
|
|
295262
|
+
p2 = join79(homedir30(), p2.slice(1));
|
|
295108
295263
|
}
|
|
295109
|
-
if (!
|
|
295264
|
+
if (!existsSync63(p2)) {
|
|
295110
295265
|
return `File not found: ${p2}
|
|
295111
295266
|
(original input: ${audioPath})`;
|
|
295112
295267
|
}
|
|
295113
295268
|
audioPath = p2;
|
|
295114
295269
|
const refsDir = luxttsCloneRefsDir();
|
|
295115
|
-
if (!
|
|
295270
|
+
if (!existsSync63(refsDir)) mkdirSync35(refsDir, { recursive: true });
|
|
295116
295271
|
const ext = audioPath.split(".").pop() || "wav";
|
|
295117
295272
|
const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
295118
295273
|
const ts = Date.now().toString(36);
|
|
295119
295274
|
const destFilename = `clone-${srcName}-${ts}.${ext}`;
|
|
295120
|
-
const destPath =
|
|
295275
|
+
const destPath = join79(refsDir, destFilename);
|
|
295121
295276
|
try {
|
|
295122
295277
|
const data = readFileSync48(audioPath);
|
|
295123
|
-
|
|
295278
|
+
writeFileSync33(destPath, data);
|
|
295124
295279
|
} catch (err) {
|
|
295125
295280
|
return `Failed to copy audio file: ${err instanceof Error ? err.message : String(err)}`;
|
|
295126
295281
|
}
|
|
@@ -295160,8 +295315,8 @@ var init_voice = __esm({
|
|
|
295160
295315
|
return `Failed to synthesize reference audio from ${source.label}.`;
|
|
295161
295316
|
}
|
|
295162
295317
|
const refsDir = luxttsCloneRefsDir();
|
|
295163
|
-
if (!
|
|
295164
|
-
const destPath =
|
|
295318
|
+
if (!existsSync63(refsDir)) mkdirSync35(refsDir, { recursive: true });
|
|
295319
|
+
const destPath = join79(refsDir, `${sourceModelId}-ref.wav`);
|
|
295165
295320
|
const sampleRate = this.config?.audio?.sample_rate ?? 22050;
|
|
295166
295321
|
this.writeWav(audioData, sampleRate, destPath);
|
|
295167
295322
|
this.luxttsCloneRef = destPath;
|
|
@@ -295177,11 +295332,11 @@ var init_voice = __esm({
|
|
|
295177
295332
|
// -------------------------------------------------------------------------
|
|
295178
295333
|
/** Metadata file for friendly names of clone refs */
|
|
295179
295334
|
static cloneMetaFile() {
|
|
295180
|
-
return
|
|
295335
|
+
return join79(luxttsCloneRefsDir(), "meta.json");
|
|
295181
295336
|
}
|
|
295182
295337
|
loadCloneMeta() {
|
|
295183
295338
|
const p2 = _VoiceEngine.cloneMetaFile();
|
|
295184
|
-
if (!
|
|
295339
|
+
if (!existsSync63(p2)) return {};
|
|
295185
295340
|
try {
|
|
295186
295341
|
return JSON.parse(readFileSync48(p2, "utf8"));
|
|
295187
295342
|
} catch {
|
|
@@ -295190,8 +295345,8 @@ var init_voice = __esm({
|
|
|
295190
295345
|
}
|
|
295191
295346
|
saveCloneMeta(meta) {
|
|
295192
295347
|
const dir = luxttsCloneRefsDir();
|
|
295193
|
-
if (!
|
|
295194
|
-
|
|
295348
|
+
if (!existsSync63(dir)) mkdirSync35(dir, { recursive: true });
|
|
295349
|
+
writeFileSync33(_VoiceEngine.cloneMetaFile(), JSON.stringify(meta, null, 2));
|
|
295195
295350
|
}
|
|
295196
295351
|
/** Audio file extensions recognized as clone references */
|
|
295197
295352
|
static AUDIO_EXTS = /* @__PURE__ */ new Set(["wav", "mp3", "ogg", "flac", "m4a", "opus", "aac"]);
|
|
@@ -295201,14 +295356,14 @@ var init_voice = __esm({
|
|
|
295201
295356
|
*/
|
|
295202
295357
|
listCloneRefs() {
|
|
295203
295358
|
const dir = luxttsCloneRefsDir();
|
|
295204
|
-
if (!
|
|
295359
|
+
if (!existsSync63(dir)) return [];
|
|
295205
295360
|
const meta = this.loadCloneMeta();
|
|
295206
295361
|
const files = readdirSync15(dir).filter((f2) => {
|
|
295207
295362
|
const ext = f2.split(".").pop()?.toLowerCase() ?? "";
|
|
295208
295363
|
return _VoiceEngine.AUDIO_EXTS.has(ext);
|
|
295209
295364
|
});
|
|
295210
295365
|
return files.map((f2) => {
|
|
295211
|
-
const p2 =
|
|
295366
|
+
const p2 = join79(dir, f2);
|
|
295212
295367
|
let size = 0;
|
|
295213
295368
|
try {
|
|
295214
295369
|
size = statSync17(p2).size;
|
|
@@ -295225,8 +295380,8 @@ var init_voice = __esm({
|
|
|
295225
295380
|
}
|
|
295226
295381
|
/** Delete a clone reference file by filename. Returns true if deleted. */
|
|
295227
295382
|
deleteCloneRef(filename) {
|
|
295228
|
-
const p2 =
|
|
295229
|
-
if (!
|
|
295383
|
+
const p2 = join79(luxttsCloneRefsDir(), filename);
|
|
295384
|
+
if (!existsSync63(p2)) return false;
|
|
295230
295385
|
try {
|
|
295231
295386
|
unlinkSync17(p2);
|
|
295232
295387
|
const meta = this.loadCloneMeta();
|
|
@@ -295249,8 +295404,8 @@ var init_voice = __esm({
|
|
|
295249
295404
|
}
|
|
295250
295405
|
/** Set the active clone reference by filename. */
|
|
295251
295406
|
setActiveCloneRef(filename) {
|
|
295252
|
-
const p2 =
|
|
295253
|
-
if (!
|
|
295407
|
+
const p2 = join79(luxttsCloneRefsDir(), filename);
|
|
295408
|
+
if (!existsSync63(p2)) return `File not found: ${filename}`;
|
|
295254
295409
|
this.luxttsCloneRef = p2;
|
|
295255
295410
|
return `Active clone voice set to: ${filename}`;
|
|
295256
295411
|
}
|
|
@@ -295609,7 +295764,7 @@ var init_voice = __esm({
|
|
|
295609
295764
|
}
|
|
295610
295765
|
this.onPCMOutput(Buffer.from(int16.buffer), sampleRate);
|
|
295611
295766
|
}
|
|
295612
|
-
const wavPath =
|
|
295767
|
+
const wavPath = join79(tmpdir19(), `oa-voice-${Date.now()}.wav`);
|
|
295613
295768
|
this.writeStereoWav(stereo.left, stereo.right, sampleRate, wavPath);
|
|
295614
295769
|
await this.playWav(wavPath);
|
|
295615
295770
|
try {
|
|
@@ -295739,7 +295894,7 @@ var init_voice = __esm({
|
|
|
295739
295894
|
buffer2.writeInt16LE(rSample < 0 ? rSample * 32768 : rSample * 32767, pos);
|
|
295740
295895
|
pos += 2;
|
|
295741
295896
|
}
|
|
295742
|
-
|
|
295897
|
+
writeFileSync33(path5, buffer2);
|
|
295743
295898
|
}
|
|
295744
295899
|
// -------------------------------------------------------------------------
|
|
295745
295900
|
// Phonemization
|
|
@@ -295813,7 +295968,7 @@ var init_voice = __esm({
|
|
|
295813
295968
|
return buffer2;
|
|
295814
295969
|
}
|
|
295815
295970
|
writeWav(samples, sampleRate, path5) {
|
|
295816
|
-
|
|
295971
|
+
writeFileSync33(path5, this.buildWavBuffer(samples, sampleRate));
|
|
295817
295972
|
}
|
|
295818
295973
|
// -------------------------------------------------------------------------
|
|
295819
295974
|
// Audio playback (system default speakers)
|
|
@@ -296005,7 +296160,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296005
296160
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
296006
296161
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
296007
296162
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
296008
|
-
const wavPath =
|
|
296163
|
+
const wavPath = join79(tmpdir19(), `oa-mlx-${Date.now()}.wav`);
|
|
296009
296164
|
const pyScript = [
|
|
296010
296165
|
"import sys, json",
|
|
296011
296166
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -296028,7 +296183,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296028
296183
|
return;
|
|
296029
296184
|
}
|
|
296030
296185
|
}
|
|
296031
|
-
if (!
|
|
296186
|
+
if (!existsSync63(wavPath)) return;
|
|
296032
296187
|
if (volume !== 1) {
|
|
296033
296188
|
try {
|
|
296034
296189
|
const wavData = readFileSync48(wavPath);
|
|
@@ -296043,7 +296198,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296043
296198
|
samples[i2] = Math.round(samples[i2] * volume);
|
|
296044
296199
|
}
|
|
296045
296200
|
const scaled = Buffer.concat([header, Buffer.from(samples.buffer, samples.byteOffset, samples.byteLength)]);
|
|
296046
|
-
|
|
296201
|
+
writeFileSync33(wavPath, scaled);
|
|
296047
296202
|
}
|
|
296048
296203
|
} catch {
|
|
296049
296204
|
}
|
|
@@ -296079,7 +296234,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296079
296234
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
296080
296235
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
296081
296236
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
296082
|
-
const wavPath =
|
|
296237
|
+
const wavPath = join79(tmpdir19(), `oa-mlx-buf-${Date.now()}.wav`);
|
|
296083
296238
|
const pyScript = [
|
|
296084
296239
|
"import sys, json",
|
|
296085
296240
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -296102,7 +296257,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296102
296257
|
return null;
|
|
296103
296258
|
}
|
|
296104
296259
|
}
|
|
296105
|
-
if (!
|
|
296260
|
+
if (!existsSync63(wavPath)) return null;
|
|
296106
296261
|
try {
|
|
296107
296262
|
const data = readFileSync48(wavPath);
|
|
296108
296263
|
unlinkSync17(wavPath);
|
|
@@ -296129,7 +296284,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296129
296284
|
}
|
|
296130
296285
|
const venvDir = luxttsVenvDir();
|
|
296131
296286
|
const venvPy = luxttsVenvPy();
|
|
296132
|
-
if (
|
|
296287
|
+
if (existsSync63(venvPy)) {
|
|
296133
296288
|
try {
|
|
296134
296289
|
const quotedPy = `"${venvPy}"`;
|
|
296135
296290
|
const repoPath = luxttsRepoDir().replace(/\\/g, "/");
|
|
@@ -296151,7 +296306,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296151
296306
|
if (torchCheck === "cpu") {
|
|
296152
296307
|
renderWarning2("GPU detected but PyTorch is CPU-only. Reinstalling with CUDA support in background...");
|
|
296153
296308
|
try {
|
|
296154
|
-
const detectScript =
|
|
296309
|
+
const detectScript = join79(voiceDir(), "detect-torch.py");
|
|
296155
296310
|
writeDetectTorchScript(detectScript);
|
|
296156
296311
|
let pipArgs = `torch torchaudio --index-url https://download.pytorch.org/whl/cu124`;
|
|
296157
296312
|
try {
|
|
@@ -296178,7 +296333,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296178
296333
|
}
|
|
296179
296334
|
}
|
|
296180
296335
|
renderInfo2("Setting up LuxTTS voice cloning (first-time setup, this takes several minutes)...");
|
|
296181
|
-
if (!
|
|
296336
|
+
if (!existsSync63(venvDir)) {
|
|
296182
296337
|
renderInfo2(" Creating Python virtual environment...");
|
|
296183
296338
|
try {
|
|
296184
296339
|
await this.asyncShell(`${py} -m venv ${JSON.stringify(venvDir)}`, 6e4);
|
|
@@ -296189,7 +296344,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296189
296344
|
}
|
|
296190
296345
|
}
|
|
296191
296346
|
{
|
|
296192
|
-
const detectScript =
|
|
296347
|
+
const detectScript = join79(voiceDir(), "detect-torch.py");
|
|
296193
296348
|
writeDetectTorchScript(detectScript);
|
|
296194
296349
|
let pipArgsStr = "torch torchaudio";
|
|
296195
296350
|
let torchDesc = "unknown platform";
|
|
@@ -296234,10 +296389,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296234
296389
|
}
|
|
296235
296390
|
}
|
|
296236
296391
|
const repoDir = luxttsRepoDir();
|
|
296237
|
-
if (!
|
|
296392
|
+
if (!existsSync63(join79(repoDir, "zipvoice", "luxvoice.py"))) {
|
|
296238
296393
|
renderInfo2(" Cloning LuxTTS repository...");
|
|
296239
296394
|
try {
|
|
296240
|
-
if (
|
|
296395
|
+
if (existsSync63(repoDir)) {
|
|
296241
296396
|
const rmCmd = process.platform === "win32" ? `rmdir /s /q ${JSON.stringify(repoDir)}` : `rm -rf ${JSON.stringify(repoDir)}`;
|
|
296242
296397
|
await this.asyncShell(rmCmd, 3e4);
|
|
296243
296398
|
}
|
|
@@ -296326,7 +296481,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296326
296481
|
renderWarning2(` Could not install system build deps: ${err instanceof Error ? err.message : String(err)}`);
|
|
296327
296482
|
}
|
|
296328
296483
|
}
|
|
296329
|
-
const isJetson = isArm && (
|
|
296484
|
+
const isJetson = isArm && (existsSync63("/etc/nv_tegra_release") || existsSync63("/usr/local/cuda/targets/aarch64-linux") || (process.env.JETSON_L4T_VERSION ?? "") !== "");
|
|
296330
296485
|
const installSteps = isArm ? [
|
|
296331
296486
|
// ARM: install individually so we get clear error messages per package.
|
|
296332
296487
|
// ALL are fatal because LuxTTS hard-imports them (no lazy/optional imports).
|
|
@@ -296339,7 +296494,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296339
296494
|
...isJetson ? (() => {
|
|
296340
296495
|
let jpVer = "v60";
|
|
296341
296496
|
try {
|
|
296342
|
-
const tegra =
|
|
296497
|
+
const tegra = existsSync63("/etc/nv_tegra_release") ? execSync49("cat /etc/nv_tegra_release 2>/dev/null", { encoding: "utf8", timeout: 3e3 }).trim() : "";
|
|
296343
296498
|
const dpkg = execSync49("dpkg -l nvidia-jetpack 2>/dev/null | grep nvidia-jetpack | awk '{print $3}'", { encoding: "utf8", timeout: 5e3 }).trim();
|
|
296344
296499
|
const ver = dpkg || process.env.JETSON_L4T_VERSION || "";
|
|
296345
296500
|
if (ver.startsWith("5.") || tegra.includes("R35") || tegra.includes("R34")) jpVer = "v51";
|
|
@@ -296419,12 +296574,12 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
|
296419
296574
|
}
|
|
296420
296575
|
/** Auto-detect an existing clone reference in the refs directory */
|
|
296421
296576
|
autoDetectCloneRef() {
|
|
296422
|
-
if (this.luxttsCloneRef &&
|
|
296577
|
+
if (this.luxttsCloneRef && existsSync63(this.luxttsCloneRef)) return;
|
|
296423
296578
|
const refsDir = luxttsCloneRefsDir();
|
|
296424
|
-
if (!
|
|
296579
|
+
if (!existsSync63(refsDir)) return;
|
|
296425
296580
|
for (const name11 of ["custom-clone.wav", "custom-clone.mp3", "glados-ref.wav", "overwatch-ref.wav"]) {
|
|
296426
|
-
const p2 =
|
|
296427
|
-
if (
|
|
296581
|
+
const p2 = join79(refsDir, name11);
|
|
296582
|
+
if (existsSync63(p2)) {
|
|
296428
296583
|
this.luxttsCloneRef = p2;
|
|
296429
296584
|
return;
|
|
296430
296585
|
}
|
|
@@ -296524,14 +296679,14 @@ if __name__ == '__main__':
|
|
|
296524
296679
|
main()
|
|
296525
296680
|
`;
|
|
296526
296681
|
const scriptPath2 = luxttsInferScript();
|
|
296527
|
-
|
|
296528
|
-
|
|
296682
|
+
mkdirSync35(voiceDir(), { recursive: true });
|
|
296683
|
+
writeFileSync33(scriptPath2, script);
|
|
296529
296684
|
}
|
|
296530
296685
|
/** Ensure the LuxTTS daemon is running, spawn if needed */
|
|
296531
296686
|
async ensureLuxttsDaemon() {
|
|
296532
296687
|
if (this._luxttsDaemon && !this._luxttsDaemon.killed) return true;
|
|
296533
296688
|
const venvPy = luxttsVenvPy();
|
|
296534
|
-
if (!
|
|
296689
|
+
if (!existsSync63(venvPy)) return false;
|
|
296535
296690
|
return new Promise((resolve40) => {
|
|
296536
296691
|
const env2 = { ...process.env, LUXTTS_REPO_PATH: luxttsRepoDir() };
|
|
296537
296692
|
const daemon = nodeSpawn(venvPy, [luxttsInferScript()], {
|
|
@@ -296620,12 +296775,12 @@ if __name__ == '__main__':
|
|
|
296620
296775
|
* Used by drainQueue's pre-fetch pipeline for gapless back-to-back playback.
|
|
296621
296776
|
*/
|
|
296622
296777
|
async synthesizeLuxttsWav(text, speedFactor = 1) {
|
|
296623
|
-
if (!this.luxttsCloneRef || !
|
|
296778
|
+
if (!this.luxttsCloneRef || !existsSync63(this.luxttsCloneRef)) return null;
|
|
296624
296779
|
const cleaned = text.replace(/\*/g, "").trim();
|
|
296625
296780
|
if (!cleaned) return null;
|
|
296626
296781
|
const ready = await this.ensureLuxttsDaemon();
|
|
296627
296782
|
if (!ready) return null;
|
|
296628
|
-
const wavPath =
|
|
296783
|
+
const wavPath = join79(tmpdir19(), `oa-luxtts-${Date.now()}-${Math.random().toString(36).slice(2, 6)}.wav`);
|
|
296629
296784
|
try {
|
|
296630
296785
|
await this.luxttsRequest({
|
|
296631
296786
|
action: "synthesize",
|
|
@@ -296637,14 +296792,14 @@ if __name__ == '__main__':
|
|
|
296637
296792
|
} catch {
|
|
296638
296793
|
return null;
|
|
296639
296794
|
}
|
|
296640
|
-
return
|
|
296795
|
+
return existsSync63(wavPath) ? wavPath : null;
|
|
296641
296796
|
}
|
|
296642
296797
|
/**
|
|
296643
296798
|
* Post-process (fade-in, volume, pitch, stereo) and play a LuxTTS WAV file.
|
|
296644
296799
|
* Cleans up the WAV file after playback.
|
|
296645
296800
|
*/
|
|
296646
296801
|
async postProcessAndPlayLuxtts(wavPath, volume = 1, pitchFactor = 1, stereoDelayMs = 0.6) {
|
|
296647
|
-
if (!
|
|
296802
|
+
if (!existsSync63(wavPath)) return;
|
|
296648
296803
|
try {
|
|
296649
296804
|
const wavData = readFileSync48(wavPath);
|
|
296650
296805
|
if (wavData.length > 44) {
|
|
@@ -296665,7 +296820,7 @@ if __name__ == '__main__':
|
|
|
296665
296820
|
}
|
|
296666
296821
|
const header = wavData.subarray(0, 44);
|
|
296667
296822
|
const scaled = Buffer.concat([header, Buffer.from(samples.buffer, samples.byteOffset, samples.byteLength)]);
|
|
296668
|
-
|
|
296823
|
+
writeFileSync33(wavPath, scaled);
|
|
296669
296824
|
}
|
|
296670
296825
|
} catch {
|
|
296671
296826
|
}
|
|
@@ -296740,12 +296895,12 @@ if __name__ == '__main__':
|
|
|
296740
296895
|
* Used for Telegram voice messages and WebSocket streaming.
|
|
296741
296896
|
*/
|
|
296742
296897
|
async synthesizeLuxttsToBuffer(text) {
|
|
296743
|
-
if (!this.luxttsCloneRef || !
|
|
296898
|
+
if (!this.luxttsCloneRef || !existsSync63(this.luxttsCloneRef)) return null;
|
|
296744
296899
|
const cleaned = text.replace(/\*/g, "").trim();
|
|
296745
296900
|
if (!cleaned) return null;
|
|
296746
296901
|
const ready = await this.ensureLuxttsDaemon();
|
|
296747
296902
|
if (!ready) return null;
|
|
296748
|
-
const wavPath =
|
|
296903
|
+
const wavPath = join79(tmpdir19(), `oa-luxtts-buf-${Date.now()}.wav`);
|
|
296749
296904
|
try {
|
|
296750
296905
|
await this.luxttsRequest({
|
|
296751
296906
|
action: "synthesize",
|
|
@@ -296757,7 +296912,7 @@ if __name__ == '__main__':
|
|
|
296757
296912
|
} catch {
|
|
296758
296913
|
return null;
|
|
296759
296914
|
}
|
|
296760
|
-
if (!
|
|
296915
|
+
if (!existsSync63(wavPath)) return null;
|
|
296761
296916
|
try {
|
|
296762
296917
|
const data = readFileSync48(wavPath);
|
|
296763
296918
|
unlinkSync17(wavPath);
|
|
@@ -296772,34 +296927,34 @@ if __name__ == '__main__':
|
|
|
296772
296927
|
async ensureRuntime() {
|
|
296773
296928
|
if (this.ort) return;
|
|
296774
296929
|
const arch2 = process.arch;
|
|
296775
|
-
|
|
296776
|
-
const pkgPath =
|
|
296930
|
+
mkdirSync35(voiceDir(), { recursive: true });
|
|
296931
|
+
const pkgPath = join79(voiceDir(), "package.json");
|
|
296777
296932
|
const expectedDeps = {
|
|
296778
296933
|
"onnxruntime-node": "^1.21.0",
|
|
296779
296934
|
"phonemizer": "^1.2.1"
|
|
296780
296935
|
};
|
|
296781
|
-
if (
|
|
296936
|
+
if (existsSync63(pkgPath)) {
|
|
296782
296937
|
try {
|
|
296783
296938
|
const existing = JSON.parse(readFileSync48(pkgPath, "utf8"));
|
|
296784
296939
|
if (!existing.dependencies?.["phonemizer"]) {
|
|
296785
296940
|
existing.dependencies = { ...existing.dependencies, ...expectedDeps };
|
|
296786
|
-
|
|
296941
|
+
writeFileSync33(pkgPath, JSON.stringify(existing, null, 2));
|
|
296787
296942
|
}
|
|
296788
296943
|
} catch {
|
|
296789
296944
|
}
|
|
296790
296945
|
}
|
|
296791
|
-
if (!
|
|
296792
|
-
|
|
296946
|
+
if (!existsSync63(pkgPath)) {
|
|
296947
|
+
writeFileSync33(pkgPath, JSON.stringify({
|
|
296793
296948
|
name: "open-agents-voice",
|
|
296794
296949
|
private: true,
|
|
296795
296950
|
dependencies: expectedDeps
|
|
296796
296951
|
}, null, 2));
|
|
296797
296952
|
}
|
|
296798
|
-
const voiceRequire = createRequire3(
|
|
296953
|
+
const voiceRequire = createRequire3(join79(voiceDir(), "index.js"));
|
|
296799
296954
|
const probeOnnx = async () => {
|
|
296800
296955
|
try {
|
|
296801
296956
|
const output = await this.asyncShell(
|
|
296802
|
-
`NODE_PATH="${
|
|
296957
|
+
`NODE_PATH="${join79(voiceDir(), "node_modules")}" node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`,
|
|
296803
296958
|
15e3
|
|
296804
296959
|
);
|
|
296805
296960
|
return output.trim() === "OK";
|
|
@@ -296807,8 +296962,8 @@ if __name__ == '__main__':
|
|
|
296807
296962
|
return false;
|
|
296808
296963
|
}
|
|
296809
296964
|
};
|
|
296810
|
-
const onnxNodeModules =
|
|
296811
|
-
const onnxInstalled =
|
|
296965
|
+
const onnxNodeModules = join79(voiceDir(), "node_modules", "onnxruntime-node");
|
|
296966
|
+
const onnxInstalled = existsSync63(onnxNodeModules);
|
|
296812
296967
|
if (onnxInstalled && !await probeOnnx()) {
|
|
296813
296968
|
throw new Error(
|
|
296814
296969
|
`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${arch2}). This is a known issue with some ARM SoCs where the CPU vendor is not recognized. Voice feedback will be disabled but all other features work normally.`
|
|
@@ -296867,16 +297022,16 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
296867
297022
|
const dir = modelDir(id);
|
|
296868
297023
|
const onnxPath = modelOnnxPath(id);
|
|
296869
297024
|
const configPath2 = modelConfigPath(id);
|
|
296870
|
-
if (
|
|
296871
|
-
|
|
296872
|
-
if (!
|
|
297025
|
+
if (existsSync63(onnxPath) && existsSync63(configPath2)) return;
|
|
297026
|
+
mkdirSync35(dir, { recursive: true });
|
|
297027
|
+
if (!existsSync63(configPath2)) {
|
|
296873
297028
|
renderInfo2(`Downloading ${model.label} voice config...`);
|
|
296874
297029
|
const configResp = await fetch(model.configUrl);
|
|
296875
297030
|
if (!configResp.ok) throw new Error(`Failed to download config: HTTP ${configResp.status}`);
|
|
296876
297031
|
const configText = await configResp.text();
|
|
296877
|
-
|
|
297032
|
+
writeFileSync33(configPath2, configText);
|
|
296878
297033
|
}
|
|
296879
|
-
if (!
|
|
297034
|
+
if (!existsSync63(onnxPath)) {
|
|
296880
297035
|
renderInfo2(`Downloading ${model.label} voice model (this may take a minute)...`);
|
|
296881
297036
|
const onnxResp = await fetch(model.onnxUrl);
|
|
296882
297037
|
if (!onnxResp.ok) throw new Error(`Failed to download model: HTTP ${onnxResp.status}`);
|
|
@@ -296898,7 +297053,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
296898
297053
|
}
|
|
296899
297054
|
}
|
|
296900
297055
|
const fullBuffer = Buffer.concat(chunks);
|
|
296901
|
-
|
|
297056
|
+
writeFileSync33(onnxPath, fullBuffer);
|
|
296902
297057
|
renderInfo2(`${model.label} model downloaded (${formatBytes2(fullBuffer.length)}).`);
|
|
296903
297058
|
}
|
|
296904
297059
|
}
|
|
@@ -296909,7 +297064,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
296909
297064
|
if (!this.ort) throw new Error("ONNX runtime not loaded");
|
|
296910
297065
|
const onnxPath = modelOnnxPath(this.modelId);
|
|
296911
297066
|
const configPath2 = modelConfigPath(this.modelId);
|
|
296912
|
-
if (!
|
|
297067
|
+
if (!existsSync63(onnxPath) || !existsSync63(configPath2)) {
|
|
296913
297068
|
throw new Error(`Model files not found for ${this.modelId}`);
|
|
296914
297069
|
}
|
|
296915
297070
|
this.config = JSON.parse(readFileSync48(configPath2, "utf8"));
|
|
@@ -296946,8 +297101,8 @@ __export(commands_exports, {
|
|
|
296946
297101
|
});
|
|
296947
297102
|
import * as nodeOs from "node:os";
|
|
296948
297103
|
import { execSync as nodeExecSync } from "node:child_process";
|
|
296949
|
-
import { existsSync as
|
|
296950
|
-
import { join as
|
|
297104
|
+
import { existsSync as existsSync64, readFileSync as readFileSync49, writeFileSync as writeFileSync34, mkdirSync as mkdirSync36, readdirSync as readdirSync16, statSync as statSync18, rmSync as rmSync2, appendFileSync as appendFileSync3 } from "node:fs";
|
|
297105
|
+
import { join as join80 } from "node:path";
|
|
296951
297106
|
async function _immediateReregister(newUrl) {
|
|
296952
297107
|
if (!_lastRegisteredSponsorPayload) return;
|
|
296953
297108
|
_lastRegisteredSponsorPayload.tunnelUrl = newUrl;
|
|
@@ -297813,8 +297968,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
297813
297968
|
if (out.includes("Connected") || out.includes("Already connected")) {
|
|
297814
297969
|
renderInfo2(out.split("\n").slice(0, 4).join("\n"));
|
|
297815
297970
|
try {
|
|
297816
|
-
const pidFile =
|
|
297817
|
-
if (
|
|
297971
|
+
const pidFile = join80(ctx3.repoRoot ?? process.cwd(), ".oa", "nexus", "daemon.pid");
|
|
297972
|
+
if (existsSync64(pidFile)) {
|
|
297818
297973
|
const pid = parseInt(readFileSync49(pidFile, "utf8").trim(), 10);
|
|
297819
297974
|
if (pid > 0 && !registry2.daemons.has("Nexus")) {
|
|
297820
297975
|
registry2.register({ name: "Nexus", pid, startedAt: Date.now(), status: "running" });
|
|
@@ -298119,18 +298274,18 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298119
298274
|
let content = "";
|
|
298120
298275
|
let metadata = {};
|
|
298121
298276
|
if (shareType === "tool") {
|
|
298122
|
-
const toolDir =
|
|
298123
|
-
const toolFile =
|
|
298124
|
-
if (!
|
|
298277
|
+
const toolDir = join80(ctx3.repoRoot, ".oa", "tools");
|
|
298278
|
+
const toolFile = join80(toolDir, shareName.endsWith(".json") ? shareName : `${shareName}.json`);
|
|
298279
|
+
if (!existsSync64(toolFile)) {
|
|
298125
298280
|
renderWarning2(`Tool not found: ${toolFile}`);
|
|
298126
298281
|
return "handled";
|
|
298127
298282
|
}
|
|
298128
298283
|
content = readFileSync49(toolFile, "utf8");
|
|
298129
298284
|
metadata = { type: "tool", name: shareName };
|
|
298130
298285
|
} else if (shareType === "skill") {
|
|
298131
|
-
const skillDir =
|
|
298132
|
-
const skillFile =
|
|
298133
|
-
if (!
|
|
298286
|
+
const skillDir = join80(ctx3.repoRoot, ".oa", "skills", shareName);
|
|
298287
|
+
const skillFile = join80(skillDir, "SKILL.md");
|
|
298288
|
+
if (!existsSync64(skillFile)) {
|
|
298134
298289
|
renderWarning2(`Skill not found: ${skillFile}`);
|
|
298135
298290
|
return "handled";
|
|
298136
298291
|
}
|
|
@@ -298171,8 +298326,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298171
298326
|
try {
|
|
298172
298327
|
const nexus = new NexusTool(ctx3.repoRoot);
|
|
298173
298328
|
await nexus.execute({ action: "ipfs_pin", cid: importCid, source: "import" });
|
|
298174
|
-
const regFile =
|
|
298175
|
-
if (
|
|
298329
|
+
const regFile = join80(ctx3.repoRoot, ".oa", "nexus", "ipfs", "cid-registry", "learning-cids.json");
|
|
298330
|
+
if (existsSync64(regFile)) {
|
|
298176
298331
|
const reg2 = JSON.parse(readFileSync49(regFile, "utf8"));
|
|
298177
298332
|
const pinned = Object.values(reg2).some((e2) => e2.cid === importCid && e2.pinned);
|
|
298178
298333
|
if (pinned) {
|
|
@@ -298224,32 +298379,32 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298224
298379
|
lines.push(`
|
|
298225
298380
|
${c3.bold("IPFS / Helia Status")}
|
|
298226
298381
|
`);
|
|
298227
|
-
const ipfsDir =
|
|
298228
|
-
const ipfsLocalDir =
|
|
298382
|
+
const ipfsDir = join80(ctx3.repoRoot, ".oa", "ipfs");
|
|
298383
|
+
const ipfsLocalDir = join80(ipfsDir, "local");
|
|
298229
298384
|
let ipfsFiles = 0;
|
|
298230
298385
|
let ipfsBytes = 0;
|
|
298231
298386
|
let heliaBlocks = 0;
|
|
298232
298387
|
let heliaBytes = 0;
|
|
298233
298388
|
try {
|
|
298234
|
-
if (
|
|
298389
|
+
if (existsSync64(ipfsLocalDir)) {
|
|
298235
298390
|
const files = readdirSync16(ipfsLocalDir).filter((f2) => f2.endsWith(".json"));
|
|
298236
298391
|
ipfsFiles = files.length;
|
|
298237
298392
|
for (const f2 of files) {
|
|
298238
298393
|
try {
|
|
298239
|
-
ipfsBytes += statSync18(
|
|
298394
|
+
ipfsBytes += statSync18(join80(ipfsLocalDir, f2)).size;
|
|
298240
298395
|
} catch {
|
|
298241
298396
|
}
|
|
298242
298397
|
}
|
|
298243
298398
|
}
|
|
298244
|
-
const heliaBlockDir =
|
|
298245
|
-
if (
|
|
298399
|
+
const heliaBlockDir = join80(ipfsDir, "blocks");
|
|
298400
|
+
if (existsSync64(heliaBlockDir)) {
|
|
298246
298401
|
const walkDir = (dir) => {
|
|
298247
298402
|
for (const entry of readdirSync16(dir, { withFileTypes: true })) {
|
|
298248
|
-
if (entry.isDirectory()) walkDir(
|
|
298403
|
+
if (entry.isDirectory()) walkDir(join80(dir, entry.name));
|
|
298249
298404
|
else {
|
|
298250
298405
|
heliaBlocks++;
|
|
298251
298406
|
try {
|
|
298252
|
-
heliaBytes += statSync18(
|
|
298407
|
+
heliaBytes += statSync18(join80(dir, entry.name)).size;
|
|
298253
298408
|
} catch {
|
|
298254
298409
|
}
|
|
298255
298410
|
}
|
|
@@ -298265,8 +298420,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298265
298420
|
lines.push(` Blocks: ${c3.bold(String(heliaBlocks))} Size: ${c3.bold(formatFileSize(heliaBytes))}`);
|
|
298266
298421
|
lines.push(` Backend: ${heliaBlocks > 0 ? c3.green("helia-ipfs") : c3.yellow("sha256-local (Helia not initialized)")}`);
|
|
298267
298422
|
try {
|
|
298268
|
-
const statusFile =
|
|
298269
|
-
if (
|
|
298423
|
+
const statusFile = join80(ctx3.repoRoot, ".oa", "nexus", "status.json");
|
|
298424
|
+
if (existsSync64(statusFile)) {
|
|
298270
298425
|
const status = JSON.parse(readFileSync49(statusFile, "utf8"));
|
|
298271
298426
|
if (status.peerId) {
|
|
298272
298427
|
lines.push(`
|
|
@@ -298286,10 +298441,10 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298286
298441
|
${c3.dim("Commands: /ipfs pin <CID> /ipfs publish /ipfs cids")}`);
|
|
298287
298442
|
lines.push(`
|
|
298288
298443
|
${c3.bold("Identity Kernel")}`);
|
|
298289
|
-
const idDir =
|
|
298444
|
+
const idDir = join80(ctx3.repoRoot, ".oa", "identity");
|
|
298290
298445
|
try {
|
|
298291
|
-
const stateFile =
|
|
298292
|
-
if (
|
|
298446
|
+
const stateFile = join80(idDir, "self-state.json");
|
|
298447
|
+
if (existsSync64(stateFile)) {
|
|
298293
298448
|
const state = JSON.parse(readFileSync49(stateFile, "utf8"));
|
|
298294
298449
|
lines.push(` Version: ${c3.bold("v" + (state.version ?? "?"))} Sessions: ${c3.bold(String(state.session_count ?? 0))}`);
|
|
298295
298450
|
if (state.narrative_summary) {
|
|
@@ -298299,8 +298454,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298299
298454
|
const traits = typeof state.personality_traits === "object" ? Object.entries(state.personality_traits).map(([k, v]) => `${k}:${v}`).join(", ") : String(state.personality_traits);
|
|
298300
298455
|
lines.push(` Traits: ${c3.dim(traits.slice(0, 60))}`);
|
|
298301
298456
|
}
|
|
298302
|
-
const cidFile =
|
|
298303
|
-
if (
|
|
298457
|
+
const cidFile = join80(idDir, "cids.json");
|
|
298458
|
+
if (existsSync64(cidFile)) {
|
|
298304
298459
|
const cids = JSON.parse(readFileSync49(cidFile, "utf8"));
|
|
298305
298460
|
const lastCid = Array.isArray(cids) ? cids[cids.length - 1] : cids.latest;
|
|
298306
298461
|
if (lastCid) lines.push(` Last CID: ${c3.dim(String(lastCid).slice(0, 50))}`);
|
|
@@ -298313,8 +298468,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298313
298468
|
lines.push(`
|
|
298314
298469
|
${c3.bold("Memory Sentiment")}`);
|
|
298315
298470
|
try {
|
|
298316
|
-
const metaFile =
|
|
298317
|
-
if (
|
|
298471
|
+
const metaFile = join80(ctx3.repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
298472
|
+
if (existsSync64(metaFile)) {
|
|
298318
298473
|
const store2 = JSON.parse(readFileSync49(metaFile, "utf8"));
|
|
298319
298474
|
const active = store2.filter((m2) => m2.type !== "quarantine");
|
|
298320
298475
|
const recoveries = active.filter((m2) => m2.content?.startsWith("[recovery]")).length;
|
|
@@ -298333,8 +298488,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298333
298488
|
} catch {
|
|
298334
298489
|
}
|
|
298335
298490
|
try {
|
|
298336
|
-
const dbPath =
|
|
298337
|
-
if (
|
|
298491
|
+
const dbPath = join80(ctx3.repoRoot, ".oa", "memory", "structured.db");
|
|
298492
|
+
if (existsSync64(dbPath)) {
|
|
298338
298493
|
const { initDb: initDb2, closeDb: cDb, ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
298339
298494
|
const db = initDb2(dbPath);
|
|
298340
298495
|
const memStore = new ProceduralMemoryStore2(db);
|
|
@@ -298355,8 +298510,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298355
298510
|
lines.push(`
|
|
298356
298511
|
${c3.bold("Storage Overview")}
|
|
298357
298512
|
`);
|
|
298358
|
-
const oaDir =
|
|
298359
|
-
if (!
|
|
298513
|
+
const oaDir = join80(ctx3.repoRoot, ".oa");
|
|
298514
|
+
if (!existsSync64(oaDir)) {
|
|
298360
298515
|
lines.push(` ${c3.dim("No .oa/ directory found.")}`);
|
|
298361
298516
|
safeLog(lines.join("\n") + "\n");
|
|
298362
298517
|
return "handled";
|
|
@@ -298366,7 +298521,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298366
298521
|
const walkStorage = (dir, category) => {
|
|
298367
298522
|
try {
|
|
298368
298523
|
for (const entry of readdirSync16(dir, { withFileTypes: true })) {
|
|
298369
|
-
const full =
|
|
298524
|
+
const full = join80(dir, entry.name);
|
|
298370
298525
|
if (entry.isDirectory()) {
|
|
298371
298526
|
const subCat = category || entry.name;
|
|
298372
298527
|
walkStorage(full, subCat);
|
|
@@ -298401,9 +298556,9 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298401
298556
|
for (const entry of readdirSync16(dir, { withFileTypes: true })) {
|
|
298402
298557
|
const name11 = entry.name.toLowerCase();
|
|
298403
298558
|
if (sensitivePatterns.some((p2) => name11.includes(p2))) {
|
|
298404
|
-
sensitiveFound.push(
|
|
298559
|
+
sensitiveFound.push(join80(dir, entry.name).replace(oaDir + "/", ""));
|
|
298405
298560
|
}
|
|
298406
|
-
if (entry.isDirectory()) checkSensitive(
|
|
298561
|
+
if (entry.isDirectory()) checkSensitive(join80(dir, entry.name));
|
|
298407
298562
|
}
|
|
298408
298563
|
} catch {
|
|
298409
298564
|
}
|
|
@@ -298431,8 +298586,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298431
298586
|
renderInfo2("Supported: .wav .mp3 .flac .ogg (audio→transcribe) | .pdf .txt .md (text→chunk)");
|
|
298432
298587
|
return "handled";
|
|
298433
298588
|
}
|
|
298434
|
-
const resolvedPath =
|
|
298435
|
-
if (!
|
|
298589
|
+
const resolvedPath = join80(ctx3.repoRoot, filePath);
|
|
298590
|
+
if (!existsSync64(resolvedPath)) {
|
|
298436
298591
|
renderWarning2(`File not found: ${resolvedPath}`);
|
|
298437
298592
|
return "handled";
|
|
298438
298593
|
}
|
|
@@ -298448,9 +298603,9 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298448
298603
|
}
|
|
298449
298604
|
try {
|
|
298450
298605
|
const { initDb: initDb2, closeDb: cDb, ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
298451
|
-
const dbDir =
|
|
298452
|
-
|
|
298453
|
-
const db = initDb2(
|
|
298606
|
+
const dbDir = join80(ctx3.repoRoot, ".oa", "memory");
|
|
298607
|
+
mkdirSync36(dbDir, { recursive: true });
|
|
298608
|
+
const db = initDb2(join80(dbDir, "structured.db"));
|
|
298454
298609
|
const memStore = new ProceduralMemoryStore2(db);
|
|
298455
298610
|
if (isAudio) {
|
|
298456
298611
|
renderInfo2(`Transcribing: ${filePath}...`);
|
|
@@ -298532,9 +298687,9 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298532
298687
|
}
|
|
298533
298688
|
case "fortemi": {
|
|
298534
298689
|
const fortemiSubCmd = (arg || "").trim().toLowerCase();
|
|
298535
|
-
const fortemiDir =
|
|
298536
|
-
const altFortemiDir =
|
|
298537
|
-
const fDir =
|
|
298690
|
+
const fortemiDir = join80(ctx3.repoRoot, "..", "fortemi-react");
|
|
298691
|
+
const altFortemiDir = join80(nodeOs.homedir(), "fortemi-react");
|
|
298692
|
+
const fDir = existsSync64(fortemiDir) ? fortemiDir : existsSync64(altFortemiDir) ? altFortemiDir : null;
|
|
298538
298693
|
if (fortemiSubCmd === "start" || fortemiSubCmd === "") {
|
|
298539
298694
|
if (!fDir) {
|
|
298540
298695
|
renderWarning2("fortemi-react not found adjacent or in home directory.");
|
|
@@ -298549,14 +298704,14 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298549
298704
|
// 24h
|
|
298550
298705
|
nonce: Math.random().toString(36).slice(2, 10)
|
|
298551
298706
|
};
|
|
298552
|
-
const jwtFile =
|
|
298553
|
-
|
|
298554
|
-
|
|
298707
|
+
const jwtFile = join80(ctx3.repoRoot, ".oa", "fortemi-jwt.json");
|
|
298708
|
+
mkdirSync36(join80(ctx3.repoRoot, ".oa"), { recursive: true });
|
|
298709
|
+
writeFileSync34(jwtFile, JSON.stringify(jwtPayload, null, 2));
|
|
298555
298710
|
renderInfo2(`Launching fortemi-react from ${fDir}...`);
|
|
298556
298711
|
try {
|
|
298557
298712
|
const { spawn: spawn27 } = __require("node:child_process");
|
|
298558
298713
|
const child = spawn27("npx", ["vite", "dev", "--host", "0.0.0.0", "--port", "3000"], {
|
|
298559
|
-
cwd:
|
|
298714
|
+
cwd: join80(fDir, "apps", "standalone"),
|
|
298560
298715
|
stdio: "ignore",
|
|
298561
298716
|
detached: true,
|
|
298562
298717
|
env: { ...process.env, OA_JWT: JSON.stringify(jwtPayload) }
|
|
@@ -298565,8 +298720,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298565
298720
|
renderInfo2("Fortemi-React starting on http://localhost:3000");
|
|
298566
298721
|
renderInfo2(`JWT saved to ${jwtFile}`);
|
|
298567
298722
|
renderInfo2("Memory operations will proxy to fortemi when available.");
|
|
298568
|
-
const bridgeFile =
|
|
298569
|
-
|
|
298723
|
+
const bridgeFile = join80(ctx3.repoRoot, ".oa", "fortemi-bridge.json");
|
|
298724
|
+
writeFileSync34(bridgeFile, JSON.stringify({
|
|
298570
298725
|
url: "http://localhost:3000",
|
|
298571
298726
|
pid: child.pid,
|
|
298572
298727
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -298578,8 +298733,8 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298578
298733
|
return "handled";
|
|
298579
298734
|
}
|
|
298580
298735
|
if (fortemiSubCmd === "status") {
|
|
298581
|
-
const bridgeFile =
|
|
298582
|
-
if (!
|
|
298736
|
+
const bridgeFile = join80(ctx3.repoRoot, ".oa", "fortemi-bridge.json");
|
|
298737
|
+
if (!existsSync64(bridgeFile)) {
|
|
298583
298738
|
renderInfo2("Fortemi bridge: not connected. Run /fortemi start");
|
|
298584
298739
|
return "handled";
|
|
298585
298740
|
}
|
|
@@ -298603,14 +298758,14 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
298603
298758
|
lines.push(` Process: ${alive ? c3.green("running") : c3.yellow("not running")} (PID ${bridge.pid})`);
|
|
298604
298759
|
lines.push(` HTTP: ${httpOk ? c3.green("connected") : c3.yellow("unreachable")}`);
|
|
298605
298760
|
lines.push(` Started: ${bridge.startedAt}`);
|
|
298606
|
-
lines.push(` JWT: ${
|
|
298761
|
+
lines.push(` JWT: ${existsSync64(bridge.jwtFile) ? c3.green("valid") : c3.yellow("missing")}`);
|
|
298607
298762
|
lines.push("");
|
|
298608
298763
|
safeLog(lines.join("\n"));
|
|
298609
298764
|
return "handled";
|
|
298610
298765
|
}
|
|
298611
298766
|
if (fortemiSubCmd === "stop") {
|
|
298612
|
-
const bridgeFile =
|
|
298613
|
-
if (
|
|
298767
|
+
const bridgeFile = join80(ctx3.repoRoot, ".oa", "fortemi-bridge.json");
|
|
298768
|
+
if (existsSync64(bridgeFile)) {
|
|
298614
298769
|
const bridge = JSON.parse(readFileSync49(bridgeFile, "utf8"));
|
|
298615
298770
|
try {
|
|
298616
298771
|
process.kill(bridge.pid, "SIGTERM");
|
|
@@ -299214,7 +299369,7 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299214
299369
|
label: `${t2.enabled ? "●" : "○"} ${t2.name || "(task)"} ${t2.schedule ? "[" + t2.schedule + "]" : ""}`,
|
|
299215
299370
|
detail: `${t2.file}#${t2.index}`
|
|
299216
299371
|
}));
|
|
299217
|
-
items.push({ key: "__kill__", label: "Kill OA schedulers", detail: "Stop scheduler/nexus
|
|
299372
|
+
items.push({ key: "__kill__", label: "Kill OA schedulers + active runs", detail: "Stop scheduler/nexus processes and terminate active OA runs" });
|
|
299218
299373
|
const result = await tuiSelect({
|
|
299219
299374
|
items,
|
|
299220
299375
|
title: "Scheduled Tasks",
|
|
@@ -299602,9 +299757,9 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299602
299757
|
}
|
|
299603
299758
|
}
|
|
299604
299759
|
}
|
|
299605
|
-
const _spLogDir =
|
|
299606
|
-
|
|
299607
|
-
const _spLogFile =
|
|
299760
|
+
const _spLogDir = join80(projectDir, ".oa", "sponsor");
|
|
299761
|
+
mkdirSync36(_spLogDir, { recursive: true });
|
|
299762
|
+
const _spLogFile = join80(_spLogDir, "sponsor-startup.log");
|
|
299608
299763
|
const _spLog = (msg) => {
|
|
299609
299764
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
|
|
299610
299765
|
`;
|
|
@@ -299714,17 +299869,17 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299714
299869
|
}
|
|
299715
299870
|
if (!sponsorUrl && !sponsorPeerId) {
|
|
299716
299871
|
_spLog("FAILED — no tunnelUrl and no peerId");
|
|
299717
|
-
_spLog(`nexusDir checked: ${
|
|
299718
|
-
_spLog(`status.json exists: ${
|
|
299719
|
-
_spLog(`daemon.pid exists: ${
|
|
299872
|
+
_spLog(`nexusDir checked: ${join80(projectDir, ".oa", "nexus")}`);
|
|
299873
|
+
_spLog(`status.json exists: ${existsSync64(join80(projectDir, ".oa", "nexus", "status.json"))}`);
|
|
299874
|
+
_spLog(`daemon.pid exists: ${existsSync64(join80(projectDir, ".oa", "nexus", "daemon.pid"))}`);
|
|
299720
299875
|
try {
|
|
299721
|
-
const _statusRaw = readFileSync49(
|
|
299876
|
+
const _statusRaw = readFileSync49(join80(projectDir, ".oa", "nexus", "status.json"), "utf8");
|
|
299722
299877
|
_spLog(`status.json content: ${_statusRaw.slice(0, 300)}`);
|
|
299723
299878
|
} catch (e2) {
|
|
299724
299879
|
_spLog(`status.json read error: ${e2}`);
|
|
299725
299880
|
}
|
|
299726
299881
|
try {
|
|
299727
|
-
const _errRaw = readFileSync49(
|
|
299882
|
+
const _errRaw = readFileSync49(join80(projectDir, ".oa", "nexus", "daemon.err"), "utf8");
|
|
299728
299883
|
_spLog(`daemon.err (last 500): ${_errRaw.slice(-500)}`);
|
|
299729
299884
|
} catch (e2) {
|
|
299730
299885
|
_spLog(`daemon.err read error: ${e2}`);
|
|
@@ -299743,7 +299898,7 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299743
299898
|
try {
|
|
299744
299899
|
const { homedir: homedir41 } = __require("os");
|
|
299745
299900
|
const namePath = __require("path").join(homedir41(), ".open-agents", "agent-name");
|
|
299746
|
-
if (
|
|
299901
|
+
if (existsSync64(namePath)) sponsorName = readFileSync49(namePath, "utf8").trim();
|
|
299747
299902
|
} catch {
|
|
299748
299903
|
}
|
|
299749
299904
|
if (!sponsorName) sponsorName = "OA Sponsor";
|
|
@@ -299818,8 +299973,8 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299818
299973
|
if (result) {
|
|
299819
299974
|
renderInfo2("Sponsor wizard completed.");
|
|
299820
299975
|
try {
|
|
299821
|
-
const nexusPidFile =
|
|
299822
|
-
if (
|
|
299976
|
+
const nexusPidFile = join80(projectDir, ".oa", "nexus", "daemon.pid");
|
|
299977
|
+
if (existsSync64(nexusPidFile)) {
|
|
299823
299978
|
const nPid = parseInt(readFileSync49(nexusPidFile, "utf8").trim(), 10);
|
|
299824
299979
|
if (nPid > 0) {
|
|
299825
299980
|
registry2.register({ name: "Nexus", pid: nPid, startedAt: Date.now(), status: "running" });
|
|
@@ -300976,13 +301131,13 @@ async function showCohereDashboard(ctx3) {
|
|
|
300976
301131
|
} else if (idResult.key === "view") {
|
|
300977
301132
|
await ik.execute({ operation: "hydrate" });
|
|
300978
301133
|
} else if (idResult.key === "history") {
|
|
300979
|
-
const snapDir =
|
|
300980
|
-
if (
|
|
301134
|
+
const snapDir = join80(ctx3.repoRoot, ".oa", "identity", "snapshots");
|
|
301135
|
+
if (existsSync64(snapDir)) {
|
|
300981
301136
|
const snaps = readdirSync16(snapDir).filter((f2) => f2.endsWith(".json")).sort().reverse();
|
|
300982
301137
|
const snapItems = snaps.slice(0, 20).map((f2) => ({
|
|
300983
301138
|
key: f2,
|
|
300984
301139
|
label: f2.replace(".json", ""),
|
|
300985
|
-
detail: `${formatFileSize(statSync18(
|
|
301140
|
+
detail: `${formatFileSize(statSync18(join80(snapDir, f2)).size)}`
|
|
300986
301141
|
}));
|
|
300987
301142
|
if (snapItems.length > 0) {
|
|
300988
301143
|
await tuiSelect({
|
|
@@ -301999,10 +302154,10 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
301999
302154
|
}
|
|
302000
302155
|
} catch {
|
|
302001
302156
|
}
|
|
302002
|
-
const sponsorDir2 =
|
|
302003
|
-
const knownFile =
|
|
302157
|
+
const sponsorDir2 = join80(ctx3.repoRoot ?? process.cwd(), ".oa", "sponsor");
|
|
302158
|
+
const knownFile = join80(sponsorDir2, "known-sponsors.json");
|
|
302004
302159
|
try {
|
|
302005
|
-
if (
|
|
302160
|
+
if (existsSync64(knownFile)) {
|
|
302006
302161
|
const saved = JSON.parse(readFileSync49(knownFile, "utf8"));
|
|
302007
302162
|
for (const s2 of saved) {
|
|
302008
302163
|
if (!sponsors.some((sp) => sp.url === s2.url)) {
|
|
@@ -302153,11 +302308,11 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
302153
302308
|
}
|
|
302154
302309
|
const saveKey = selected.url || selected.peerId || selected.name;
|
|
302155
302310
|
try {
|
|
302156
|
-
|
|
302157
|
-
const existing =
|
|
302311
|
+
mkdirSync36(sponsorDir2, { recursive: true });
|
|
302312
|
+
const existing = existsSync64(knownFile) ? JSON.parse(readFileSync49(knownFile, "utf8")) : [];
|
|
302158
302313
|
const updated = existing.filter((s2) => (s2.url || s2.peerId || s2.name) !== saveKey);
|
|
302159
302314
|
updated.push(selected);
|
|
302160
|
-
|
|
302315
|
+
writeFileSync34(knownFile, JSON.stringify(updated, null, 2), "utf8");
|
|
302161
302316
|
} catch {
|
|
302162
302317
|
}
|
|
302163
302318
|
renderInfo2(`Connected to sponsored endpoint: ${selected.name}`);
|
|
@@ -306244,8 +306399,8 @@ import { EventEmitter as EventEmitter5 } from "node:events";
|
|
|
306244
306399
|
import { randomBytes as randomBytes17 } from "node:crypto";
|
|
306245
306400
|
import { URL as URL2 } from "node:url";
|
|
306246
306401
|
import { loadavg as loadavg3, cpus as cpus4, totalmem as totalmem5, freemem as freemem4 } from "node:os";
|
|
306247
|
-
import { existsSync as
|
|
306248
|
-
import { join as
|
|
306402
|
+
import { existsSync as existsSync65, readFileSync as readFileSync50, writeFileSync as writeFileSync35, unlinkSync as unlinkSync18, mkdirSync as mkdirSync37, readdirSync as readdirSync17, statSync as statSync19 } from "node:fs";
|
|
306403
|
+
import { join as join81 } from "node:path";
|
|
306249
306404
|
function cleanForwardHeaders(raw, targetHost) {
|
|
306250
306405
|
const out = {};
|
|
306251
306406
|
for (const [key, value2] of Object.entries(raw)) {
|
|
@@ -306266,8 +306421,8 @@ function fmtTokens(n2) {
|
|
|
306266
306421
|
}
|
|
306267
306422
|
function readExposeState(stateDir) {
|
|
306268
306423
|
try {
|
|
306269
|
-
const path5 =
|
|
306270
|
-
if (!
|
|
306424
|
+
const path5 = join81(stateDir, STATE_FILE_NAME);
|
|
306425
|
+
if (!existsSync65(path5)) return null;
|
|
306271
306426
|
const raw = readFileSync50(path5, "utf8");
|
|
306272
306427
|
const data = JSON.parse(raw);
|
|
306273
306428
|
if (!data.pid || !data.tunnelUrl || !data.authKey || !data.proxyPort) return null;
|
|
@@ -306278,14 +306433,14 @@ function readExposeState(stateDir) {
|
|
|
306278
306433
|
}
|
|
306279
306434
|
function writeExposeState(stateDir, state) {
|
|
306280
306435
|
try {
|
|
306281
|
-
|
|
306282
|
-
|
|
306436
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
306437
|
+
writeFileSync35(join81(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
306283
306438
|
} catch {
|
|
306284
306439
|
}
|
|
306285
306440
|
}
|
|
306286
306441
|
function removeExposeState(stateDir) {
|
|
306287
306442
|
try {
|
|
306288
|
-
unlinkSync18(
|
|
306443
|
+
unlinkSync18(join81(stateDir, STATE_FILE_NAME));
|
|
306289
306444
|
} catch {
|
|
306290
306445
|
}
|
|
306291
306446
|
}
|
|
@@ -306382,8 +306537,8 @@ async function collectSystemMetricsAsync() {
|
|
|
306382
306537
|
}
|
|
306383
306538
|
function readP2PExposeState(stateDir) {
|
|
306384
306539
|
try {
|
|
306385
|
-
const path5 =
|
|
306386
|
-
if (!
|
|
306540
|
+
const path5 = join81(stateDir, P2P_STATE_FILE_NAME);
|
|
306541
|
+
if (!existsSync65(path5)) return null;
|
|
306387
306542
|
const raw = readFileSync50(path5, "utf8");
|
|
306388
306543
|
const data = JSON.parse(raw);
|
|
306389
306544
|
if (!data.peerId || !data.authKey) return null;
|
|
@@ -306394,14 +306549,14 @@ function readP2PExposeState(stateDir) {
|
|
|
306394
306549
|
}
|
|
306395
306550
|
function writeP2PExposeState(stateDir, state) {
|
|
306396
306551
|
try {
|
|
306397
|
-
|
|
306398
|
-
|
|
306552
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
306553
|
+
writeFileSync35(join81(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
306399
306554
|
} catch {
|
|
306400
306555
|
}
|
|
306401
306556
|
}
|
|
306402
306557
|
function removeP2PExposeState(stateDir) {
|
|
306403
306558
|
try {
|
|
306404
|
-
unlinkSync18(
|
|
306559
|
+
unlinkSync18(join81(stateDir, P2P_STATE_FILE_NAME));
|
|
306405
306560
|
} catch {
|
|
306406
306561
|
}
|
|
306407
306562
|
}
|
|
@@ -307391,7 +307546,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
307391
307546
|
throw new Error(`Expose failed: ${exposeResult.error}`);
|
|
307392
307547
|
}
|
|
307393
307548
|
const nexusDir = this._nexusTool.getNexusDir();
|
|
307394
|
-
const statusPath =
|
|
307549
|
+
const statusPath = join81(nexusDir, "status.json");
|
|
307395
307550
|
for (let i2 = 0; i2 < 80; i2++) {
|
|
307396
307551
|
try {
|
|
307397
307552
|
const raw = readFileSync50(statusPath, "utf8");
|
|
@@ -307425,8 +307580,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307425
307580
|
});
|
|
307426
307581
|
}
|
|
307427
307582
|
try {
|
|
307428
|
-
const invocDir =
|
|
307429
|
-
if (
|
|
307583
|
+
const invocDir = join81(nexusDir, "invocations");
|
|
307584
|
+
if (existsSync65(invocDir)) {
|
|
307430
307585
|
this._prevInvocCount = readdirSync17(invocDir).filter((f2) => f2.endsWith(".json")).length;
|
|
307431
307586
|
this._stats.totalRequests = this._prevInvocCount;
|
|
307432
307587
|
}
|
|
@@ -307453,9 +307608,9 @@ ${this.formatConnectionInfo()}`);
|
|
|
307453
307608
|
const state = readP2PExposeState(stateDir);
|
|
307454
307609
|
if (!state) return null;
|
|
307455
307610
|
const nexusDir = nexusTool.getNexusDir();
|
|
307456
|
-
const statusPath =
|
|
307611
|
+
const statusPath = join81(nexusDir, "status.json");
|
|
307457
307612
|
try {
|
|
307458
|
-
if (!
|
|
307613
|
+
if (!existsSync65(statusPath)) {
|
|
307459
307614
|
removeP2PExposeState(stateDir);
|
|
307460
307615
|
return null;
|
|
307461
307616
|
}
|
|
@@ -307512,8 +307667,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307512
307667
|
let lastMeteringLineCount = 0;
|
|
307513
307668
|
this._activityPollTimer = setInterval(() => {
|
|
307514
307669
|
try {
|
|
307515
|
-
const invocDir =
|
|
307516
|
-
if (!
|
|
307670
|
+
const invocDir = join81(nexusDir, "invocations");
|
|
307671
|
+
if (!existsSync65(invocDir)) return;
|
|
307517
307672
|
const files = readdirSync17(invocDir).filter((f2) => f2.endsWith(".json"));
|
|
307518
307673
|
const invocCount = files.length;
|
|
307519
307674
|
const newRequests = invocCount - this._prevInvocCount;
|
|
@@ -307527,15 +307682,15 @@ ${this.formatConnectionInfo()}`);
|
|
|
307527
307682
|
let recentActive = 0;
|
|
307528
307683
|
for (const f2 of files.slice(-10)) {
|
|
307529
307684
|
try {
|
|
307530
|
-
const st = statSync19(
|
|
307685
|
+
const st = statSync19(join81(invocDir, f2));
|
|
307531
307686
|
if (now - st.mtimeMs < 1e4) recentActive++;
|
|
307532
307687
|
} catch {
|
|
307533
307688
|
}
|
|
307534
307689
|
}
|
|
307535
|
-
const meteringFile =
|
|
307690
|
+
const meteringFile = join81(nexusDir, "metering.jsonl");
|
|
307536
307691
|
let meteringLines = lastMeteringLineCount;
|
|
307537
307692
|
try {
|
|
307538
|
-
if (
|
|
307693
|
+
if (existsSync65(meteringFile)) {
|
|
307539
307694
|
const content = readFileSync50(meteringFile, "utf8");
|
|
307540
307695
|
meteringLines = content.split("\n").filter((l2) => l2.trim()).length;
|
|
307541
307696
|
}
|
|
@@ -307561,8 +307716,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307561
307716
|
this._activityPollTimer.unref();
|
|
307562
307717
|
this._pollTimer = setInterval(() => {
|
|
307563
307718
|
try {
|
|
307564
|
-
const statusPath =
|
|
307565
|
-
if (
|
|
307719
|
+
const statusPath = join81(nexusDir, "status.json");
|
|
307720
|
+
if (existsSync65(statusPath)) {
|
|
307566
307721
|
const status = JSON.parse(readFileSync50(statusPath, "utf8"));
|
|
307567
307722
|
if (status.peerId && !this._peerId) {
|
|
307568
307723
|
this._peerId = status.peerId;
|
|
@@ -307572,8 +307727,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307572
307727
|
} catch {
|
|
307573
307728
|
}
|
|
307574
307729
|
try {
|
|
307575
|
-
const invocDir =
|
|
307576
|
-
if (
|
|
307730
|
+
const invocDir = join81(nexusDir, "invocations");
|
|
307731
|
+
if (existsSync65(invocDir)) {
|
|
307577
307732
|
const files = readdirSync17(invocDir);
|
|
307578
307733
|
const invocCount = files.filter((f2) => f2.endsWith(".json")).length;
|
|
307579
307734
|
if (invocCount > this._stats.totalRequests) {
|
|
@@ -307584,8 +307739,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307584
307739
|
} catch {
|
|
307585
307740
|
}
|
|
307586
307741
|
try {
|
|
307587
|
-
const meteringFile =
|
|
307588
|
-
if (
|
|
307742
|
+
const meteringFile = join81(nexusDir, "metering.jsonl");
|
|
307743
|
+
if (existsSync65(meteringFile)) {
|
|
307589
307744
|
const content = readFileSync50(meteringFile, "utf8");
|
|
307590
307745
|
if (content.length > lastMeteringSize) {
|
|
307591
307746
|
const newContent = content.slice(lastMeteringSize);
|
|
@@ -307797,7 +307952,7 @@ var init_types = __esm({
|
|
|
307797
307952
|
|
|
307798
307953
|
// packages/cli/src/tui/p2p/secret-vault.ts
|
|
307799
307954
|
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes18, scryptSync as scryptSync2, createHash as createHash5 } from "node:crypto";
|
|
307800
|
-
import { readFileSync as readFileSync51, writeFileSync as
|
|
307955
|
+
import { readFileSync as readFileSync51, writeFileSync as writeFileSync36, existsSync as existsSync66, mkdirSync as mkdirSync38 } from "node:fs";
|
|
307801
307956
|
import { dirname as dirname24 } from "node:path";
|
|
307802
307957
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
307803
307958
|
var init_secret_vault = __esm({
|
|
@@ -308005,15 +308160,15 @@ var init_secret_vault = __esm({
|
|
|
308005
308160
|
const tag = cipher.getAuthTag();
|
|
308006
308161
|
const blob = Buffer.concat([salt, iv, tag, encrypted]);
|
|
308007
308162
|
const dir = dirname24(this.storePath);
|
|
308008
|
-
if (!
|
|
308009
|
-
|
|
308163
|
+
if (!existsSync66(dir)) mkdirSync38(dir, { recursive: true });
|
|
308164
|
+
writeFileSync36(this.storePath, blob, { mode: 384 });
|
|
308010
308165
|
}
|
|
308011
308166
|
/**
|
|
308012
308167
|
* Load vault from disk, decrypting with the given passphrase.
|
|
308013
308168
|
* Returns the number of secrets loaded.
|
|
308014
308169
|
*/
|
|
308015
308170
|
load(passphrase) {
|
|
308016
|
-
if (!this.storePath || !
|
|
308171
|
+
if (!this.storePath || !existsSync66(this.storePath)) return 0;
|
|
308017
308172
|
const blob = readFileSync51(this.storePath);
|
|
308018
308173
|
if (blob.length < SALT_LEN + IV_LEN + 16) {
|
|
308019
308174
|
throw new Error("Vault file is corrupted (too small)");
|
|
@@ -309035,10 +309190,10 @@ ${activitySummary}
|
|
|
309035
309190
|
});
|
|
309036
309191
|
|
|
309037
309192
|
// packages/cli/src/tui/project-context.ts
|
|
309038
|
-
import { existsSync as
|
|
309039
|
-
import { join as
|
|
309193
|
+
import { existsSync as existsSync67, readFileSync as readFileSync52, readdirSync as readdirSync18 } from "node:fs";
|
|
309194
|
+
import { join as join83, basename as basename13 } from "node:path";
|
|
309040
309195
|
import { execSync as execSync51 } from "node:child_process";
|
|
309041
|
-
import { homedir as
|
|
309196
|
+
import { homedir as homedir32, platform as platform5, release } from "node:os";
|
|
309042
309197
|
function getModelTier(modelName) {
|
|
309043
309198
|
const m2 = modelName.toLowerCase();
|
|
309044
309199
|
const sizeMatch = m2.match(/\b(\d+)b\b/);
|
|
@@ -309067,8 +309222,8 @@ function loadProjectMap(repoRoot) {
|
|
|
309067
309222
|
if (!hasOaDirectory(repoRoot)) {
|
|
309068
309223
|
initOaDirectory(repoRoot);
|
|
309069
309224
|
}
|
|
309070
|
-
const mapPath2 =
|
|
309071
|
-
if (
|
|
309225
|
+
const mapPath2 = join83(repoRoot, OA_DIR, "context", "project-map.md");
|
|
309226
|
+
if (existsSync67(mapPath2)) {
|
|
309072
309227
|
try {
|
|
309073
309228
|
const content = readFileSync52(mapPath2, "utf-8");
|
|
309074
309229
|
return content;
|
|
@@ -309109,27 +309264,27 @@ ${log22}`);
|
|
|
309109
309264
|
}
|
|
309110
309265
|
function loadMemoryContext(repoRoot) {
|
|
309111
309266
|
const sections = [];
|
|
309112
|
-
const oaMemDir =
|
|
309267
|
+
const oaMemDir = join83(repoRoot, OA_DIR, "memory");
|
|
309113
309268
|
const oaEntries = loadMemoryDir(oaMemDir, "project");
|
|
309114
309269
|
if (oaEntries) sections.push(oaEntries);
|
|
309115
|
-
const legacyMemDir =
|
|
309116
|
-
if (legacyMemDir !== oaMemDir &&
|
|
309270
|
+
const legacyMemDir = join83(repoRoot, ".open-agents", "memory");
|
|
309271
|
+
if (legacyMemDir !== oaMemDir && existsSync67(legacyMemDir)) {
|
|
309117
309272
|
const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
|
|
309118
309273
|
if (legacyEntries) sections.push(legacyEntries);
|
|
309119
309274
|
}
|
|
309120
|
-
const globalMemDir =
|
|
309275
|
+
const globalMemDir = join83(homedir32(), ".open-agents", "memory");
|
|
309121
309276
|
const globalEntries = loadMemoryDir(globalMemDir, "global");
|
|
309122
309277
|
if (globalEntries) sections.push(globalEntries);
|
|
309123
309278
|
return sections.join("\n\n");
|
|
309124
309279
|
}
|
|
309125
309280
|
function loadMemoryDir(memDir, scope) {
|
|
309126
|
-
if (!
|
|
309281
|
+
if (!existsSync67(memDir)) return "";
|
|
309127
309282
|
const lines = [];
|
|
309128
309283
|
try {
|
|
309129
309284
|
const files = readdirSync18(memDir).filter((f2) => f2.endsWith(".json"));
|
|
309130
309285
|
for (const file of files.slice(0, 10)) {
|
|
309131
309286
|
try {
|
|
309132
|
-
const raw = readFileSync52(
|
|
309287
|
+
const raw = readFileSync52(join83(memDir, file), "utf-8");
|
|
309133
309288
|
const entries = JSON.parse(raw);
|
|
309134
309289
|
const topic = basename13(file, ".json");
|
|
309135
309290
|
const keys = Object.keys(entries);
|
|
@@ -309657,8 +309812,8 @@ __export(banner_exports, {
|
|
|
309657
309812
|
saveBannerDesign: () => saveBannerDesign,
|
|
309658
309813
|
setGridText: () => setGridText
|
|
309659
309814
|
});
|
|
309660
|
-
import { existsSync as
|
|
309661
|
-
import { join as
|
|
309815
|
+
import { existsSync as existsSync68, readFileSync as readFileSync53, writeFileSync as writeFileSync37, mkdirSync as mkdirSync39 } from "node:fs";
|
|
309816
|
+
import { join as join84 } from "node:path";
|
|
309662
309817
|
function generateMnemonic(seed) {
|
|
309663
309818
|
let h = 2166136261;
|
|
309664
309819
|
for (let i2 = 0; i2 < seed.length; i2++) {
|
|
@@ -309788,13 +309943,13 @@ function createSponsorBanner(sponsorName, tagline, primaryColor = 214, bgColor =
|
|
|
309788
309943
|
};
|
|
309789
309944
|
}
|
|
309790
309945
|
function saveBannerDesign(workDir, design) {
|
|
309791
|
-
const dir =
|
|
309792
|
-
|
|
309793
|
-
|
|
309946
|
+
const dir = join84(workDir, ".oa", "banners");
|
|
309947
|
+
mkdirSync39(dir, { recursive: true });
|
|
309948
|
+
writeFileSync37(join84(dir, `${design.id}.json`), JSON.stringify(design, null, 2), "utf8");
|
|
309794
309949
|
}
|
|
309795
309950
|
function loadBannerDesign(workDir, id) {
|
|
309796
|
-
const file =
|
|
309797
|
-
if (!
|
|
309951
|
+
const file = join84(workDir, ".oa", "banners", `${id}.json`);
|
|
309952
|
+
if (!existsSync68(file)) return null;
|
|
309798
309953
|
try {
|
|
309799
309954
|
return JSON.parse(readFileSync53(file, "utf8"));
|
|
309800
309955
|
} catch {
|
|
@@ -309802,8 +309957,8 @@ function loadBannerDesign(workDir, id) {
|
|
|
309802
309957
|
}
|
|
309803
309958
|
}
|
|
309804
309959
|
function listBannerDesigns(workDir) {
|
|
309805
|
-
const dir =
|
|
309806
|
-
if (!
|
|
309960
|
+
const dir = join84(workDir, ".oa", "banners");
|
|
309961
|
+
if (!existsSync68(dir)) return [];
|
|
309807
309962
|
try {
|
|
309808
309963
|
const { readdirSync: readdirSync31 } = __require("node:fs");
|
|
309809
309964
|
return readdirSync31(dir).filter((f2) => f2.endsWith(".json")).map((f2) => f2.replace(".json", ""));
|
|
@@ -310111,21 +310266,21 @@ var init_banner = __esm({
|
|
|
310111
310266
|
});
|
|
310112
310267
|
|
|
310113
310268
|
// packages/cli/src/tui/carousel-descriptors.ts
|
|
310114
|
-
import { existsSync as
|
|
310115
|
-
import { join as
|
|
310269
|
+
import { existsSync as existsSync69, readFileSync as readFileSync54, writeFileSync as writeFileSync38, mkdirSync as mkdirSync40, readdirSync as readdirSync19 } from "node:fs";
|
|
310270
|
+
import { join as join85, basename as basename14 } from "node:path";
|
|
310116
310271
|
function loadToolProfile(repoRoot) {
|
|
310117
|
-
const filePath =
|
|
310272
|
+
const filePath = join85(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
310118
310273
|
try {
|
|
310119
|
-
if (!
|
|
310274
|
+
if (!existsSync69(filePath)) return null;
|
|
310120
310275
|
return JSON.parse(readFileSync54(filePath, "utf-8"));
|
|
310121
310276
|
} catch {
|
|
310122
310277
|
return null;
|
|
310123
310278
|
}
|
|
310124
310279
|
}
|
|
310125
310280
|
function saveToolProfile(repoRoot, profile) {
|
|
310126
|
-
const contextDir =
|
|
310127
|
-
|
|
310128
|
-
|
|
310281
|
+
const contextDir = join85(repoRoot, OA_DIR, "context");
|
|
310282
|
+
mkdirSync40(contextDir, { recursive: true });
|
|
310283
|
+
writeFileSync38(join85(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
|
|
310129
310284
|
}
|
|
310130
310285
|
function categorizeToolCall(toolName) {
|
|
310131
310286
|
for (const cat2 of TOOL_CATEGORIES) {
|
|
@@ -310180,9 +310335,9 @@ function weightedColor(profile) {
|
|
|
310180
310335
|
return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
|
|
310181
310336
|
}
|
|
310182
310337
|
function loadCachedDescriptors(repoRoot) {
|
|
310183
|
-
const filePath =
|
|
310338
|
+
const filePath = join85(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
|
|
310184
310339
|
try {
|
|
310185
|
-
if (!
|
|
310340
|
+
if (!existsSync69(filePath)) return null;
|
|
310186
310341
|
const cached = JSON.parse(readFileSync54(filePath, "utf-8"));
|
|
310187
310342
|
return cached.phrases.length > 0 ? cached.phrases : null;
|
|
310188
310343
|
} catch {
|
|
@@ -310190,14 +310345,14 @@ function loadCachedDescriptors(repoRoot) {
|
|
|
310190
310345
|
}
|
|
310191
310346
|
}
|
|
310192
310347
|
function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
310193
|
-
const contextDir =
|
|
310194
|
-
|
|
310348
|
+
const contextDir = join85(repoRoot, OA_DIR, "context");
|
|
310349
|
+
mkdirSync40(contextDir, { recursive: true });
|
|
310195
310350
|
const cached = {
|
|
310196
310351
|
phrases,
|
|
310197
310352
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
310198
310353
|
sourceHash
|
|
310199
310354
|
};
|
|
310200
|
-
|
|
310355
|
+
writeFileSync38(join85(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
310201
310356
|
}
|
|
310202
310357
|
function generateDescriptors(repoRoot) {
|
|
310203
310358
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -310244,9 +310399,9 @@ function generateDescriptors(repoRoot) {
|
|
|
310244
310399
|
return phrases;
|
|
310245
310400
|
}
|
|
310246
310401
|
function extractFromPackageJson(repoRoot, tags) {
|
|
310247
|
-
const pkgPath =
|
|
310402
|
+
const pkgPath = join85(repoRoot, "package.json");
|
|
310248
310403
|
try {
|
|
310249
|
-
if (!
|
|
310404
|
+
if (!existsSync69(pkgPath)) return;
|
|
310250
310405
|
const pkg = JSON.parse(readFileSync54(pkgPath, "utf-8"));
|
|
310251
310406
|
if (pkg.name && typeof pkg.name === "string") {
|
|
310252
310407
|
const parts = pkg.name.replace(/^@/, "").split("/");
|
|
@@ -310288,7 +310443,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
310288
310443
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
310289
310444
|
];
|
|
310290
310445
|
for (const check of manifestChecks) {
|
|
310291
|
-
if (
|
|
310446
|
+
if (existsSync69(join85(repoRoot, check.file))) {
|
|
310292
310447
|
tags.push(check.tag);
|
|
310293
310448
|
}
|
|
310294
310449
|
}
|
|
@@ -310310,15 +310465,15 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
310310
310465
|
}
|
|
310311
310466
|
}
|
|
310312
310467
|
function extractFromMemory(repoRoot, tags) {
|
|
310313
|
-
const memoryDir =
|
|
310468
|
+
const memoryDir = join85(repoRoot, OA_DIR, "memory");
|
|
310314
310469
|
try {
|
|
310315
|
-
if (!
|
|
310470
|
+
if (!existsSync69(memoryDir)) return;
|
|
310316
310471
|
const files = readdirSync19(memoryDir).filter((f2) => f2.endsWith(".json"));
|
|
310317
310472
|
for (const file of files) {
|
|
310318
310473
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
310319
310474
|
tags.push(topic);
|
|
310320
310475
|
try {
|
|
310321
|
-
const data = JSON.parse(readFileSync54(
|
|
310476
|
+
const data = JSON.parse(readFileSync54(join85(memoryDir, file), "utf-8"));
|
|
310322
310477
|
if (data && typeof data === "object") {
|
|
310323
310478
|
const keys = Object.keys(data).slice(0, 3);
|
|
310324
310479
|
for (const key of keys) {
|
|
@@ -311016,13 +311171,13 @@ var init_stream_renderer = __esm({
|
|
|
311016
311171
|
});
|
|
311017
311172
|
|
|
311018
311173
|
// packages/cli/src/tui/edit-history.ts
|
|
311019
|
-
import { appendFileSync as appendFileSync4, mkdirSync as
|
|
311020
|
-
import { join as
|
|
311174
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "node:fs";
|
|
311175
|
+
import { join as join86 } from "node:path";
|
|
311021
311176
|
function createEditHistoryLogger(repoRoot, sessionId) {
|
|
311022
|
-
const historyDir =
|
|
311023
|
-
const logPath2 =
|
|
311177
|
+
const historyDir = join86(repoRoot, ".oa", "history");
|
|
311178
|
+
const logPath2 = join86(historyDir, "edits.jsonl");
|
|
311024
311179
|
try {
|
|
311025
|
-
|
|
311180
|
+
mkdirSync41(historyDir, { recursive: true });
|
|
311026
311181
|
} catch {
|
|
311027
311182
|
}
|
|
311028
311183
|
function logToolCall(toolName, toolArgs, success) {
|
|
@@ -311130,14 +311285,14 @@ var init_edit_history = __esm({
|
|
|
311130
311285
|
});
|
|
311131
311286
|
|
|
311132
311287
|
// packages/cli/src/tui/promptLoader.ts
|
|
311133
|
-
import { readFileSync as readFileSync55, existsSync as
|
|
311134
|
-
import { join as
|
|
311288
|
+
import { readFileSync as readFileSync55, existsSync as existsSync70 } from "node:fs";
|
|
311289
|
+
import { join as join87, dirname as dirname25 } from "node:path";
|
|
311135
311290
|
import { fileURLToPath as fileURLToPath15 } from "node:url";
|
|
311136
311291
|
function loadPrompt3(promptPath, vars) {
|
|
311137
311292
|
let content = cache6.get(promptPath);
|
|
311138
311293
|
if (content === void 0) {
|
|
311139
|
-
const fullPath =
|
|
311140
|
-
if (!
|
|
311294
|
+
const fullPath = join87(PROMPTS_DIR3, promptPath);
|
|
311295
|
+
if (!existsSync70(fullPath)) {
|
|
311141
311296
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
311142
311297
|
}
|
|
311143
311298
|
content = readFileSync55(fullPath, "utf-8");
|
|
@@ -311152,16 +311307,16 @@ var init_promptLoader3 = __esm({
|
|
|
311152
311307
|
"use strict";
|
|
311153
311308
|
__filename5 = fileURLToPath15(import.meta.url);
|
|
311154
311309
|
__dirname7 = dirname25(__filename5);
|
|
311155
|
-
devPath2 =
|
|
311156
|
-
publishedPath2 =
|
|
311157
|
-
PROMPTS_DIR3 =
|
|
311310
|
+
devPath2 = join87(__dirname7, "..", "..", "prompts");
|
|
311311
|
+
publishedPath2 = join87(__dirname7, "..", "prompts");
|
|
311312
|
+
PROMPTS_DIR3 = existsSync70(devPath2) ? devPath2 : publishedPath2;
|
|
311158
311313
|
cache6 = /* @__PURE__ */ new Map();
|
|
311159
311314
|
}
|
|
311160
311315
|
});
|
|
311161
311316
|
|
|
311162
311317
|
// packages/cli/src/tui/dream-engine.ts
|
|
311163
|
-
import { mkdirSync as
|
|
311164
|
-
import { join as
|
|
311318
|
+
import { mkdirSync as mkdirSync42, writeFileSync as writeFileSync39, readFileSync as readFileSync56, existsSync as existsSync71, readdirSync as readdirSync20 } from "node:fs";
|
|
311319
|
+
import { join as join88, basename as basename15 } from "node:path";
|
|
311165
311320
|
import { execSync as execSync52 } from "node:child_process";
|
|
311166
311321
|
function setDreamWriteContent(fn) {
|
|
311167
311322
|
_dreamWriteContent = fn;
|
|
@@ -311174,8 +311329,8 @@ function dreamWrite(fn) {
|
|
|
311174
311329
|
}
|
|
311175
311330
|
}
|
|
311176
311331
|
function loadAutoresearchMemory(repoRoot) {
|
|
311177
|
-
const memoryPath =
|
|
311178
|
-
if (!
|
|
311332
|
+
const memoryPath = join88(repoRoot, ".oa", "memory", "autoresearch.json");
|
|
311333
|
+
if (!existsSync71(memoryPath)) return "";
|
|
311179
311334
|
try {
|
|
311180
311335
|
const raw = readFileSync56(memoryPath, "utf-8");
|
|
311181
311336
|
const data = JSON.parse(raw);
|
|
@@ -311373,14 +311528,14 @@ var init_dream_engine = __esm({
|
|
|
311373
311528
|
const rawPath = String(args2["path"] ?? "");
|
|
311374
311529
|
const content = String(args2["content"] ?? "");
|
|
311375
311530
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
311376
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
311531
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join88(this.autoresearchDir, basename15(rawPath)) : join88(this.autoresearchDir, rawPath);
|
|
311377
311532
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
311378
311533
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start2 };
|
|
311379
311534
|
}
|
|
311380
311535
|
try {
|
|
311381
|
-
const dir =
|
|
311382
|
-
|
|
311383
|
-
|
|
311536
|
+
const dir = join88(targetPath, "..");
|
|
311537
|
+
mkdirSync42(dir, { recursive: true });
|
|
311538
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311384
311539
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311385
311540
|
} catch (err) {
|
|
311386
311541
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311407,12 +311562,12 @@ var init_dream_engine = __esm({
|
|
|
311407
311562
|
const rawPath = String(args2["path"] ?? "");
|
|
311408
311563
|
const oldStr = String(args2["old_string"] ?? "");
|
|
311409
311564
|
const newStr = String(args2["new_string"] ?? "");
|
|
311410
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
311565
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join88(this.autoresearchDir, basename15(rawPath)) : join88(this.autoresearchDir, rawPath);
|
|
311411
311566
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
311412
311567
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start2 };
|
|
311413
311568
|
}
|
|
311414
311569
|
try {
|
|
311415
|
-
if (!
|
|
311570
|
+
if (!existsSync71(targetPath)) {
|
|
311416
311571
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311417
311572
|
}
|
|
311418
311573
|
let content = readFileSync56(targetPath, "utf-8");
|
|
@@ -311420,7 +311575,7 @@ var init_dream_engine = __esm({
|
|
|
311420
311575
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
311421
311576
|
}
|
|
311422
311577
|
content = content.replace(oldStr, newStr);
|
|
311423
|
-
|
|
311578
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311424
311579
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311425
311580
|
} catch (err) {
|
|
311426
311581
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311459,14 +311614,14 @@ var init_dream_engine = __esm({
|
|
|
311459
311614
|
const rawPath = String(args2["path"] ?? "");
|
|
311460
311615
|
const content = String(args2["content"] ?? "");
|
|
311461
311616
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
311462
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
311617
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join88(this.dreamsDir, basename15(rawPath)) : join88(this.dreamsDir, rawPath);
|
|
311463
311618
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
311464
311619
|
return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start2 };
|
|
311465
311620
|
}
|
|
311466
311621
|
try {
|
|
311467
|
-
const dir =
|
|
311468
|
-
|
|
311469
|
-
|
|
311622
|
+
const dir = join88(targetPath, "..");
|
|
311623
|
+
mkdirSync42(dir, { recursive: true });
|
|
311624
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311470
311625
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311471
311626
|
} catch (err) {
|
|
311472
311627
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311493,12 +311648,12 @@ var init_dream_engine = __esm({
|
|
|
311493
311648
|
const rawPath = String(args2["path"] ?? "");
|
|
311494
311649
|
const oldStr = String(args2["old_string"] ?? "");
|
|
311495
311650
|
const newStr = String(args2["new_string"] ?? "");
|
|
311496
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
311651
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join88(this.dreamsDir, basename15(rawPath)) : join88(this.dreamsDir, rawPath);
|
|
311497
311652
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
311498
311653
|
return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start2 };
|
|
311499
311654
|
}
|
|
311500
311655
|
try {
|
|
311501
|
-
if (!
|
|
311656
|
+
if (!existsSync71(targetPath)) {
|
|
311502
311657
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311503
311658
|
}
|
|
311504
311659
|
let content = readFileSync56(targetPath, "utf-8");
|
|
@@ -311506,7 +311661,7 @@ var init_dream_engine = __esm({
|
|
|
311506
311661
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
311507
311662
|
}
|
|
311508
311663
|
content = content.replace(oldStr, newStr);
|
|
311509
|
-
|
|
311664
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311510
311665
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311511
311666
|
} catch (err) {
|
|
311512
311667
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311554,7 +311709,7 @@ var init_dream_engine = __esm({
|
|
|
311554
311709
|
constructor(config, repoRoot) {
|
|
311555
311710
|
this.config = config;
|
|
311556
311711
|
this.repoRoot = repoRoot;
|
|
311557
|
-
this.dreamsDir =
|
|
311712
|
+
this.dreamsDir = join88(repoRoot, ".oa", "dreams");
|
|
311558
311713
|
this.state = {
|
|
311559
311714
|
mode: "default",
|
|
311560
311715
|
active: false,
|
|
@@ -311591,7 +311746,7 @@ var init_dream_engine = __esm({
|
|
|
311591
311746
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
311592
311747
|
results: []
|
|
311593
311748
|
};
|
|
311594
|
-
|
|
311749
|
+
mkdirSync42(this.dreamsDir, { recursive: true });
|
|
311595
311750
|
this.saveDreamState();
|
|
311596
311751
|
try {
|
|
311597
311752
|
for (let cycle = 1; cycle <= totalCycles; cycle++) {
|
|
@@ -311663,8 +311818,8 @@ ${result.summary}`;
|
|
|
311663
311818
|
if (mode !== "default" || cycle === totalCycles) {
|
|
311664
311819
|
renderDreamContraction(cycle);
|
|
311665
311820
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
311666
|
-
const summaryPath =
|
|
311667
|
-
|
|
311821
|
+
const summaryPath = join88(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
311822
|
+
writeFileSync39(summaryPath, cycleSummary, "utf-8");
|
|
311668
311823
|
}
|
|
311669
311824
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
311670
311825
|
this.saveVersionCheckpoint(cycle);
|
|
@@ -311903,7 +312058,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
311903
312058
|
}
|
|
311904
312059
|
/** Build role-specific tool sets for swarm agents */
|
|
311905
312060
|
buildSwarmTools(role, _workspace) {
|
|
311906
|
-
const autoresearchDir =
|
|
312061
|
+
const autoresearchDir = join88(this.repoRoot, ".oa", "autoresearch");
|
|
311907
312062
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
311908
312063
|
switch (role) {
|
|
311909
312064
|
case "researcher": {
|
|
@@ -312302,7 +312457,7 @@ Call task_complete with a human-readable summary of the autoresearch session.`,
|
|
|
312302
312457
|
workspace,
|
|
312303
312458
|
onEvent
|
|
312304
312459
|
);
|
|
312305
|
-
const reportPath =
|
|
312460
|
+
const reportPath = join88(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
312306
312461
|
const report = `# Autoresearch Swarm Report — Cycle ${cycleNum}
|
|
312307
312462
|
|
|
312308
312463
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -312324,8 +312479,8 @@ ${summaryResult}
|
|
|
312324
312479
|
*Generated by open-agents autoresearch swarm*
|
|
312325
312480
|
`;
|
|
312326
312481
|
try {
|
|
312327
|
-
|
|
312328
|
-
|
|
312482
|
+
mkdirSync42(this.dreamsDir, { recursive: true });
|
|
312483
|
+
writeFileSync39(reportPath, report, "utf-8");
|
|
312329
312484
|
} catch {
|
|
312330
312485
|
}
|
|
312331
312486
|
renderSwarmComplete(workspace);
|
|
@@ -312391,9 +312546,9 @@ ${summaryResult}
|
|
|
312391
312546
|
}
|
|
312392
312547
|
/** Save workspace backup for lucid mode */
|
|
312393
312548
|
saveVersionCheckpoint(cycle) {
|
|
312394
|
-
const checkpointDir =
|
|
312549
|
+
const checkpointDir = join88(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
312395
312550
|
try {
|
|
312396
|
-
|
|
312551
|
+
mkdirSync42(checkpointDir, { recursive: true });
|
|
312397
312552
|
try {
|
|
312398
312553
|
const gitStatus = execSync52("git status --porcelain", {
|
|
312399
312554
|
cwd: this.repoRoot,
|
|
@@ -312410,11 +312565,11 @@ ${summaryResult}
|
|
|
312410
312565
|
encoding: "utf-8",
|
|
312411
312566
|
timeout: 5e3
|
|
312412
312567
|
}).trim();
|
|
312413
|
-
|
|
312414
|
-
|
|
312415
|
-
|
|
312416
|
-
|
|
312417
|
-
|
|
312568
|
+
writeFileSync39(join88(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
|
|
312569
|
+
writeFileSync39(join88(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
|
|
312570
|
+
writeFileSync39(join88(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
|
|
312571
|
+
writeFileSync39(
|
|
312572
|
+
join88(checkpointDir, "checkpoint.json"),
|
|
312418
312573
|
JSON.stringify({
|
|
312419
312574
|
cycle,
|
|
312420
312575
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -312425,8 +312580,8 @@ ${summaryResult}
|
|
|
312425
312580
|
);
|
|
312426
312581
|
renderInfo2(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
312427
312582
|
} catch {
|
|
312428
|
-
|
|
312429
|
-
|
|
312583
|
+
writeFileSync39(
|
|
312584
|
+
join88(checkpointDir, "checkpoint.json"),
|
|
312430
312585
|
JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2),
|
|
312431
312586
|
"utf-8"
|
|
312432
312587
|
);
|
|
@@ -312487,7 +312642,7 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312487
312642
|
---
|
|
312488
312643
|
*Auto-generated by open-agents dream engine*
|
|
312489
312644
|
`;
|
|
312490
|
-
|
|
312645
|
+
writeFileSync39(join88(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
312491
312646
|
} catch {
|
|
312492
312647
|
}
|
|
312493
312648
|
}
|
|
@@ -312508,8 +312663,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312508
312663
|
results: []
|
|
312509
312664
|
};
|
|
312510
312665
|
renderInfo2("Memory consolidation starting — Phase 1: Orient → Phase 2: Gather → Phase 3: Consolidate → Phase 4: Prune");
|
|
312511
|
-
const memoryDir =
|
|
312512
|
-
|
|
312666
|
+
const memoryDir = join88(this.repoRoot, ".oa", "memory");
|
|
312667
|
+
mkdirSync42(memoryDir, { recursive: true });
|
|
312513
312668
|
let prompt;
|
|
312514
312669
|
try {
|
|
312515
312670
|
prompt = loadPrompt3("tui/dream-consolidate.md", {
|
|
@@ -312573,8 +312728,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312573
312728
|
durationMs
|
|
312574
312729
|
});
|
|
312575
312730
|
try {
|
|
312576
|
-
|
|
312577
|
-
|
|
312731
|
+
writeFileSync39(
|
|
312732
|
+
join88(memoryDir, ".last-consolidation"),
|
|
312578
312733
|
JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), summary: result.summary?.slice(0, 500) }) + "\n"
|
|
312579
312734
|
);
|
|
312580
312735
|
} catch {
|
|
@@ -312591,8 +312746,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312591
312746
|
/** Save dream state for resume/inspection */
|
|
312592
312747
|
saveDreamState() {
|
|
312593
312748
|
try {
|
|
312594
|
-
|
|
312595
|
-
|
|
312749
|
+
writeFileSync39(
|
|
312750
|
+
join88(this.dreamsDir, "dream-state.json"),
|
|
312596
312751
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
312597
312752
|
"utf-8"
|
|
312598
312753
|
);
|
|
@@ -312962,8 +313117,8 @@ var init_bless_engine = __esm({
|
|
|
312962
313117
|
});
|
|
312963
313118
|
|
|
312964
313119
|
// packages/cli/src/tui/dmn-engine.ts
|
|
312965
|
-
import { existsSync as
|
|
312966
|
-
import { join as
|
|
313120
|
+
import { existsSync as existsSync72, readFileSync as readFileSync57, writeFileSync as writeFileSync40, mkdirSync as mkdirSync43, readdirSync as readdirSync21, unlinkSync as unlinkSync19 } from "node:fs";
|
|
313121
|
+
import { join as join89, basename as basename16 } from "node:path";
|
|
312967
313122
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
312968
313123
|
const competenceReport = competence.length > 0 ? competence.map((c7) => {
|
|
312969
313124
|
const rate = c7.attempts > 0 ? Math.round(c7.successes / c7.attempts * 100) : 0;
|
|
@@ -313068,9 +313223,9 @@ var init_dmn_engine = __esm({
|
|
|
313068
313223
|
constructor(config, repoRoot) {
|
|
313069
313224
|
this.config = config;
|
|
313070
313225
|
this.repoRoot = repoRoot;
|
|
313071
|
-
this.stateDir =
|
|
313072
|
-
this.historyDir =
|
|
313073
|
-
|
|
313226
|
+
this.stateDir = join89(repoRoot, ".oa", "dmn");
|
|
313227
|
+
this.historyDir = join89(repoRoot, ".oa", "dmn", "cycles");
|
|
313228
|
+
mkdirSync43(this.historyDir, { recursive: true });
|
|
313074
313229
|
this.loadState();
|
|
313075
313230
|
}
|
|
313076
313231
|
state = {
|
|
@@ -313704,11 +313859,11 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313704
313859
|
async gatherMemoryTopics() {
|
|
313705
313860
|
const topics = [];
|
|
313706
313861
|
const dirs = [
|
|
313707
|
-
|
|
313708
|
-
|
|
313862
|
+
join89(this.repoRoot, ".oa", "memory"),
|
|
313863
|
+
join89(this.repoRoot, ".open-agents", "memory")
|
|
313709
313864
|
];
|
|
313710
313865
|
for (const dir of dirs) {
|
|
313711
|
-
if (!
|
|
313866
|
+
if (!existsSync72(dir)) continue;
|
|
313712
313867
|
try {
|
|
313713
313868
|
const files = readdirSync21(dir).filter((f2) => f2.endsWith(".json"));
|
|
313714
313869
|
for (const f2 of files) {
|
|
@@ -313722,8 +313877,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313722
313877
|
}
|
|
313723
313878
|
// ── State persistence ─────────────────────────────────────────────────
|
|
313724
313879
|
loadState() {
|
|
313725
|
-
const path5 =
|
|
313726
|
-
if (
|
|
313880
|
+
const path5 = join89(this.stateDir, "state.json");
|
|
313881
|
+
if (existsSync72(path5)) {
|
|
313727
313882
|
try {
|
|
313728
313883
|
this.state = JSON.parse(readFileSync57(path5, "utf-8"));
|
|
313729
313884
|
} catch {
|
|
@@ -313732,8 +313887,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313732
313887
|
}
|
|
313733
313888
|
saveState() {
|
|
313734
313889
|
try {
|
|
313735
|
-
|
|
313736
|
-
|
|
313890
|
+
writeFileSync40(
|
|
313891
|
+
join89(this.stateDir, "state.json"),
|
|
313737
313892
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
313738
313893
|
"utf-8"
|
|
313739
313894
|
);
|
|
@@ -313743,8 +313898,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313743
313898
|
saveCycleResult(result) {
|
|
313744
313899
|
try {
|
|
313745
313900
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
313746
|
-
|
|
313747
|
-
|
|
313901
|
+
writeFileSync40(
|
|
313902
|
+
join89(this.historyDir, filename),
|
|
313748
313903
|
JSON.stringify(result, null, 2) + "\n",
|
|
313749
313904
|
"utf-8"
|
|
313750
313905
|
);
|
|
@@ -313752,7 +313907,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313752
313907
|
if (files.length > 50) {
|
|
313753
313908
|
for (const old of files.slice(0, files.length - 50)) {
|
|
313754
313909
|
try {
|
|
313755
|
-
unlinkSync19(
|
|
313910
|
+
unlinkSync19(join89(this.historyDir, old));
|
|
313756
313911
|
} catch {
|
|
313757
313912
|
}
|
|
313758
313913
|
}
|
|
@@ -313765,8 +313920,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313765
313920
|
});
|
|
313766
313921
|
|
|
313767
313922
|
// packages/cli/src/tui/snr-engine.ts
|
|
313768
|
-
import { existsSync as
|
|
313769
|
-
import { join as
|
|
313923
|
+
import { existsSync as existsSync73, readdirSync as readdirSync22, readFileSync as readFileSync58 } from "node:fs";
|
|
313924
|
+
import { join as join90, basename as basename17 } from "node:path";
|
|
313770
313925
|
function computeDPrime(signalScores, noiseScores) {
|
|
313771
313926
|
if (signalScores.length === 0 || noiseScores.length === 0) return 0;
|
|
313772
313927
|
const mean = (arr) => arr.reduce((s2, v) => s2 + v, 0) / arr.length;
|
|
@@ -314050,18 +314205,18 @@ Call task_complete with the JSON array when done.`,
|
|
|
314050
314205
|
loadMemoryEntries(topics) {
|
|
314051
314206
|
const entries = [];
|
|
314052
314207
|
const dirs = [
|
|
314053
|
-
|
|
314054
|
-
|
|
314208
|
+
join90(this.repoRoot, ".oa", "memory"),
|
|
314209
|
+
join90(this.repoRoot, ".open-agents", "memory")
|
|
314055
314210
|
];
|
|
314056
314211
|
for (const dir of dirs) {
|
|
314057
|
-
if (!
|
|
314212
|
+
if (!existsSync73(dir)) continue;
|
|
314058
314213
|
try {
|
|
314059
314214
|
const files = readdirSync22(dir).filter((f2) => f2.endsWith(".json"));
|
|
314060
314215
|
for (const f2 of files) {
|
|
314061
314216
|
const topic = basename17(f2, ".json");
|
|
314062
314217
|
if (topics.length > 0 && !topics.includes(topic)) continue;
|
|
314063
314218
|
try {
|
|
314064
|
-
const data = JSON.parse(readFileSync58(
|
|
314219
|
+
const data = JSON.parse(readFileSync58(join90(dir, f2), "utf-8"));
|
|
314065
314220
|
for (const [key, val] of Object.entries(data)) {
|
|
314066
314221
|
const value2 = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
314067
314222
|
entries.push({ topic, key, value: value2 });
|
|
@@ -314605,8 +314760,8 @@ var init_tool_policy = __esm({
|
|
|
314605
314760
|
});
|
|
314606
314761
|
|
|
314607
314762
|
// packages/cli/src/tui/telegram-bridge.ts
|
|
314608
|
-
import { mkdirSync as
|
|
314609
|
-
import { join as
|
|
314763
|
+
import { mkdirSync as mkdirSync44, unlinkSync as unlinkSync20 } from "node:fs";
|
|
314764
|
+
import { join as join91, resolve as resolve33 } from "node:path";
|
|
314610
314765
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
314611
314766
|
function convertMarkdownToTelegramHTML(md) {
|
|
314612
314767
|
let html = md;
|
|
@@ -314929,7 +315084,7 @@ with summary "no_reply" to silently skip without responding.
|
|
|
314929
315084
|
this.polling = true;
|
|
314930
315085
|
this.abortController = new AbortController();
|
|
314931
315086
|
try {
|
|
314932
|
-
|
|
315087
|
+
mkdirSync44(this.mediaCacheDir, { recursive: true });
|
|
314933
315088
|
} catch {
|
|
314934
315089
|
}
|
|
314935
315090
|
this.mediaCacheCleanupTimer = setInterval(() => this.cleanupMediaCache(), 5 * 60 * 1e3);
|
|
@@ -315362,7 +315517,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
|
|
|
315362
315517
|
if (!res.ok) return null;
|
|
315363
315518
|
const buffer2 = Buffer.from(await res.arrayBuffer());
|
|
315364
315519
|
const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension2}`;
|
|
315365
|
-
const localPath =
|
|
315520
|
+
const localPath = join91(this.mediaCacheDir, fileName);
|
|
315366
315521
|
await writeFileAsync(localPath, buffer2);
|
|
315367
315522
|
return localPath;
|
|
315368
315523
|
} catch {
|
|
@@ -315825,43 +315980,43 @@ __export(chat_session_exports, {
|
|
|
315825
315980
|
});
|
|
315826
315981
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
315827
315982
|
import {
|
|
315828
|
-
existsSync as
|
|
315983
|
+
existsSync as existsSync75,
|
|
315829
315984
|
readFileSync as readFileSync59,
|
|
315830
315985
|
readdirSync as readdirSync24,
|
|
315831
|
-
writeFileSync as
|
|
315986
|
+
writeFileSync as writeFileSync41,
|
|
315832
315987
|
renameSync as renameSync4,
|
|
315833
|
-
mkdirSync as
|
|
315988
|
+
mkdirSync as mkdirSync45,
|
|
315834
315989
|
unlinkSync as unlinkSync21
|
|
315835
315990
|
} from "node:fs";
|
|
315836
|
-
import { join as
|
|
315837
|
-
import { homedir as
|
|
315991
|
+
import { join as join92 } from "node:path";
|
|
315992
|
+
import { homedir as homedir33 } from "node:os";
|
|
315838
315993
|
function sessionsDir() {
|
|
315839
|
-
return
|
|
315994
|
+
return join92(homedir33(), ".open-agents", "chat-sessions");
|
|
315840
315995
|
}
|
|
315841
315996
|
function sessionPath(id) {
|
|
315842
315997
|
const safe = id.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
315843
|
-
return
|
|
315998
|
+
return join92(sessionsDir(), `${safe}.json`);
|
|
315844
315999
|
}
|
|
315845
316000
|
function inFlightPath(id) {
|
|
315846
316001
|
const safe = id.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
315847
|
-
return
|
|
316002
|
+
return join92(sessionsDir(), `${safe}.inflight.json`);
|
|
315848
316003
|
}
|
|
315849
316004
|
function persistSession(s2) {
|
|
315850
316005
|
try {
|
|
315851
|
-
|
|
316006
|
+
mkdirSync45(sessionsDir(), { recursive: true });
|
|
315852
316007
|
const final2 = sessionPath(s2.id);
|
|
315853
316008
|
const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
|
|
315854
|
-
|
|
316009
|
+
writeFileSync41(tmp, JSON.stringify(s2, null, 2), "utf-8");
|
|
315855
316010
|
renameSync4(tmp, final2);
|
|
315856
316011
|
} catch {
|
|
315857
316012
|
}
|
|
315858
316013
|
}
|
|
315859
316014
|
function persistInFlight(j) {
|
|
315860
316015
|
try {
|
|
315861
|
-
|
|
316016
|
+
mkdirSync45(sessionsDir(), { recursive: true });
|
|
315862
316017
|
const final2 = inFlightPath(j.sessionId);
|
|
315863
316018
|
const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
|
|
315864
|
-
|
|
316019
|
+
writeFileSync41(tmp, JSON.stringify(j, null, 2), "utf-8");
|
|
315865
316020
|
renameSync4(tmp, final2);
|
|
315866
316021
|
} catch {
|
|
315867
316022
|
}
|
|
@@ -315869,7 +316024,7 @@ function persistInFlight(j) {
|
|
|
315869
316024
|
function deleteInFlightFile(id) {
|
|
315870
316025
|
try {
|
|
315871
316026
|
const p2 = inFlightPath(id);
|
|
315872
|
-
if (
|
|
316027
|
+
if (existsSync75(p2)) unlinkSync21(p2);
|
|
315873
316028
|
} catch {
|
|
315874
316029
|
}
|
|
315875
316030
|
}
|
|
@@ -315877,11 +316032,11 @@ function loadPersistedSessions() {
|
|
|
315877
316032
|
const report = { restored: 0, staleInFlight: 0 };
|
|
315878
316033
|
try {
|
|
315879
316034
|
const dir = sessionsDir();
|
|
315880
|
-
if (!
|
|
316035
|
+
if (!existsSync75(dir)) return report;
|
|
315881
316036
|
const cutoff = Date.now() - SESSION_TTL_MS;
|
|
315882
316037
|
for (const f2 of readdirSync24(dir)) {
|
|
315883
316038
|
if (!f2.endsWith(".json") || f2.includes(".tmp.")) continue;
|
|
315884
|
-
const fp =
|
|
316039
|
+
const fp = join92(dir, f2);
|
|
315885
316040
|
try {
|
|
315886
316041
|
const parsed = JSON.parse(readFileSync59(fp, "utf-8"));
|
|
315887
316042
|
if (f2.endsWith(".inflight.json")) {
|
|
@@ -315893,7 +316048,7 @@ function loadPersistedSessions() {
|
|
|
315893
316048
|
parsed.error = "Daemon restart while subprocess was running";
|
|
315894
316049
|
parsed.completedAt = Date.now();
|
|
315895
316050
|
try {
|
|
315896
|
-
|
|
316051
|
+
writeFileSync41(fp, JSON.stringify(parsed, null, 2), "utf-8");
|
|
315897
316052
|
} catch {
|
|
315898
316053
|
}
|
|
315899
316054
|
report.staleInFlight++;
|
|
@@ -315920,23 +316075,23 @@ function buildSystemPrompt(cwd4) {
|
|
|
315920
316075
|
"You are Open Agent (OA), an AI coding assistant running locally via Ollama. You have access to the user's workspace and can discuss code, files, and projects. Be helpful, concise, and technically precise. When asked about files or code, describe what you know from the conversation context."
|
|
315921
316076
|
);
|
|
315922
316077
|
parts.push(`\\nEnvironment: ${process.platform}, Node ${process.version}, CWD: ${cwd4}`);
|
|
315923
|
-
const diaryPath =
|
|
315924
|
-
if (
|
|
316078
|
+
const diaryPath = join92(cwd4, ".oa", "context", "session-diary.md");
|
|
316079
|
+
if (existsSync75(diaryPath)) {
|
|
315925
316080
|
try {
|
|
315926
316081
|
const diary = readFileSync59(diaryPath, "utf-8").slice(0, 1e3);
|
|
315927
316082
|
parts.push(`\\nPrevious session history:\\n${diary}`);
|
|
315928
316083
|
} catch {
|
|
315929
316084
|
}
|
|
315930
316085
|
}
|
|
315931
|
-
const memDir =
|
|
315932
|
-
if (
|
|
316086
|
+
const memDir = join92(cwd4, ".oa", "memory");
|
|
316087
|
+
if (existsSync75(memDir)) {
|
|
315933
316088
|
try {
|
|
315934
316089
|
const files = readdirSync24(memDir).filter((f2) => f2.endsWith(".json")).slice(0, 5);
|
|
315935
316090
|
if (files.length > 0) {
|
|
315936
316091
|
parts.push("\\nPersistent memory topics: " + files.map((f2) => f2.replace(".json", "")).join(", "));
|
|
315937
316092
|
for (const f2 of files.slice(0, 3)) {
|
|
315938
316093
|
try {
|
|
315939
|
-
const data = JSON.parse(readFileSync59(
|
|
316094
|
+
const data = JSON.parse(readFileSync59(join92(memDir, f2), "utf-8"));
|
|
315940
316095
|
const entries = Object.entries(data).slice(0, 3);
|
|
315941
316096
|
if (entries.length > 0) {
|
|
315942
316097
|
parts.push(`\\nMemory [${f2.replace(".json", "")}]: ` + entries.map(([k, v]) => `${k}: ${String(v.value ?? v).slice(0, 100)}`).join("; "));
|
|
@@ -315949,8 +316104,8 @@ function buildSystemPrompt(cwd4) {
|
|
|
315949
316104
|
}
|
|
315950
316105
|
}
|
|
315951
316106
|
for (const name11 of ["AGENTS.md", "OA.md", ".open-agents.md"]) {
|
|
315952
|
-
const p2 =
|
|
315953
|
-
if (
|
|
316107
|
+
const p2 = join92(cwd4, name11);
|
|
316108
|
+
if (existsSync75(p2)) {
|
|
315954
316109
|
try {
|
|
315955
316110
|
const content = readFileSync59(p2, "utf-8").slice(0, 500);
|
|
315956
316111
|
parts.push(`\\nProject instructions (${name11}):\\n${content}`);
|
|
@@ -315969,7 +316124,7 @@ function getSession(sessionId, model, cwd4) {
|
|
|
315969
316124
|
if (sessionId) {
|
|
315970
316125
|
try {
|
|
315971
316126
|
const fp = sessionPath(sessionId);
|
|
315972
|
-
if (
|
|
316127
|
+
if (existsSync75(fp)) {
|
|
315973
316128
|
const parsed = JSON.parse(readFileSync59(fp, "utf-8"));
|
|
315974
316129
|
if (parsed && parsed.id === sessionId) {
|
|
315975
316130
|
parsed.lastActivity = Date.now();
|
|
@@ -316072,11 +316227,11 @@ function addTriageResponseMessage(session, acknowledgment, steering) {
|
|
|
316072
316227
|
}
|
|
316073
316228
|
function checkinPath(sessionId) {
|
|
316074
316229
|
const safe = sessionId.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
316075
|
-
return
|
|
316230
|
+
return join92(sessionsDir(), `${safe}.checkins.jsonl`);
|
|
316076
316231
|
}
|
|
316077
316232
|
function appendCheckin(sessionId, steering) {
|
|
316078
316233
|
try {
|
|
316079
|
-
|
|
316234
|
+
mkdirSync45(sessionsDir(), { recursive: true });
|
|
316080
316235
|
const fp = checkinPath(sessionId);
|
|
316081
316236
|
const entry = JSON.stringify({ ts: Date.now(), steering }) + "\n";
|
|
316082
316237
|
const { appendFileSync: appendFileSync7 } = __require("node:fs");
|
|
@@ -316086,7 +316241,7 @@ function appendCheckin(sessionId, steering) {
|
|
|
316086
316241
|
}
|
|
316087
316242
|
function drainCheckins(sessionId) {
|
|
316088
316243
|
const fp = checkinPath(sessionId);
|
|
316089
|
-
if (!
|
|
316244
|
+
if (!existsSync75(fp)) return [];
|
|
316090
316245
|
try {
|
|
316091
316246
|
const raw = readFileSync59(fp, "utf-8");
|
|
316092
316247
|
try {
|
|
@@ -316128,7 +316283,7 @@ function listSessions2() {
|
|
|
316128
316283
|
function deleteSession2(id) {
|
|
316129
316284
|
try {
|
|
316130
316285
|
const p2 = sessionPath(id);
|
|
316131
|
-
if (
|
|
316286
|
+
if (existsSync75(p2)) unlinkSync21(p2);
|
|
316132
316287
|
} catch {
|
|
316133
316288
|
}
|
|
316134
316289
|
deleteInFlightFile(id);
|
|
@@ -316140,7 +316295,7 @@ function lookupSession(id) {
|
|
|
316140
316295
|
if (cached) return cached;
|
|
316141
316296
|
try {
|
|
316142
316297
|
const fp = sessionPath(id);
|
|
316143
|
-
if (
|
|
316298
|
+
if (existsSync75(fp)) {
|
|
316144
316299
|
const parsed = JSON.parse(readFileSync59(fp, "utf-8"));
|
|
316145
316300
|
if (parsed && parsed.id === id) {
|
|
316146
316301
|
sessions.set(id, parsed);
|
|
@@ -316193,7 +316348,7 @@ function getInFlightChat(sessionId) {
|
|
|
316193
316348
|
if (cached) return cached;
|
|
316194
316349
|
try {
|
|
316195
316350
|
const p2 = inFlightPath(sessionId);
|
|
316196
|
-
if (
|
|
316351
|
+
if (existsSync75(p2)) {
|
|
316197
316352
|
const parsed = JSON.parse(readFileSync59(p2, "utf-8"));
|
|
316198
316353
|
if (parsed && parsed.sessionId === sessionId) {
|
|
316199
316354
|
return parsed;
|
|
@@ -316839,13 +316994,13 @@ __export(audit_log_exports, {
|
|
|
316839
316994
|
recordAudit: () => recordAudit,
|
|
316840
316995
|
sanitizeBody: () => sanitizeBody
|
|
316841
316996
|
});
|
|
316842
|
-
import { mkdirSync as
|
|
316843
|
-
import { join as
|
|
316997
|
+
import { mkdirSync as mkdirSync46, appendFileSync as appendFileSync5, readFileSync as readFileSync60, existsSync as existsSync76 } from "node:fs";
|
|
316998
|
+
import { join as join93 } from "node:path";
|
|
316844
316999
|
function initAuditLog(oaDir) {
|
|
316845
|
-
auditDir =
|
|
316846
|
-
auditFile =
|
|
317000
|
+
auditDir = join93(oaDir, "audit");
|
|
317001
|
+
auditFile = join93(auditDir, "audit.jsonl");
|
|
316847
317002
|
try {
|
|
316848
|
-
|
|
317003
|
+
mkdirSync46(auditDir, { recursive: true });
|
|
316849
317004
|
initialized = true;
|
|
316850
317005
|
} catch {
|
|
316851
317006
|
}
|
|
@@ -316874,7 +317029,7 @@ function sanitizeBody(body, maxLen = 200) {
|
|
|
316874
317029
|
return safe.length > maxLen ? safe.slice(0, maxLen) + "..." : safe;
|
|
316875
317030
|
}
|
|
316876
317031
|
function queryAudit(opts) {
|
|
316877
|
-
if (!initialized || !
|
|
317032
|
+
if (!initialized || !existsSync76(auditFile)) return [];
|
|
316878
317033
|
try {
|
|
316879
317034
|
const raw = readFileSync60(auditFile, "utf-8");
|
|
316880
317035
|
const lines = raw.split("\n").filter(Boolean);
|
|
@@ -316913,7 +317068,7 @@ var init_audit_log = __esm({
|
|
|
316913
317068
|
|
|
316914
317069
|
// packages/cli/src/api/disk-task-output.ts
|
|
316915
317070
|
import { open } from "node:fs/promises";
|
|
316916
|
-
import { existsSync as
|
|
317071
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync47, statSync as statSync21 } from "node:fs";
|
|
316917
317072
|
import { dirname as dirname27 } from "node:path";
|
|
316918
317073
|
import * as fsConstants from "node:constants";
|
|
316919
317074
|
var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
|
|
@@ -316933,7 +317088,7 @@ var init_disk_task_output = __esm({
|
|
|
316933
317088
|
fileSize = 0;
|
|
316934
317089
|
constructor(outputPath) {
|
|
316935
317090
|
this.path = outputPath;
|
|
316936
|
-
|
|
317091
|
+
mkdirSync47(dirname27(outputPath), { recursive: true });
|
|
316937
317092
|
}
|
|
316938
317093
|
/** Queue content for async append. Non-blocking. */
|
|
316939
317094
|
append(chunk) {
|
|
@@ -317009,7 +317164,7 @@ var init_disk_task_output = __esm({
|
|
|
317009
317164
|
async readFrom(offset, limit = 65536) {
|
|
317010
317165
|
let handle2 = null;
|
|
317011
317166
|
try {
|
|
317012
|
-
if (!
|
|
317167
|
+
if (!existsSync77(this.path)) {
|
|
317013
317168
|
return { content: "", nextOffset: offset, eof: true, size: 0 };
|
|
317014
317169
|
}
|
|
317015
317170
|
const st = statSync21(this.path);
|
|
@@ -317211,19 +317366,19 @@ __export(aiwg_exports, {
|
|
|
317211
317366
|
resolveAiwgRoot: () => resolveAiwgRoot,
|
|
317212
317367
|
tryRouteAiwg: () => tryRouteAiwg
|
|
317213
317368
|
});
|
|
317214
|
-
import { existsSync as
|
|
317215
|
-
import { join as
|
|
317216
|
-
import { homedir as
|
|
317369
|
+
import { existsSync as existsSync78, readFileSync as readFileSync61, readdirSync as readdirSync25, statSync as statSync22 } from "node:fs";
|
|
317370
|
+
import { join as join94 } from "node:path";
|
|
317371
|
+
import { homedir as homedir34 } from "node:os";
|
|
317217
317372
|
import { execSync as execSync53 } from "node:child_process";
|
|
317218
317373
|
function resolveAiwgRoot() {
|
|
317219
317374
|
if (_cachedAiwgRoot !== void 0) return _cachedAiwgRoot;
|
|
317220
317375
|
const envRoot = process.env["OA_AIWG_ROOT"];
|
|
317221
|
-
if (envRoot &&
|
|
317376
|
+
if (envRoot && existsSync78(join94(envRoot, "package.json"))) {
|
|
317222
317377
|
_cachedAiwgRoot = envRoot;
|
|
317223
317378
|
return envRoot;
|
|
317224
317379
|
}
|
|
317225
|
-
const shareDir =
|
|
317226
|
-
if (
|
|
317380
|
+
const shareDir = join94(homedir34(), ".local", "share", "ai-writing-guide");
|
|
317381
|
+
if (existsSync78(join94(shareDir, "agentic"))) {
|
|
317227
317382
|
_cachedAiwgRoot = shareDir;
|
|
317228
317383
|
return shareDir;
|
|
317229
317384
|
}
|
|
@@ -317233,8 +317388,8 @@ function resolveAiwgRoot() {
|
|
|
317233
317388
|
timeout: 5e3,
|
|
317234
317389
|
stdio: ["pipe", "pipe", "pipe"]
|
|
317235
317390
|
}).trim();
|
|
317236
|
-
const candidate =
|
|
317237
|
-
if (
|
|
317391
|
+
const candidate = join94(globalRoot, "aiwg");
|
|
317392
|
+
if (existsSync78(join94(candidate, "package.json"))) {
|
|
317238
317393
|
_cachedAiwgRoot = candidate;
|
|
317239
317394
|
return candidate;
|
|
317240
317395
|
}
|
|
@@ -317245,22 +317400,22 @@ function resolveAiwgRoot() {
|
|
|
317245
317400
|
"/usr/lib/node_modules/aiwg",
|
|
317246
317401
|
"/opt/homebrew/lib/node_modules/aiwg"
|
|
317247
317402
|
]) {
|
|
317248
|
-
if (
|
|
317403
|
+
if (existsSync78(join94(p2, "package.json"))) {
|
|
317249
317404
|
_cachedAiwgRoot = p2;
|
|
317250
317405
|
return p2;
|
|
317251
317406
|
}
|
|
317252
317407
|
}
|
|
317253
317408
|
const versionDirs = [
|
|
317254
|
-
|
|
317255
|
-
|
|
317409
|
+
join94(homedir34(), ".nvm", "versions", "node"),
|
|
317410
|
+
join94(homedir34(), ".local", "share", "fnm", "node-versions")
|
|
317256
317411
|
];
|
|
317257
317412
|
for (const vdir of versionDirs) {
|
|
317258
|
-
if (!
|
|
317413
|
+
if (!existsSync78(vdir)) continue;
|
|
317259
317414
|
try {
|
|
317260
317415
|
for (const ver of readdirSync25(vdir)) {
|
|
317261
317416
|
for (const prefix of ["lib/node_modules/aiwg", "installation/lib/node_modules/aiwg"]) {
|
|
317262
|
-
const cand =
|
|
317263
|
-
if (
|
|
317417
|
+
const cand = join94(vdir, ver, prefix);
|
|
317418
|
+
if (existsSync78(join94(cand, "package.json"))) {
|
|
317264
317419
|
_cachedAiwgRoot = cand;
|
|
317265
317420
|
return cand;
|
|
317266
317421
|
}
|
|
@@ -317278,9 +317433,9 @@ function resolveAiwgRoot() {
|
|
|
317278
317433
|
if (whichAiwg) {
|
|
317279
317434
|
let cur = whichAiwg;
|
|
317280
317435
|
for (let i2 = 0; i2 < 8; i2++) {
|
|
317281
|
-
cur =
|
|
317282
|
-
const pj =
|
|
317283
|
-
if (
|
|
317436
|
+
cur = join94(cur, "..");
|
|
317437
|
+
const pj = join94(cur, "package.json");
|
|
317438
|
+
if (existsSync78(pj)) {
|
|
317284
317439
|
try {
|
|
317285
317440
|
const pkg = JSON.parse(readFileSync61(pj, "utf-8"));
|
|
317286
317441
|
if (pkg.name === "aiwg") {
|
|
@@ -317304,14 +317459,14 @@ function listAiwgFrameworks() {
|
|
|
317304
317459
|
_cachedFrameworks = [];
|
|
317305
317460
|
return _cachedFrameworks;
|
|
317306
317461
|
}
|
|
317307
|
-
const frameworksDir =
|
|
317308
|
-
if (!
|
|
317462
|
+
const frameworksDir = join94(root, "agentic", "code", "frameworks");
|
|
317463
|
+
if (!existsSync78(frameworksDir)) {
|
|
317309
317464
|
_cachedFrameworks = [];
|
|
317310
317465
|
return _cachedFrameworks;
|
|
317311
317466
|
}
|
|
317312
317467
|
const out = [];
|
|
317313
317468
|
for (const name11 of readdirSync25(frameworksDir)) {
|
|
317314
|
-
const p2 =
|
|
317469
|
+
const p2 = join94(frameworksDir, name11);
|
|
317315
317470
|
try {
|
|
317316
317471
|
const st = statSync22(p2);
|
|
317317
317472
|
if (!st.isDirectory()) continue;
|
|
@@ -317339,7 +317494,7 @@ function aggregateDir(dir, depth = 0) {
|
|
|
317339
317494
|
try {
|
|
317340
317495
|
for (const e2 of readdirSync25(dir, { withFileTypes: true })) {
|
|
317341
317496
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
317342
|
-
const p2 =
|
|
317497
|
+
const p2 = join94(dir, e2.name);
|
|
317343
317498
|
if (e2.isDirectory()) {
|
|
317344
317499
|
const sub = aggregateDir(p2, depth + 1);
|
|
317345
317500
|
out.files += sub.files;
|
|
@@ -317369,8 +317524,8 @@ function aggregateDir(dir, depth = 0) {
|
|
|
317369
317524
|
}
|
|
317370
317525
|
function readFirstLineDescription(dir) {
|
|
317371
317526
|
for (const candidate of ["README.md", "SKILL.md", "INDEX.md"]) {
|
|
317372
|
-
const p2 =
|
|
317373
|
-
if (!
|
|
317527
|
+
const p2 = join94(dir, candidate);
|
|
317528
|
+
if (!existsSync78(p2)) continue;
|
|
317374
317529
|
try {
|
|
317375
317530
|
const txt = readFileSync61(p2, "utf-8");
|
|
317376
317531
|
const descMatch = txt.match(/^description:\s*(.+)$/m);
|
|
@@ -317394,12 +317549,12 @@ function listAiwgItems() {
|
|
|
317394
317549
|
}
|
|
317395
317550
|
const out = [];
|
|
317396
317551
|
const walkRoots = [
|
|
317397
|
-
|
|
317398
|
-
|
|
317399
|
-
|
|
317552
|
+
join94(root, "agentic", "code", "frameworks"),
|
|
317553
|
+
join94(root, "agentic", "code", "addons"),
|
|
317554
|
+
join94(root, "plugins")
|
|
317400
317555
|
];
|
|
317401
317556
|
for (const wr of walkRoots) {
|
|
317402
|
-
if (!
|
|
317557
|
+
if (!existsSync78(wr)) continue;
|
|
317403
317558
|
walkForItems(wr, out, 0);
|
|
317404
317559
|
}
|
|
317405
317560
|
_cachedItems = out;
|
|
@@ -317410,7 +317565,7 @@ function walkForItems(dir, out, depth) {
|
|
|
317410
317565
|
try {
|
|
317411
317566
|
for (const e2 of readdirSync25(dir, { withFileTypes: true })) {
|
|
317412
317567
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
317413
|
-
const p2 =
|
|
317568
|
+
const p2 = join94(dir, e2.name);
|
|
317414
317569
|
if (e2.isDirectory()) {
|
|
317415
317570
|
walkForItems(p2, out, depth + 1);
|
|
317416
317571
|
} else if (e2.isFile() && e2.name.endsWith(".md")) {
|
|
@@ -317461,7 +317616,7 @@ function deriveSource(p2) {
|
|
|
317461
317616
|
}
|
|
317462
317617
|
function loadAiwgItemContent(path5, maxBytes = 2e4) {
|
|
317463
317618
|
try {
|
|
317464
|
-
if (!
|
|
317619
|
+
if (!existsSync78(path5)) return null;
|
|
317465
317620
|
const raw = readFileSync61(path5, "utf-8");
|
|
317466
317621
|
return raw.length > maxBytes ? raw.slice(0, maxBytes) + "\n\n...(truncated for context budget)" : raw;
|
|
317467
317622
|
} catch {
|
|
@@ -317475,14 +317630,14 @@ function listAiwgAddons() {
|
|
|
317475
317630
|
_cachedAddons = [];
|
|
317476
317631
|
return _cachedAddons;
|
|
317477
317632
|
}
|
|
317478
|
-
const addonsDir =
|
|
317479
|
-
if (!
|
|
317633
|
+
const addonsDir = join94(root, "agentic", "code", "addons");
|
|
317634
|
+
if (!existsSync78(addonsDir)) {
|
|
317480
317635
|
_cachedAddons = [];
|
|
317481
317636
|
return _cachedAddons;
|
|
317482
317637
|
}
|
|
317483
317638
|
const out = [];
|
|
317484
317639
|
for (const name11 of readdirSync25(addonsDir)) {
|
|
317485
|
-
const p2 =
|
|
317640
|
+
const p2 = join94(addonsDir, name11);
|
|
317486
317641
|
try {
|
|
317487
317642
|
const st = statSync22(p2);
|
|
317488
317643
|
if (!st.isDirectory()) continue;
|
|
@@ -317964,9 +318119,9 @@ var init_aiwg = __esm({
|
|
|
317964
318119
|
});
|
|
317965
318120
|
|
|
317966
318121
|
// packages/cli/src/api/routes-v1.ts
|
|
317967
|
-
import { existsSync as
|
|
317968
|
-
import { join as
|
|
317969
|
-
import { homedir as
|
|
318122
|
+
import { existsSync as existsSync79, readFileSync as readFileSync62, readdirSync as readdirSync26, statSync as statSync23 } from "node:fs";
|
|
318123
|
+
import { join as join95, resolve as pathResolve } from "node:path";
|
|
318124
|
+
import { homedir as homedir35 } from "node:os";
|
|
317970
318125
|
async function tryRouteV1(ctx3) {
|
|
317971
318126
|
const { pathname, method } = ctx3;
|
|
317972
318127
|
if (pathname === "/v1/skills" && method === "GET") {
|
|
@@ -318171,11 +318326,11 @@ async function handleGetSkill(ctx3, name11) {
|
|
|
318171
318326
|
async function fallbackDiscoverSkills() {
|
|
318172
318327
|
return (_root) => {
|
|
318173
318328
|
const roots = [
|
|
318174
|
-
|
|
318329
|
+
join95(homedir35(), ".local", "share", "ai-writing-guide")
|
|
318175
318330
|
];
|
|
318176
318331
|
const out = [];
|
|
318177
318332
|
for (const root of roots) {
|
|
318178
|
-
if (!
|
|
318333
|
+
if (!existsSync79(root)) continue;
|
|
318179
318334
|
walkForSkills(root, out, 0);
|
|
318180
318335
|
}
|
|
318181
318336
|
return out;
|
|
@@ -318186,7 +318341,7 @@ function walkForSkills(dir, out, depth) {
|
|
|
318186
318341
|
try {
|
|
318187
318342
|
for (const e2 of readdirSync26(dir, { withFileTypes: true })) {
|
|
318188
318343
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
318189
|
-
const p2 =
|
|
318344
|
+
const p2 = join95(dir, e2.name);
|
|
318190
318345
|
if (e2.isDirectory()) {
|
|
318191
318346
|
walkForSkills(p2, out, depth + 1);
|
|
318192
318347
|
} else if (e2.isFile() && e2.name === "SKILL.md") {
|
|
@@ -318375,7 +318530,7 @@ async function getMemoryStores() {
|
|
|
318375
318530
|
if (memoryInitTried) return null;
|
|
318376
318531
|
memoryInitTried = true;
|
|
318377
318532
|
try {
|
|
318378
|
-
const dbPath =
|
|
318533
|
+
const dbPath = join95(homedir35(), ".open-agents", "memory.db");
|
|
318379
318534
|
const sharedDb = initDb(dbPath);
|
|
318380
318535
|
memoryStoresCache = {
|
|
318381
318536
|
episode: new EpisodeStore(dbPath),
|
|
@@ -318633,7 +318788,7 @@ async function handleFilesRead(ctx3) {
|
|
|
318633
318788
|
}));
|
|
318634
318789
|
return true;
|
|
318635
318790
|
}
|
|
318636
|
-
if (!
|
|
318791
|
+
if (!existsSync79(resolved)) {
|
|
318637
318792
|
sendProblem(res, problemDetails({
|
|
318638
318793
|
type: P.notFound,
|
|
318639
318794
|
status: 404,
|
|
@@ -318896,12 +319051,12 @@ async function handleNexusStatus(ctx3) {
|
|
|
318896
319051
|
const { res, requestId } = ctx3;
|
|
318897
319052
|
try {
|
|
318898
319053
|
const statePaths = [
|
|
318899
|
-
|
|
318900
|
-
|
|
319054
|
+
join95(process.cwd(), ".oa", "nexus-peer-state.json"),
|
|
319055
|
+
join95(homedir35(), ".open-agents", "nexus-peer-cache.json")
|
|
318901
319056
|
];
|
|
318902
319057
|
const states = [];
|
|
318903
319058
|
for (const p2 of statePaths) {
|
|
318904
|
-
if (!
|
|
319059
|
+
if (!existsSync79(p2)) continue;
|
|
318905
319060
|
try {
|
|
318906
319061
|
const raw = readFileSync62(p2, "utf-8");
|
|
318907
319062
|
states.push({ source: p2, data: JSON.parse(raw) });
|
|
@@ -318930,8 +319085,8 @@ async function handleNexusStatus(ctx3) {
|
|
|
318930
319085
|
}
|
|
318931
319086
|
function loadAgentName() {
|
|
318932
319087
|
try {
|
|
318933
|
-
const p2 =
|
|
318934
|
-
if (
|
|
319088
|
+
const p2 = join95(homedir35(), ".open-agents", "agent-name");
|
|
319089
|
+
if (existsSync79(p2)) return readFileSync62(p2, "utf-8").trim();
|
|
318935
319090
|
} catch {
|
|
318936
319091
|
}
|
|
318937
319092
|
return null;
|
|
@@ -318940,12 +319095,12 @@ async function handleSponsors(ctx3) {
|
|
|
318940
319095
|
const { req: req2, res, url, requestId } = ctx3;
|
|
318941
319096
|
try {
|
|
318942
319097
|
const candidates = [
|
|
318943
|
-
|
|
318944
|
-
|
|
319098
|
+
join95(homedir35(), ".open-agents", "sponsor-cache.json"),
|
|
319099
|
+
join95(homedir35(), ".open-agents", "sponsors.json")
|
|
318945
319100
|
];
|
|
318946
319101
|
let sponsors = [];
|
|
318947
319102
|
for (const p2 of candidates) {
|
|
318948
|
-
if (!
|
|
319103
|
+
if (!existsSync79(p2)) continue;
|
|
318949
319104
|
try {
|
|
318950
319105
|
const raw = JSON.parse(readFileSync62(p2, "utf-8"));
|
|
318951
319106
|
if (Array.isArray(raw)) {
|
|
@@ -319016,8 +319171,8 @@ async function handleEvaluate(ctx3) {
|
|
|
319016
319171
|
}));
|
|
319017
319172
|
return true;
|
|
319018
319173
|
}
|
|
319019
|
-
const jobPath =
|
|
319020
|
-
if (!
|
|
319174
|
+
const jobPath = join95(process.cwd(), ".oa", "jobs", `${runId}.json`);
|
|
319175
|
+
if (!existsSync79(jobPath)) {
|
|
319021
319176
|
sendProblem(res, problemDetails({
|
|
319022
319177
|
type: P.notFound,
|
|
319023
319178
|
status: 404,
|
|
@@ -319165,17 +319320,17 @@ async function handleListAgentTypes(ctx3) {
|
|
|
319165
319320
|
}
|
|
319166
319321
|
async function handleListEngines(ctx3) {
|
|
319167
319322
|
const { res } = ctx3;
|
|
319168
|
-
const home =
|
|
319323
|
+
const home = homedir35();
|
|
319169
319324
|
sendJson(res, 200, {
|
|
319170
319325
|
engines: [
|
|
319171
|
-
{ name: "dream", state_file:
|
|
319172
|
-
{ name: "bless", state_file:
|
|
319173
|
-
{ name: "call", state_file:
|
|
319174
|
-
{ name: "listen", state_file:
|
|
319175
|
-
{ name: "telegram", state_file:
|
|
319176
|
-
{ name: "expose", state_file:
|
|
319177
|
-
{ name: "nexus", state_file:
|
|
319178
|
-
{ name: "ipfs", state_file:
|
|
319326
|
+
{ name: "dream", state_file: join95(process.cwd(), ".oa", "dreams"), controllable_via: "SSE + slash commands" },
|
|
319327
|
+
{ name: "bless", state_file: join95(process.cwd(), ".oa", "bless-state.json"), controllable_via: "slash commands" },
|
|
319328
|
+
{ name: "call", state_file: join95(process.cwd(), ".oa", "call-state.json"), controllable_via: "slash commands" },
|
|
319329
|
+
{ name: "listen", state_file: join95(process.cwd(), ".oa", "listen-state.json"), controllable_via: "slash commands" },
|
|
319330
|
+
{ name: "telegram", state_file: join95(home, ".open-agents", "telegram-state.json"), controllable_via: "slash commands" },
|
|
319331
|
+
{ name: "expose", state_file: join95(process.cwd(), ".oa", "expose-state.json"), controllable_via: "/expose commands" },
|
|
319332
|
+
{ name: "nexus", state_file: join95(home, ".open-agents", "nexus-peer-cache.json"), controllable_via: "/nexus commands" },
|
|
319333
|
+
{ name: "ipfs", state_file: join95(process.cwd(), ".oa", "ipfs"), controllable_via: "slash commands" }
|
|
319179
319334
|
],
|
|
319180
319335
|
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."
|
|
319181
319336
|
});
|
|
@@ -319258,12 +319413,12 @@ async function tryAimsRoute(ctx3) {
|
|
|
319258
319413
|
return false;
|
|
319259
319414
|
}
|
|
319260
319415
|
function aimsDir() {
|
|
319261
|
-
return
|
|
319416
|
+
return join95(homedir35(), ".open-agents", "aims");
|
|
319262
319417
|
}
|
|
319263
319418
|
function readAimsFile(name11, fallback) {
|
|
319264
319419
|
try {
|
|
319265
|
-
const p2 =
|
|
319266
|
-
if (
|
|
319420
|
+
const p2 = join95(aimsDir(), name11);
|
|
319421
|
+
if (existsSync79(p2)) return JSON.parse(readFileSync62(p2, "utf-8"));
|
|
319267
319422
|
} catch {
|
|
319268
319423
|
}
|
|
319269
319424
|
return fallback;
|
|
@@ -319272,7 +319427,7 @@ function writeAimsFile(name11, data) {
|
|
|
319272
319427
|
const dir = aimsDir();
|
|
319273
319428
|
const { mkdirSync: mkdirSync55, writeFileSync: wf, renameSync: rn } = __require("node:fs");
|
|
319274
319429
|
mkdirSync55(dir, { recursive: true });
|
|
319275
|
-
const finalPath =
|
|
319430
|
+
const finalPath = join95(dir, name11);
|
|
319276
319431
|
const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
|
|
319277
319432
|
try {
|
|
319278
319433
|
wf(tmpPath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
@@ -319602,10 +319757,10 @@ async function handleAimsSuppliers(ctx3) {
|
|
|
319602
319757
|
}
|
|
319603
319758
|
];
|
|
319604
319759
|
const sponsorPaths = [
|
|
319605
|
-
|
|
319760
|
+
join95(homedir35(), ".open-agents", "sponsor-cache.json")
|
|
319606
319761
|
];
|
|
319607
319762
|
for (const p2 of sponsorPaths) {
|
|
319608
|
-
if (!
|
|
319763
|
+
if (!existsSync79(p2)) continue;
|
|
319609
319764
|
try {
|
|
319610
319765
|
const raw = JSON.parse(readFileSync62(p2, "utf-8"));
|
|
319611
319766
|
const list = Array.isArray(raw) ? raw : raw?.sponsors ?? [];
|
|
@@ -323902,14 +324057,14 @@ var init_auth_oidc = __esm({
|
|
|
323902
324057
|
});
|
|
323903
324058
|
|
|
323904
324059
|
// packages/cli/src/api/usage-tracker.ts
|
|
323905
|
-
import { mkdirSync as
|
|
323906
|
-
import { join as
|
|
324060
|
+
import { mkdirSync as mkdirSync48, readFileSync as readFileSync63, writeFileSync as writeFileSync42, existsSync as existsSync80 } from "node:fs";
|
|
324061
|
+
import { join as join96 } from "node:path";
|
|
323907
324062
|
function initUsageTracker(oaDir) {
|
|
323908
|
-
const dir =
|
|
323909
|
-
|
|
323910
|
-
usageFile =
|
|
324063
|
+
const dir = join96(oaDir, "usage");
|
|
324064
|
+
mkdirSync48(dir, { recursive: true });
|
|
324065
|
+
usageFile = join96(dir, "token-usage.json");
|
|
323911
324066
|
try {
|
|
323912
|
-
if (
|
|
324067
|
+
if (existsSync80(usageFile)) {
|
|
323913
324068
|
store = JSON.parse(readFileSync63(usageFile, "utf-8"));
|
|
323914
324069
|
}
|
|
323915
324070
|
} catch {
|
|
@@ -323946,7 +324101,7 @@ function flush2() {
|
|
|
323946
324101
|
if (!initialized2 || !dirty) return;
|
|
323947
324102
|
try {
|
|
323948
324103
|
store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
|
|
323949
|
-
|
|
324104
|
+
writeFileSync42(usageFile, JSON.stringify(store, null, 2), "utf-8");
|
|
323950
324105
|
dirty = false;
|
|
323951
324106
|
} catch {
|
|
323952
324107
|
}
|
|
@@ -323974,24 +324129,24 @@ var init_usage_tracker = __esm({
|
|
|
323974
324129
|
});
|
|
323975
324130
|
|
|
323976
324131
|
// packages/cli/src/api/profiles.ts
|
|
323977
|
-
import { existsSync as
|
|
323978
|
-
import { join as
|
|
323979
|
-
import { homedir as
|
|
324132
|
+
import { existsSync as existsSync81, readFileSync as readFileSync64, writeFileSync as writeFileSync43, mkdirSync as mkdirSync49, readdirSync as readdirSync27, unlinkSync as unlinkSync22 } from "node:fs";
|
|
324133
|
+
import { join as join97 } from "node:path";
|
|
324134
|
+
import { homedir as homedir36 } from "node:os";
|
|
323980
324135
|
import { createCipheriv as createCipheriv4, createDecipheriv as createDecipheriv4, randomBytes as randomBytes20, scryptSync as scryptSync3 } from "node:crypto";
|
|
323981
324136
|
function globalProfileDir() {
|
|
323982
|
-
return
|
|
324137
|
+
return join97(homedir36(), ".open-agents", "profiles");
|
|
323983
324138
|
}
|
|
323984
324139
|
function projectProfileDir(projectDir) {
|
|
323985
|
-
return
|
|
324140
|
+
return join97(projectDir || process.cwd(), ".oa", "profiles");
|
|
323986
324141
|
}
|
|
323987
324142
|
function listProfiles(projectDir) {
|
|
323988
324143
|
const result = [];
|
|
323989
324144
|
const seen = /* @__PURE__ */ new Set();
|
|
323990
324145
|
const projDir = projectProfileDir(projectDir);
|
|
323991
|
-
if (
|
|
324146
|
+
if (existsSync81(projDir)) {
|
|
323992
324147
|
for (const f2 of readdirSync27(projDir).filter((f3) => f3.endsWith(".json"))) {
|
|
323993
324148
|
try {
|
|
323994
|
-
const raw = JSON.parse(readFileSync64(
|
|
324149
|
+
const raw = JSON.parse(readFileSync64(join97(projDir, f2), "utf8"));
|
|
323995
324150
|
const name11 = f2.replace(".json", "");
|
|
323996
324151
|
seen.add(name11);
|
|
323997
324152
|
result.push({
|
|
@@ -324005,12 +324160,12 @@ function listProfiles(projectDir) {
|
|
|
324005
324160
|
}
|
|
324006
324161
|
}
|
|
324007
324162
|
const globDir = globalProfileDir();
|
|
324008
|
-
if (
|
|
324163
|
+
if (existsSync81(globDir)) {
|
|
324009
324164
|
for (const f2 of readdirSync27(globDir).filter((f3) => f3.endsWith(".json"))) {
|
|
324010
324165
|
const name11 = f2.replace(".json", "");
|
|
324011
324166
|
if (seen.has(name11)) continue;
|
|
324012
324167
|
try {
|
|
324013
|
-
const raw = JSON.parse(readFileSync64(
|
|
324168
|
+
const raw = JSON.parse(readFileSync64(join97(globDir, f2), "utf8"));
|
|
324014
324169
|
result.push({
|
|
324015
324170
|
name: name11,
|
|
324016
324171
|
description: raw.description || "",
|
|
@@ -324025,9 +324180,9 @@ function listProfiles(projectDir) {
|
|
|
324025
324180
|
}
|
|
324026
324181
|
function loadProfile(name11, password, projectDir) {
|
|
324027
324182
|
const sanitized = name11.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
324028
|
-
const projPath =
|
|
324029
|
-
const globPath =
|
|
324030
|
-
const filePath =
|
|
324183
|
+
const projPath = join97(projectProfileDir(projectDir), `${sanitized}.json`);
|
|
324184
|
+
const globPath = join97(globalProfileDir(), `${sanitized}.json`);
|
|
324185
|
+
const filePath = existsSync81(projPath) ? projPath : existsSync81(globPath) ? globPath : null;
|
|
324031
324186
|
if (!filePath) return null;
|
|
324032
324187
|
const raw = JSON.parse(readFileSync64(filePath, "utf8"));
|
|
324033
324188
|
if (raw.encrypted === true) {
|
|
@@ -324038,23 +324193,23 @@ function loadProfile(name11, password, projectDir) {
|
|
|
324038
324193
|
}
|
|
324039
324194
|
function saveProfile(profile, password, scope = "global", projectDir) {
|
|
324040
324195
|
const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
|
|
324041
|
-
|
|
324196
|
+
mkdirSync49(dir, { recursive: true });
|
|
324042
324197
|
const sanitized = profile.name.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
324043
|
-
const filePath =
|
|
324198
|
+
const filePath = join97(dir, `${sanitized}.json`);
|
|
324044
324199
|
profile.modified = (/* @__PURE__ */ new Date()).toISOString();
|
|
324045
324200
|
if (password) {
|
|
324046
324201
|
const encrypted = encryptProfile(profile, password);
|
|
324047
|
-
|
|
324202
|
+
writeFileSync43(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
324048
324203
|
} else {
|
|
324049
324204
|
profile.encrypted = false;
|
|
324050
|
-
|
|
324205
|
+
writeFileSync43(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
|
|
324051
324206
|
}
|
|
324052
324207
|
}
|
|
324053
324208
|
function deleteProfile(name11, scope = "global", projectDir) {
|
|
324054
324209
|
const sanitized = name11.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
324055
324210
|
const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
|
|
324056
|
-
const filePath =
|
|
324057
|
-
if (
|
|
324211
|
+
const filePath = join97(dir, `${sanitized}.json`);
|
|
324212
|
+
if (existsSync81(filePath)) {
|
|
324058
324213
|
unlinkSync22(filePath);
|
|
324059
324214
|
return true;
|
|
324060
324215
|
}
|
|
@@ -324169,23 +324324,23 @@ var init_profiles = __esm({
|
|
|
324169
324324
|
|
|
324170
324325
|
// packages/cli/src/docker.ts
|
|
324171
324326
|
import { execSync as execSync54, spawn as spawn24 } from "node:child_process";
|
|
324172
|
-
import { existsSync as
|
|
324173
|
-
import { join as
|
|
324174
|
-
import { homedir as
|
|
324327
|
+
import { existsSync as existsSync82, mkdirSync as mkdirSync50, writeFileSync as writeFileSync44 } from "node:fs";
|
|
324328
|
+
import { join as join98, resolve as resolve34, dirname as dirname28 } from "node:path";
|
|
324329
|
+
import { homedir as homedir37 } from "node:os";
|
|
324175
324330
|
import { fileURLToPath as fileURLToPath16 } from "node:url";
|
|
324176
324331
|
function getDockerDir() {
|
|
324177
324332
|
try {
|
|
324178
324333
|
if (typeof __dirname !== "undefined") {
|
|
324179
|
-
return
|
|
324334
|
+
return join98(__dirname, "..", "..", "..", "docker");
|
|
324180
324335
|
}
|
|
324181
324336
|
} catch {
|
|
324182
324337
|
}
|
|
324183
324338
|
try {
|
|
324184
324339
|
const thisDir = dirname28(fileURLToPath16(import.meta.url));
|
|
324185
|
-
return
|
|
324340
|
+
return join98(thisDir, "..", "..", "..", "docker");
|
|
324186
324341
|
} catch {
|
|
324187
324342
|
}
|
|
324188
|
-
return
|
|
324343
|
+
return join98(process.cwd(), "docker");
|
|
324189
324344
|
}
|
|
324190
324345
|
function isDockerAvailable() {
|
|
324191
324346
|
try {
|
|
@@ -324316,11 +324471,11 @@ async function ensureOaImage(force = false) {
|
|
|
324316
324471
|
}
|
|
324317
324472
|
let buildContext;
|
|
324318
324473
|
const dockerDir = getDockerDir();
|
|
324319
|
-
if (
|
|
324474
|
+
if (existsSync82(join98(dockerDir, "Dockerfile"))) {
|
|
324320
324475
|
buildContext = dockerDir;
|
|
324321
324476
|
} else {
|
|
324322
|
-
buildContext =
|
|
324323
|
-
|
|
324477
|
+
buildContext = join98(homedir37(), ".oa", "docker-build");
|
|
324478
|
+
mkdirSync50(buildContext, { recursive: true });
|
|
324324
324479
|
writeDockerfiles(buildContext);
|
|
324325
324480
|
}
|
|
324326
324481
|
try {
|
|
@@ -324394,8 +324549,8 @@ chown -R node:node /workspace /home/node/.oa /home/node/.open-agents 2>/dev/null
|
|
|
324394
324549
|
if [ "$1" = "oa" ]; then shift; exec su - node -c "cd /workspace && oa $*"; fi
|
|
324395
324550
|
exec "$@"
|
|
324396
324551
|
`;
|
|
324397
|
-
|
|
324398
|
-
|
|
324552
|
+
writeFileSync44(join98(dir, "Dockerfile"), dockerfile);
|
|
324553
|
+
writeFileSync44(join98(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
|
|
324399
324554
|
}
|
|
324400
324555
|
function hasNvidiaGpu() {
|
|
324401
324556
|
try {
|
|
@@ -324462,119 +324617,6 @@ var init_docker = __esm({
|
|
|
324462
324617
|
}
|
|
324463
324618
|
});
|
|
324464
324619
|
|
|
324465
|
-
// packages/cli/src/api/py-embed.ts
|
|
324466
|
-
var py_embed_exports = {};
|
|
324467
|
-
__export(py_embed_exports, {
|
|
324468
|
-
ensureEmbedDeps: () => ensureEmbedDeps,
|
|
324469
|
-
runEmbedAudio: () => runEmbedAudio,
|
|
324470
|
-
runEmbedImage: () => runEmbedImage,
|
|
324471
|
-
runEmbedText: () => runEmbedText,
|
|
324472
|
-
runTranscribeFile: () => runTranscribeFile
|
|
324473
|
-
});
|
|
324474
|
-
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
324475
|
-
import { existsSync as existsSync82, mkdirSync as mkdirSync50, writeFileSync as writeFileSync44 } from "node:fs";
|
|
324476
|
-
import { join as join98 } from "node:path";
|
|
324477
|
-
import { homedir as homedir37 } from "node:os";
|
|
324478
|
-
function getVenvDir2() {
|
|
324479
|
-
return join98(homedir37(), ".open-agents", "venv");
|
|
324480
|
-
}
|
|
324481
|
-
function getVenvPython() {
|
|
324482
|
-
const base3 = getVenvDir2();
|
|
324483
|
-
const bin = process.platform === "win32" ? "Scripts" : "bin";
|
|
324484
|
-
const exe = process.platform === "win32" ? "python.exe" : "python3";
|
|
324485
|
-
return join98(base3, bin, exe);
|
|
324486
|
-
}
|
|
324487
|
-
function ensureEmbedDeps() {
|
|
324488
|
-
const venv = getVenvDir2();
|
|
324489
|
-
let log22 = "";
|
|
324490
|
-
try {
|
|
324491
|
-
mkdirSync50(venv, { recursive: true });
|
|
324492
|
-
} catch {
|
|
324493
|
-
}
|
|
324494
|
-
if (!existsSync82(getVenvPython())) {
|
|
324495
|
-
const mk = spawnSync5("python3", ["-m", "venv", venv], { encoding: "utf8" });
|
|
324496
|
-
log22 += mk.stdout + mk.stderr;
|
|
324497
|
-
}
|
|
324498
|
-
const pip = process.platform === "win32" ? join98(venv, "Scripts", "pip.exe") : join98(venv, "bin", "pip");
|
|
324499
|
-
const pkgs = [
|
|
324500
|
-
"open-clip-torch",
|
|
324501
|
-
"torch",
|
|
324502
|
-
"torchvision",
|
|
324503
|
-
"torchaudio",
|
|
324504
|
-
"Pillow",
|
|
324505
|
-
"speechbrain",
|
|
324506
|
-
"soundfile",
|
|
324507
|
-
"openai-whisper"
|
|
324508
|
-
];
|
|
324509
|
-
const ins = spawnSync5(pip, ["install", "--upgrade", ...pkgs], { encoding: "utf8", timeout: 9e5 });
|
|
324510
|
-
log22 += ins.stdout + ins.stderr;
|
|
324511
|
-
const ok2 = ins.status === 0;
|
|
324512
|
-
return { ok: ok2, log: log22 };
|
|
324513
|
-
}
|
|
324514
|
-
function runEmbedImage(input) {
|
|
324515
|
-
const py = getVenvPython();
|
|
324516
|
-
const script = locateScript("embed-image.py");
|
|
324517
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8" });
|
|
324518
|
-
try {
|
|
324519
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324520
|
-
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
324521
|
-
} catch {
|
|
324522
|
-
}
|
|
324523
|
-
return null;
|
|
324524
|
-
}
|
|
324525
|
-
function runEmbedAudio(input) {
|
|
324526
|
-
const py = getVenvPython();
|
|
324527
|
-
const script = locateScript("embed-audio.py");
|
|
324528
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8" });
|
|
324529
|
-
try {
|
|
324530
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324531
|
-
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
324532
|
-
} catch {
|
|
324533
|
-
}
|
|
324534
|
-
return null;
|
|
324535
|
-
}
|
|
324536
|
-
function runEmbedText(text) {
|
|
324537
|
-
const py = getVenvPython();
|
|
324538
|
-
const script = locateScript("embed-text.py");
|
|
324539
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify({ text }), encoding: "utf8" });
|
|
324540
|
-
try {
|
|
324541
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324542
|
-
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
324543
|
-
} catch {
|
|
324544
|
-
}
|
|
324545
|
-
return null;
|
|
324546
|
-
}
|
|
324547
|
-
function runTranscribeFile(input) {
|
|
324548
|
-
const py = getVenvPython();
|
|
324549
|
-
const script = locateScript("transcribe-file.py");
|
|
324550
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8", timeout: 6e5 });
|
|
324551
|
-
try {
|
|
324552
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324553
|
-
if (typeof out.text === "string") return out.text;
|
|
324554
|
-
} catch {
|
|
324555
|
-
}
|
|
324556
|
-
return null;
|
|
324557
|
-
}
|
|
324558
|
-
function locateScript(name11) {
|
|
324559
|
-
const candidates = [
|
|
324560
|
-
join98(process.cwd(), "dist", "scripts", name11),
|
|
324561
|
-
join98(process.cwd(), name11),
|
|
324562
|
-
join98(process.cwd(), "scripts", name11)
|
|
324563
|
-
];
|
|
324564
|
-
for (const c7 of candidates) if (existsSync82(c7)) return c7;
|
|
324565
|
-
const fallback = join98(process.cwd(), name11);
|
|
324566
|
-
try {
|
|
324567
|
-
writeFileSync44(fallback, 'print("missing script")\n');
|
|
324568
|
-
} catch {
|
|
324569
|
-
}
|
|
324570
|
-
return fallback;
|
|
324571
|
-
}
|
|
324572
|
-
var init_py_embed = __esm({
|
|
324573
|
-
"packages/cli/src/api/py-embed.ts"() {
|
|
324574
|
-
"use strict";
|
|
324575
|
-
}
|
|
324576
|
-
});
|
|
324577
|
-
|
|
324578
324620
|
// packages/cli/src/api/embedding-workers.ts
|
|
324579
324621
|
var embedding_workers_exports = {};
|
|
324580
324622
|
__export(embedding_workers_exports, {
|
|
@@ -327498,9 +327540,36 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
327498
327540
|
if (pathname === "/v1/scheduled/kill" && method === "POST") {
|
|
327499
327541
|
const body = await parseJsonBody(req2);
|
|
327500
327542
|
const pids = Array.isArray(body?.pids) ? body.pids.filter((n2) => Number.isInteger(n2)) : void 0;
|
|
327501
|
-
const pattern = typeof body?.pattern === "string" && body.pattern.trim() ? body.pattern.trim() : "(/bin/oa|open-agents-ai|nexus-daemon|OPEN-AGENTS-SCHEDULED)";
|
|
327543
|
+
const pattern = typeof body?.pattern === "string" && body.pattern.trim() ? body.pattern.trim() : "(/bin/oa|open-agents-ai|nexus-daemon|OPEN-AGENTS-SCHEDULED|ollama)";
|
|
327502
327544
|
const killed = killScheduledProcesses(pids, pattern);
|
|
327503
|
-
|
|
327545
|
+
const additionally = [];
|
|
327546
|
+
try {
|
|
327547
|
+
for (const [rid, child] of Array.from(runningProcesses.entries())) {
|
|
327548
|
+
const pid = child?.pid ?? 0;
|
|
327549
|
+
if (pid > 0) {
|
|
327550
|
+
try {
|
|
327551
|
+
process.kill(pid, "SIGTERM");
|
|
327552
|
+
additionally.push({ pid, ok: true, signal: "TERM", run_id: rid });
|
|
327553
|
+
} catch {
|
|
327554
|
+
additionally.push({ pid, ok: false, signal: "TERM", run_id: rid });
|
|
327555
|
+
}
|
|
327556
|
+
}
|
|
327557
|
+
try {
|
|
327558
|
+
if (pid > 0) {
|
|
327559
|
+
process.kill(pid, 0);
|
|
327560
|
+
try {
|
|
327561
|
+
process.kill(pid, "SIGKILL");
|
|
327562
|
+
additionally.push({ pid, ok: true, signal: "KILL", run_id: rid });
|
|
327563
|
+
} catch {
|
|
327564
|
+
}
|
|
327565
|
+
}
|
|
327566
|
+
} catch {
|
|
327567
|
+
}
|
|
327568
|
+
runningProcesses.delete(rid);
|
|
327569
|
+
}
|
|
327570
|
+
} catch {
|
|
327571
|
+
}
|
|
327572
|
+
jsonResponse(res, 200, { killed_count: killed.length + additionally.length, killed, additionally });
|
|
327504
327573
|
return;
|
|
327505
327574
|
}
|
|
327506
327575
|
if ((pathname === "/v1/chat" || pathname === "/api/chat") && method === "POST") {
|