open-agents-ai 0.187.309 → 0.187.311
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 +987 -884
- 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");
|
|
@@ -299270,11 +299425,34 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299270
299425
|
return "handled";
|
|
299271
299426
|
}
|
|
299272
299427
|
if ((sub === "enable" || sub === "disable") && tokens[1]) {
|
|
299273
|
-
const
|
|
299428
|
+
const target = tokens[1];
|
|
299429
|
+
if (target.toLowerCase() === "all") {
|
|
299430
|
+
try {
|
|
299431
|
+
const r2 = await doFetch("/v1/scheduled");
|
|
299432
|
+
const d2 = await r2.json();
|
|
299433
|
+
const tasks = Array.isArray(d2.tasks) ? d2.tasks : [];
|
|
299434
|
+
if (!tasks.length) {
|
|
299435
|
+
renderInfo2("No scheduled tasks found.");
|
|
299436
|
+
return "handled";
|
|
299437
|
+
}
|
|
299438
|
+
const want = sub === "enable";
|
|
299439
|
+
let changed = 0, failed = 0;
|
|
299440
|
+
for (const t2 of tasks) {
|
|
299441
|
+
if (!!t2.enabled === want) continue;
|
|
299442
|
+
const rr = await doFetch(`/v1/scheduled/${encodeURIComponent(t2.id)}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ enabled: want }) });
|
|
299443
|
+
if (rr.ok) changed++;
|
|
299444
|
+
else failed++;
|
|
299445
|
+
}
|
|
299446
|
+
renderInfo2(`${sub} all: ${changed} changed${failed ? `, ${failed} failed` : ""}.`);
|
|
299447
|
+
} catch (e2) {
|
|
299448
|
+
renderError2(e2?.message || String(e2));
|
|
299449
|
+
}
|
|
299450
|
+
return "handled";
|
|
299451
|
+
}
|
|
299274
299452
|
try {
|
|
299275
|
-
const r2 = await doFetch(`/v1/scheduled/${encodeURIComponent(
|
|
299276
|
-
if (r2.ok) renderInfo2(`${sub}d ${
|
|
299277
|
-
else renderWarning2(`Failed to ${sub} ${
|
|
299453
|
+
const r2 = await doFetch(`/v1/scheduled/${encodeURIComponent(target)}`, { method: "POST", body: JSON.stringify({ enabled: sub === "enable" }), headers: { "Content-Type": "application/json" } });
|
|
299454
|
+
if (r2.ok) renderInfo2(`${sub}d ${target}`);
|
|
299455
|
+
else renderWarning2(`Failed to ${sub} ${target}`);
|
|
299278
299456
|
} catch (e2) {
|
|
299279
299457
|
renderError2(e2?.message || String(e2));
|
|
299280
299458
|
}
|
|
@@ -299579,9 +299757,9 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299579
299757
|
}
|
|
299580
299758
|
}
|
|
299581
299759
|
}
|
|
299582
|
-
const _spLogDir =
|
|
299583
|
-
|
|
299584
|
-
const _spLogFile =
|
|
299760
|
+
const _spLogDir = join80(projectDir, ".oa", "sponsor");
|
|
299761
|
+
mkdirSync36(_spLogDir, { recursive: true });
|
|
299762
|
+
const _spLogFile = join80(_spLogDir, "sponsor-startup.log");
|
|
299585
299763
|
const _spLog = (msg) => {
|
|
299586
299764
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
|
|
299587
299765
|
`;
|
|
@@ -299691,17 +299869,17 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299691
299869
|
}
|
|
299692
299870
|
if (!sponsorUrl && !sponsorPeerId) {
|
|
299693
299871
|
_spLog("FAILED — no tunnelUrl and no peerId");
|
|
299694
|
-
_spLog(`nexusDir checked: ${
|
|
299695
|
-
_spLog(`status.json exists: ${
|
|
299696
|
-
_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"))}`);
|
|
299697
299875
|
try {
|
|
299698
|
-
const _statusRaw = readFileSync49(
|
|
299876
|
+
const _statusRaw = readFileSync49(join80(projectDir, ".oa", "nexus", "status.json"), "utf8");
|
|
299699
299877
|
_spLog(`status.json content: ${_statusRaw.slice(0, 300)}`);
|
|
299700
299878
|
} catch (e2) {
|
|
299701
299879
|
_spLog(`status.json read error: ${e2}`);
|
|
299702
299880
|
}
|
|
299703
299881
|
try {
|
|
299704
|
-
const _errRaw = readFileSync49(
|
|
299882
|
+
const _errRaw = readFileSync49(join80(projectDir, ".oa", "nexus", "daemon.err"), "utf8");
|
|
299705
299883
|
_spLog(`daemon.err (last 500): ${_errRaw.slice(-500)}`);
|
|
299706
299884
|
} catch (e2) {
|
|
299707
299885
|
_spLog(`daemon.err read error: ${e2}`);
|
|
@@ -299720,7 +299898,7 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299720
299898
|
try {
|
|
299721
299899
|
const { homedir: homedir41 } = __require("os");
|
|
299722
299900
|
const namePath = __require("path").join(homedir41(), ".open-agents", "agent-name");
|
|
299723
|
-
if (
|
|
299901
|
+
if (existsSync64(namePath)) sponsorName = readFileSync49(namePath, "utf8").trim();
|
|
299724
299902
|
} catch {
|
|
299725
299903
|
}
|
|
299726
299904
|
if (!sponsorName) sponsorName = "OA Sponsor";
|
|
@@ -299795,8 +299973,8 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299795
299973
|
if (result) {
|
|
299796
299974
|
renderInfo2("Sponsor wizard completed.");
|
|
299797
299975
|
try {
|
|
299798
|
-
const nexusPidFile =
|
|
299799
|
-
if (
|
|
299976
|
+
const nexusPidFile = join80(projectDir, ".oa", "nexus", "daemon.pid");
|
|
299977
|
+
if (existsSync64(nexusPidFile)) {
|
|
299800
299978
|
const nPid = parseInt(readFileSync49(nexusPidFile, "utf8").trim(), 10);
|
|
299801
299979
|
if (nPid > 0) {
|
|
299802
299980
|
registry2.register({ name: "Nexus", pid: nPid, startedAt: Date.now(), status: "running" });
|
|
@@ -300953,13 +301131,13 @@ async function showCohereDashboard(ctx3) {
|
|
|
300953
301131
|
} else if (idResult.key === "view") {
|
|
300954
301132
|
await ik.execute({ operation: "hydrate" });
|
|
300955
301133
|
} else if (idResult.key === "history") {
|
|
300956
|
-
const snapDir =
|
|
300957
|
-
if (
|
|
301134
|
+
const snapDir = join80(ctx3.repoRoot, ".oa", "identity", "snapshots");
|
|
301135
|
+
if (existsSync64(snapDir)) {
|
|
300958
301136
|
const snaps = readdirSync16(snapDir).filter((f2) => f2.endsWith(".json")).sort().reverse();
|
|
300959
301137
|
const snapItems = snaps.slice(0, 20).map((f2) => ({
|
|
300960
301138
|
key: f2,
|
|
300961
301139
|
label: f2.replace(".json", ""),
|
|
300962
|
-
detail: `${formatFileSize(statSync18(
|
|
301140
|
+
detail: `${formatFileSize(statSync18(join80(snapDir, f2)).size)}`
|
|
300963
301141
|
}));
|
|
300964
301142
|
if (snapItems.length > 0) {
|
|
300965
301143
|
await tuiSelect({
|
|
@@ -301976,10 +302154,10 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
301976
302154
|
}
|
|
301977
302155
|
} catch {
|
|
301978
302156
|
}
|
|
301979
|
-
const sponsorDir2 =
|
|
301980
|
-
const knownFile =
|
|
302157
|
+
const sponsorDir2 = join80(ctx3.repoRoot ?? process.cwd(), ".oa", "sponsor");
|
|
302158
|
+
const knownFile = join80(sponsorDir2, "known-sponsors.json");
|
|
301981
302159
|
try {
|
|
301982
|
-
if (
|
|
302160
|
+
if (existsSync64(knownFile)) {
|
|
301983
302161
|
const saved = JSON.parse(readFileSync49(knownFile, "utf8"));
|
|
301984
302162
|
for (const s2 of saved) {
|
|
301985
302163
|
if (!sponsors.some((sp) => sp.url === s2.url)) {
|
|
@@ -302130,11 +302308,11 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
302130
302308
|
}
|
|
302131
302309
|
const saveKey = selected.url || selected.peerId || selected.name;
|
|
302132
302310
|
try {
|
|
302133
|
-
|
|
302134
|
-
const existing =
|
|
302311
|
+
mkdirSync36(sponsorDir2, { recursive: true });
|
|
302312
|
+
const existing = existsSync64(knownFile) ? JSON.parse(readFileSync49(knownFile, "utf8")) : [];
|
|
302135
302313
|
const updated = existing.filter((s2) => (s2.url || s2.peerId || s2.name) !== saveKey);
|
|
302136
302314
|
updated.push(selected);
|
|
302137
|
-
|
|
302315
|
+
writeFileSync34(knownFile, JSON.stringify(updated, null, 2), "utf8");
|
|
302138
302316
|
} catch {
|
|
302139
302317
|
}
|
|
302140
302318
|
renderInfo2(`Connected to sponsored endpoint: ${selected.name}`);
|
|
@@ -306221,8 +306399,8 @@ import { EventEmitter as EventEmitter5 } from "node:events";
|
|
|
306221
306399
|
import { randomBytes as randomBytes17 } from "node:crypto";
|
|
306222
306400
|
import { URL as URL2 } from "node:url";
|
|
306223
306401
|
import { loadavg as loadavg3, cpus as cpus4, totalmem as totalmem5, freemem as freemem4 } from "node:os";
|
|
306224
|
-
import { existsSync as
|
|
306225
|
-
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";
|
|
306226
306404
|
function cleanForwardHeaders(raw, targetHost) {
|
|
306227
306405
|
const out = {};
|
|
306228
306406
|
for (const [key, value2] of Object.entries(raw)) {
|
|
@@ -306243,8 +306421,8 @@ function fmtTokens(n2) {
|
|
|
306243
306421
|
}
|
|
306244
306422
|
function readExposeState(stateDir) {
|
|
306245
306423
|
try {
|
|
306246
|
-
const path5 =
|
|
306247
|
-
if (!
|
|
306424
|
+
const path5 = join81(stateDir, STATE_FILE_NAME);
|
|
306425
|
+
if (!existsSync65(path5)) return null;
|
|
306248
306426
|
const raw = readFileSync50(path5, "utf8");
|
|
306249
306427
|
const data = JSON.parse(raw);
|
|
306250
306428
|
if (!data.pid || !data.tunnelUrl || !data.authKey || !data.proxyPort) return null;
|
|
@@ -306255,14 +306433,14 @@ function readExposeState(stateDir) {
|
|
|
306255
306433
|
}
|
|
306256
306434
|
function writeExposeState(stateDir, state) {
|
|
306257
306435
|
try {
|
|
306258
|
-
|
|
306259
|
-
|
|
306436
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
306437
|
+
writeFileSync35(join81(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
306260
306438
|
} catch {
|
|
306261
306439
|
}
|
|
306262
306440
|
}
|
|
306263
306441
|
function removeExposeState(stateDir) {
|
|
306264
306442
|
try {
|
|
306265
|
-
unlinkSync18(
|
|
306443
|
+
unlinkSync18(join81(stateDir, STATE_FILE_NAME));
|
|
306266
306444
|
} catch {
|
|
306267
306445
|
}
|
|
306268
306446
|
}
|
|
@@ -306359,8 +306537,8 @@ async function collectSystemMetricsAsync() {
|
|
|
306359
306537
|
}
|
|
306360
306538
|
function readP2PExposeState(stateDir) {
|
|
306361
306539
|
try {
|
|
306362
|
-
const path5 =
|
|
306363
|
-
if (!
|
|
306540
|
+
const path5 = join81(stateDir, P2P_STATE_FILE_NAME);
|
|
306541
|
+
if (!existsSync65(path5)) return null;
|
|
306364
306542
|
const raw = readFileSync50(path5, "utf8");
|
|
306365
306543
|
const data = JSON.parse(raw);
|
|
306366
306544
|
if (!data.peerId || !data.authKey) return null;
|
|
@@ -306371,14 +306549,14 @@ function readP2PExposeState(stateDir) {
|
|
|
306371
306549
|
}
|
|
306372
306550
|
function writeP2PExposeState(stateDir, state) {
|
|
306373
306551
|
try {
|
|
306374
|
-
|
|
306375
|
-
|
|
306552
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
306553
|
+
writeFileSync35(join81(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
306376
306554
|
} catch {
|
|
306377
306555
|
}
|
|
306378
306556
|
}
|
|
306379
306557
|
function removeP2PExposeState(stateDir) {
|
|
306380
306558
|
try {
|
|
306381
|
-
unlinkSync18(
|
|
306559
|
+
unlinkSync18(join81(stateDir, P2P_STATE_FILE_NAME));
|
|
306382
306560
|
} catch {
|
|
306383
306561
|
}
|
|
306384
306562
|
}
|
|
@@ -307368,7 +307546,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
307368
307546
|
throw new Error(`Expose failed: ${exposeResult.error}`);
|
|
307369
307547
|
}
|
|
307370
307548
|
const nexusDir = this._nexusTool.getNexusDir();
|
|
307371
|
-
const statusPath =
|
|
307549
|
+
const statusPath = join81(nexusDir, "status.json");
|
|
307372
307550
|
for (let i2 = 0; i2 < 80; i2++) {
|
|
307373
307551
|
try {
|
|
307374
307552
|
const raw = readFileSync50(statusPath, "utf8");
|
|
@@ -307402,8 +307580,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307402
307580
|
});
|
|
307403
307581
|
}
|
|
307404
307582
|
try {
|
|
307405
|
-
const invocDir =
|
|
307406
|
-
if (
|
|
307583
|
+
const invocDir = join81(nexusDir, "invocations");
|
|
307584
|
+
if (existsSync65(invocDir)) {
|
|
307407
307585
|
this._prevInvocCount = readdirSync17(invocDir).filter((f2) => f2.endsWith(".json")).length;
|
|
307408
307586
|
this._stats.totalRequests = this._prevInvocCount;
|
|
307409
307587
|
}
|
|
@@ -307430,9 +307608,9 @@ ${this.formatConnectionInfo()}`);
|
|
|
307430
307608
|
const state = readP2PExposeState(stateDir);
|
|
307431
307609
|
if (!state) return null;
|
|
307432
307610
|
const nexusDir = nexusTool.getNexusDir();
|
|
307433
|
-
const statusPath =
|
|
307611
|
+
const statusPath = join81(nexusDir, "status.json");
|
|
307434
307612
|
try {
|
|
307435
|
-
if (!
|
|
307613
|
+
if (!existsSync65(statusPath)) {
|
|
307436
307614
|
removeP2PExposeState(stateDir);
|
|
307437
307615
|
return null;
|
|
307438
307616
|
}
|
|
@@ -307489,8 +307667,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307489
307667
|
let lastMeteringLineCount = 0;
|
|
307490
307668
|
this._activityPollTimer = setInterval(() => {
|
|
307491
307669
|
try {
|
|
307492
|
-
const invocDir =
|
|
307493
|
-
if (!
|
|
307670
|
+
const invocDir = join81(nexusDir, "invocations");
|
|
307671
|
+
if (!existsSync65(invocDir)) return;
|
|
307494
307672
|
const files = readdirSync17(invocDir).filter((f2) => f2.endsWith(".json"));
|
|
307495
307673
|
const invocCount = files.length;
|
|
307496
307674
|
const newRequests = invocCount - this._prevInvocCount;
|
|
@@ -307504,15 +307682,15 @@ ${this.formatConnectionInfo()}`);
|
|
|
307504
307682
|
let recentActive = 0;
|
|
307505
307683
|
for (const f2 of files.slice(-10)) {
|
|
307506
307684
|
try {
|
|
307507
|
-
const st = statSync19(
|
|
307685
|
+
const st = statSync19(join81(invocDir, f2));
|
|
307508
307686
|
if (now - st.mtimeMs < 1e4) recentActive++;
|
|
307509
307687
|
} catch {
|
|
307510
307688
|
}
|
|
307511
307689
|
}
|
|
307512
|
-
const meteringFile =
|
|
307690
|
+
const meteringFile = join81(nexusDir, "metering.jsonl");
|
|
307513
307691
|
let meteringLines = lastMeteringLineCount;
|
|
307514
307692
|
try {
|
|
307515
|
-
if (
|
|
307693
|
+
if (existsSync65(meteringFile)) {
|
|
307516
307694
|
const content = readFileSync50(meteringFile, "utf8");
|
|
307517
307695
|
meteringLines = content.split("\n").filter((l2) => l2.trim()).length;
|
|
307518
307696
|
}
|
|
@@ -307538,8 +307716,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307538
307716
|
this._activityPollTimer.unref();
|
|
307539
307717
|
this._pollTimer = setInterval(() => {
|
|
307540
307718
|
try {
|
|
307541
|
-
const statusPath =
|
|
307542
|
-
if (
|
|
307719
|
+
const statusPath = join81(nexusDir, "status.json");
|
|
307720
|
+
if (existsSync65(statusPath)) {
|
|
307543
307721
|
const status = JSON.parse(readFileSync50(statusPath, "utf8"));
|
|
307544
307722
|
if (status.peerId && !this._peerId) {
|
|
307545
307723
|
this._peerId = status.peerId;
|
|
@@ -307549,8 +307727,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307549
307727
|
} catch {
|
|
307550
307728
|
}
|
|
307551
307729
|
try {
|
|
307552
|
-
const invocDir =
|
|
307553
|
-
if (
|
|
307730
|
+
const invocDir = join81(nexusDir, "invocations");
|
|
307731
|
+
if (existsSync65(invocDir)) {
|
|
307554
307732
|
const files = readdirSync17(invocDir);
|
|
307555
307733
|
const invocCount = files.filter((f2) => f2.endsWith(".json")).length;
|
|
307556
307734
|
if (invocCount > this._stats.totalRequests) {
|
|
@@ -307561,8 +307739,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
307561
307739
|
} catch {
|
|
307562
307740
|
}
|
|
307563
307741
|
try {
|
|
307564
|
-
const meteringFile =
|
|
307565
|
-
if (
|
|
307742
|
+
const meteringFile = join81(nexusDir, "metering.jsonl");
|
|
307743
|
+
if (existsSync65(meteringFile)) {
|
|
307566
307744
|
const content = readFileSync50(meteringFile, "utf8");
|
|
307567
307745
|
if (content.length > lastMeteringSize) {
|
|
307568
307746
|
const newContent = content.slice(lastMeteringSize);
|
|
@@ -307774,7 +307952,7 @@ var init_types = __esm({
|
|
|
307774
307952
|
|
|
307775
307953
|
// packages/cli/src/tui/p2p/secret-vault.ts
|
|
307776
307954
|
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes18, scryptSync as scryptSync2, createHash as createHash5 } from "node:crypto";
|
|
307777
|
-
import { readFileSync as readFileSync51, writeFileSync as
|
|
307955
|
+
import { readFileSync as readFileSync51, writeFileSync as writeFileSync36, existsSync as existsSync66, mkdirSync as mkdirSync38 } from "node:fs";
|
|
307778
307956
|
import { dirname as dirname24 } from "node:path";
|
|
307779
307957
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
307780
307958
|
var init_secret_vault = __esm({
|
|
@@ -307982,15 +308160,15 @@ var init_secret_vault = __esm({
|
|
|
307982
308160
|
const tag = cipher.getAuthTag();
|
|
307983
308161
|
const blob = Buffer.concat([salt, iv, tag, encrypted]);
|
|
307984
308162
|
const dir = dirname24(this.storePath);
|
|
307985
|
-
if (!
|
|
307986
|
-
|
|
308163
|
+
if (!existsSync66(dir)) mkdirSync38(dir, { recursive: true });
|
|
308164
|
+
writeFileSync36(this.storePath, blob, { mode: 384 });
|
|
307987
308165
|
}
|
|
307988
308166
|
/**
|
|
307989
308167
|
* Load vault from disk, decrypting with the given passphrase.
|
|
307990
308168
|
* Returns the number of secrets loaded.
|
|
307991
308169
|
*/
|
|
307992
308170
|
load(passphrase) {
|
|
307993
|
-
if (!this.storePath || !
|
|
308171
|
+
if (!this.storePath || !existsSync66(this.storePath)) return 0;
|
|
307994
308172
|
const blob = readFileSync51(this.storePath);
|
|
307995
308173
|
if (blob.length < SALT_LEN + IV_LEN + 16) {
|
|
307996
308174
|
throw new Error("Vault file is corrupted (too small)");
|
|
@@ -309012,10 +309190,10 @@ ${activitySummary}
|
|
|
309012
309190
|
});
|
|
309013
309191
|
|
|
309014
309192
|
// packages/cli/src/tui/project-context.ts
|
|
309015
|
-
import { existsSync as
|
|
309016
|
-
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";
|
|
309017
309195
|
import { execSync as execSync51 } from "node:child_process";
|
|
309018
|
-
import { homedir as
|
|
309196
|
+
import { homedir as homedir32, platform as platform5, release } from "node:os";
|
|
309019
309197
|
function getModelTier(modelName) {
|
|
309020
309198
|
const m2 = modelName.toLowerCase();
|
|
309021
309199
|
const sizeMatch = m2.match(/\b(\d+)b\b/);
|
|
@@ -309044,8 +309222,8 @@ function loadProjectMap(repoRoot) {
|
|
|
309044
309222
|
if (!hasOaDirectory(repoRoot)) {
|
|
309045
309223
|
initOaDirectory(repoRoot);
|
|
309046
309224
|
}
|
|
309047
|
-
const mapPath2 =
|
|
309048
|
-
if (
|
|
309225
|
+
const mapPath2 = join83(repoRoot, OA_DIR, "context", "project-map.md");
|
|
309226
|
+
if (existsSync67(mapPath2)) {
|
|
309049
309227
|
try {
|
|
309050
309228
|
const content = readFileSync52(mapPath2, "utf-8");
|
|
309051
309229
|
return content;
|
|
@@ -309086,27 +309264,27 @@ ${log22}`);
|
|
|
309086
309264
|
}
|
|
309087
309265
|
function loadMemoryContext(repoRoot) {
|
|
309088
309266
|
const sections = [];
|
|
309089
|
-
const oaMemDir =
|
|
309267
|
+
const oaMemDir = join83(repoRoot, OA_DIR, "memory");
|
|
309090
309268
|
const oaEntries = loadMemoryDir(oaMemDir, "project");
|
|
309091
309269
|
if (oaEntries) sections.push(oaEntries);
|
|
309092
|
-
const legacyMemDir =
|
|
309093
|
-
if (legacyMemDir !== oaMemDir &&
|
|
309270
|
+
const legacyMemDir = join83(repoRoot, ".open-agents", "memory");
|
|
309271
|
+
if (legacyMemDir !== oaMemDir && existsSync67(legacyMemDir)) {
|
|
309094
309272
|
const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
|
|
309095
309273
|
if (legacyEntries) sections.push(legacyEntries);
|
|
309096
309274
|
}
|
|
309097
|
-
const globalMemDir =
|
|
309275
|
+
const globalMemDir = join83(homedir32(), ".open-agents", "memory");
|
|
309098
309276
|
const globalEntries = loadMemoryDir(globalMemDir, "global");
|
|
309099
309277
|
if (globalEntries) sections.push(globalEntries);
|
|
309100
309278
|
return sections.join("\n\n");
|
|
309101
309279
|
}
|
|
309102
309280
|
function loadMemoryDir(memDir, scope) {
|
|
309103
|
-
if (!
|
|
309281
|
+
if (!existsSync67(memDir)) return "";
|
|
309104
309282
|
const lines = [];
|
|
309105
309283
|
try {
|
|
309106
309284
|
const files = readdirSync18(memDir).filter((f2) => f2.endsWith(".json"));
|
|
309107
309285
|
for (const file of files.slice(0, 10)) {
|
|
309108
309286
|
try {
|
|
309109
|
-
const raw = readFileSync52(
|
|
309287
|
+
const raw = readFileSync52(join83(memDir, file), "utf-8");
|
|
309110
309288
|
const entries = JSON.parse(raw);
|
|
309111
309289
|
const topic = basename13(file, ".json");
|
|
309112
309290
|
const keys = Object.keys(entries);
|
|
@@ -309634,8 +309812,8 @@ __export(banner_exports, {
|
|
|
309634
309812
|
saveBannerDesign: () => saveBannerDesign,
|
|
309635
309813
|
setGridText: () => setGridText
|
|
309636
309814
|
});
|
|
309637
|
-
import { existsSync as
|
|
309638
|
-
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";
|
|
309639
309817
|
function generateMnemonic(seed) {
|
|
309640
309818
|
let h = 2166136261;
|
|
309641
309819
|
for (let i2 = 0; i2 < seed.length; i2++) {
|
|
@@ -309765,13 +309943,13 @@ function createSponsorBanner(sponsorName, tagline, primaryColor = 214, bgColor =
|
|
|
309765
309943
|
};
|
|
309766
309944
|
}
|
|
309767
309945
|
function saveBannerDesign(workDir, design) {
|
|
309768
|
-
const dir =
|
|
309769
|
-
|
|
309770
|
-
|
|
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");
|
|
309771
309949
|
}
|
|
309772
309950
|
function loadBannerDesign(workDir, id) {
|
|
309773
|
-
const file =
|
|
309774
|
-
if (!
|
|
309951
|
+
const file = join84(workDir, ".oa", "banners", `${id}.json`);
|
|
309952
|
+
if (!existsSync68(file)) return null;
|
|
309775
309953
|
try {
|
|
309776
309954
|
return JSON.parse(readFileSync53(file, "utf8"));
|
|
309777
309955
|
} catch {
|
|
@@ -309779,8 +309957,8 @@ function loadBannerDesign(workDir, id) {
|
|
|
309779
309957
|
}
|
|
309780
309958
|
}
|
|
309781
309959
|
function listBannerDesigns(workDir) {
|
|
309782
|
-
const dir =
|
|
309783
|
-
if (!
|
|
309960
|
+
const dir = join84(workDir, ".oa", "banners");
|
|
309961
|
+
if (!existsSync68(dir)) return [];
|
|
309784
309962
|
try {
|
|
309785
309963
|
const { readdirSync: readdirSync31 } = __require("node:fs");
|
|
309786
309964
|
return readdirSync31(dir).filter((f2) => f2.endsWith(".json")).map((f2) => f2.replace(".json", ""));
|
|
@@ -310088,21 +310266,21 @@ var init_banner = __esm({
|
|
|
310088
310266
|
});
|
|
310089
310267
|
|
|
310090
310268
|
// packages/cli/src/tui/carousel-descriptors.ts
|
|
310091
|
-
import { existsSync as
|
|
310092
|
-
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";
|
|
310093
310271
|
function loadToolProfile(repoRoot) {
|
|
310094
|
-
const filePath =
|
|
310272
|
+
const filePath = join85(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
310095
310273
|
try {
|
|
310096
|
-
if (!
|
|
310274
|
+
if (!existsSync69(filePath)) return null;
|
|
310097
310275
|
return JSON.parse(readFileSync54(filePath, "utf-8"));
|
|
310098
310276
|
} catch {
|
|
310099
310277
|
return null;
|
|
310100
310278
|
}
|
|
310101
310279
|
}
|
|
310102
310280
|
function saveToolProfile(repoRoot, profile) {
|
|
310103
|
-
const contextDir =
|
|
310104
|
-
|
|
310105
|
-
|
|
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");
|
|
310106
310284
|
}
|
|
310107
310285
|
function categorizeToolCall(toolName) {
|
|
310108
310286
|
for (const cat2 of TOOL_CATEGORIES) {
|
|
@@ -310157,9 +310335,9 @@ function weightedColor(profile) {
|
|
|
310157
310335
|
return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
|
|
310158
310336
|
}
|
|
310159
310337
|
function loadCachedDescriptors(repoRoot) {
|
|
310160
|
-
const filePath =
|
|
310338
|
+
const filePath = join85(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
|
|
310161
310339
|
try {
|
|
310162
|
-
if (!
|
|
310340
|
+
if (!existsSync69(filePath)) return null;
|
|
310163
310341
|
const cached = JSON.parse(readFileSync54(filePath, "utf-8"));
|
|
310164
310342
|
return cached.phrases.length > 0 ? cached.phrases : null;
|
|
310165
310343
|
} catch {
|
|
@@ -310167,14 +310345,14 @@ function loadCachedDescriptors(repoRoot) {
|
|
|
310167
310345
|
}
|
|
310168
310346
|
}
|
|
310169
310347
|
function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
310170
|
-
const contextDir =
|
|
310171
|
-
|
|
310348
|
+
const contextDir = join85(repoRoot, OA_DIR, "context");
|
|
310349
|
+
mkdirSync40(contextDir, { recursive: true });
|
|
310172
310350
|
const cached = {
|
|
310173
310351
|
phrases,
|
|
310174
310352
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
310175
310353
|
sourceHash
|
|
310176
310354
|
};
|
|
310177
|
-
|
|
310355
|
+
writeFileSync38(join85(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
310178
310356
|
}
|
|
310179
310357
|
function generateDescriptors(repoRoot) {
|
|
310180
310358
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -310221,9 +310399,9 @@ function generateDescriptors(repoRoot) {
|
|
|
310221
310399
|
return phrases;
|
|
310222
310400
|
}
|
|
310223
310401
|
function extractFromPackageJson(repoRoot, tags) {
|
|
310224
|
-
const pkgPath =
|
|
310402
|
+
const pkgPath = join85(repoRoot, "package.json");
|
|
310225
310403
|
try {
|
|
310226
|
-
if (!
|
|
310404
|
+
if (!existsSync69(pkgPath)) return;
|
|
310227
310405
|
const pkg = JSON.parse(readFileSync54(pkgPath, "utf-8"));
|
|
310228
310406
|
if (pkg.name && typeof pkg.name === "string") {
|
|
310229
310407
|
const parts = pkg.name.replace(/^@/, "").split("/");
|
|
@@ -310265,7 +310443,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
310265
310443
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
310266
310444
|
];
|
|
310267
310445
|
for (const check of manifestChecks) {
|
|
310268
|
-
if (
|
|
310446
|
+
if (existsSync69(join85(repoRoot, check.file))) {
|
|
310269
310447
|
tags.push(check.tag);
|
|
310270
310448
|
}
|
|
310271
310449
|
}
|
|
@@ -310287,15 +310465,15 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
310287
310465
|
}
|
|
310288
310466
|
}
|
|
310289
310467
|
function extractFromMemory(repoRoot, tags) {
|
|
310290
|
-
const memoryDir =
|
|
310468
|
+
const memoryDir = join85(repoRoot, OA_DIR, "memory");
|
|
310291
310469
|
try {
|
|
310292
|
-
if (!
|
|
310470
|
+
if (!existsSync69(memoryDir)) return;
|
|
310293
310471
|
const files = readdirSync19(memoryDir).filter((f2) => f2.endsWith(".json"));
|
|
310294
310472
|
for (const file of files) {
|
|
310295
310473
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
310296
310474
|
tags.push(topic);
|
|
310297
310475
|
try {
|
|
310298
|
-
const data = JSON.parse(readFileSync54(
|
|
310476
|
+
const data = JSON.parse(readFileSync54(join85(memoryDir, file), "utf-8"));
|
|
310299
310477
|
if (data && typeof data === "object") {
|
|
310300
310478
|
const keys = Object.keys(data).slice(0, 3);
|
|
310301
310479
|
for (const key of keys) {
|
|
@@ -310993,13 +311171,13 @@ var init_stream_renderer = __esm({
|
|
|
310993
311171
|
});
|
|
310994
311172
|
|
|
310995
311173
|
// packages/cli/src/tui/edit-history.ts
|
|
310996
|
-
import { appendFileSync as appendFileSync4, mkdirSync as
|
|
310997
|
-
import { join as
|
|
311174
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "node:fs";
|
|
311175
|
+
import { join as join86 } from "node:path";
|
|
310998
311176
|
function createEditHistoryLogger(repoRoot, sessionId) {
|
|
310999
|
-
const historyDir =
|
|
311000
|
-
const logPath2 =
|
|
311177
|
+
const historyDir = join86(repoRoot, ".oa", "history");
|
|
311178
|
+
const logPath2 = join86(historyDir, "edits.jsonl");
|
|
311001
311179
|
try {
|
|
311002
|
-
|
|
311180
|
+
mkdirSync41(historyDir, { recursive: true });
|
|
311003
311181
|
} catch {
|
|
311004
311182
|
}
|
|
311005
311183
|
function logToolCall(toolName, toolArgs, success) {
|
|
@@ -311107,14 +311285,14 @@ var init_edit_history = __esm({
|
|
|
311107
311285
|
});
|
|
311108
311286
|
|
|
311109
311287
|
// packages/cli/src/tui/promptLoader.ts
|
|
311110
|
-
import { readFileSync as readFileSync55, existsSync as
|
|
311111
|
-
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";
|
|
311112
311290
|
import { fileURLToPath as fileURLToPath15 } from "node:url";
|
|
311113
311291
|
function loadPrompt3(promptPath, vars) {
|
|
311114
311292
|
let content = cache6.get(promptPath);
|
|
311115
311293
|
if (content === void 0) {
|
|
311116
|
-
const fullPath =
|
|
311117
|
-
if (!
|
|
311294
|
+
const fullPath = join87(PROMPTS_DIR3, promptPath);
|
|
311295
|
+
if (!existsSync70(fullPath)) {
|
|
311118
311296
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
311119
311297
|
}
|
|
311120
311298
|
content = readFileSync55(fullPath, "utf-8");
|
|
@@ -311129,16 +311307,16 @@ var init_promptLoader3 = __esm({
|
|
|
311129
311307
|
"use strict";
|
|
311130
311308
|
__filename5 = fileURLToPath15(import.meta.url);
|
|
311131
311309
|
__dirname7 = dirname25(__filename5);
|
|
311132
|
-
devPath2 =
|
|
311133
|
-
publishedPath2 =
|
|
311134
|
-
PROMPTS_DIR3 =
|
|
311310
|
+
devPath2 = join87(__dirname7, "..", "..", "prompts");
|
|
311311
|
+
publishedPath2 = join87(__dirname7, "..", "prompts");
|
|
311312
|
+
PROMPTS_DIR3 = existsSync70(devPath2) ? devPath2 : publishedPath2;
|
|
311135
311313
|
cache6 = /* @__PURE__ */ new Map();
|
|
311136
311314
|
}
|
|
311137
311315
|
});
|
|
311138
311316
|
|
|
311139
311317
|
// packages/cli/src/tui/dream-engine.ts
|
|
311140
|
-
import { mkdirSync as
|
|
311141
|
-
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";
|
|
311142
311320
|
import { execSync as execSync52 } from "node:child_process";
|
|
311143
311321
|
function setDreamWriteContent(fn) {
|
|
311144
311322
|
_dreamWriteContent = fn;
|
|
@@ -311151,8 +311329,8 @@ function dreamWrite(fn) {
|
|
|
311151
311329
|
}
|
|
311152
311330
|
}
|
|
311153
311331
|
function loadAutoresearchMemory(repoRoot) {
|
|
311154
|
-
const memoryPath =
|
|
311155
|
-
if (!
|
|
311332
|
+
const memoryPath = join88(repoRoot, ".oa", "memory", "autoresearch.json");
|
|
311333
|
+
if (!existsSync71(memoryPath)) return "";
|
|
311156
311334
|
try {
|
|
311157
311335
|
const raw = readFileSync56(memoryPath, "utf-8");
|
|
311158
311336
|
const data = JSON.parse(raw);
|
|
@@ -311350,14 +311528,14 @@ var init_dream_engine = __esm({
|
|
|
311350
311528
|
const rawPath = String(args2["path"] ?? "");
|
|
311351
311529
|
const content = String(args2["content"] ?? "");
|
|
311352
311530
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
311353
|
-
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);
|
|
311354
311532
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
311355
311533
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start2 };
|
|
311356
311534
|
}
|
|
311357
311535
|
try {
|
|
311358
|
-
const dir =
|
|
311359
|
-
|
|
311360
|
-
|
|
311536
|
+
const dir = join88(targetPath, "..");
|
|
311537
|
+
mkdirSync42(dir, { recursive: true });
|
|
311538
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311361
311539
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311362
311540
|
} catch (err) {
|
|
311363
311541
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311384,12 +311562,12 @@ var init_dream_engine = __esm({
|
|
|
311384
311562
|
const rawPath = String(args2["path"] ?? "");
|
|
311385
311563
|
const oldStr = String(args2["old_string"] ?? "");
|
|
311386
311564
|
const newStr = String(args2["new_string"] ?? "");
|
|
311387
|
-
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);
|
|
311388
311566
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
311389
311567
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start2 };
|
|
311390
311568
|
}
|
|
311391
311569
|
try {
|
|
311392
|
-
if (!
|
|
311570
|
+
if (!existsSync71(targetPath)) {
|
|
311393
311571
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311394
311572
|
}
|
|
311395
311573
|
let content = readFileSync56(targetPath, "utf-8");
|
|
@@ -311397,7 +311575,7 @@ var init_dream_engine = __esm({
|
|
|
311397
311575
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
311398
311576
|
}
|
|
311399
311577
|
content = content.replace(oldStr, newStr);
|
|
311400
|
-
|
|
311578
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311401
311579
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311402
311580
|
} catch (err) {
|
|
311403
311581
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311436,14 +311614,14 @@ var init_dream_engine = __esm({
|
|
|
311436
311614
|
const rawPath = String(args2["path"] ?? "");
|
|
311437
311615
|
const content = String(args2["content"] ?? "");
|
|
311438
311616
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
311439
|
-
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);
|
|
311440
311618
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
311441
311619
|
return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start2 };
|
|
311442
311620
|
}
|
|
311443
311621
|
try {
|
|
311444
|
-
const dir =
|
|
311445
|
-
|
|
311446
|
-
|
|
311622
|
+
const dir = join88(targetPath, "..");
|
|
311623
|
+
mkdirSync42(dir, { recursive: true });
|
|
311624
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311447
311625
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311448
311626
|
} catch (err) {
|
|
311449
311627
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311470,12 +311648,12 @@ var init_dream_engine = __esm({
|
|
|
311470
311648
|
const rawPath = String(args2["path"] ?? "");
|
|
311471
311649
|
const oldStr = String(args2["old_string"] ?? "");
|
|
311472
311650
|
const newStr = String(args2["new_string"] ?? "");
|
|
311473
|
-
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);
|
|
311474
311652
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
311475
311653
|
return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start2 };
|
|
311476
311654
|
}
|
|
311477
311655
|
try {
|
|
311478
|
-
if (!
|
|
311656
|
+
if (!existsSync71(targetPath)) {
|
|
311479
311657
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311480
311658
|
}
|
|
311481
311659
|
let content = readFileSync56(targetPath, "utf-8");
|
|
@@ -311483,7 +311661,7 @@ var init_dream_engine = __esm({
|
|
|
311483
311661
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
311484
311662
|
}
|
|
311485
311663
|
content = content.replace(oldStr, newStr);
|
|
311486
|
-
|
|
311664
|
+
writeFileSync39(targetPath, content, "utf-8");
|
|
311487
311665
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
311488
311666
|
} catch (err) {
|
|
311489
311667
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -311531,7 +311709,7 @@ var init_dream_engine = __esm({
|
|
|
311531
311709
|
constructor(config, repoRoot) {
|
|
311532
311710
|
this.config = config;
|
|
311533
311711
|
this.repoRoot = repoRoot;
|
|
311534
|
-
this.dreamsDir =
|
|
311712
|
+
this.dreamsDir = join88(repoRoot, ".oa", "dreams");
|
|
311535
311713
|
this.state = {
|
|
311536
311714
|
mode: "default",
|
|
311537
311715
|
active: false,
|
|
@@ -311568,7 +311746,7 @@ var init_dream_engine = __esm({
|
|
|
311568
311746
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
311569
311747
|
results: []
|
|
311570
311748
|
};
|
|
311571
|
-
|
|
311749
|
+
mkdirSync42(this.dreamsDir, { recursive: true });
|
|
311572
311750
|
this.saveDreamState();
|
|
311573
311751
|
try {
|
|
311574
311752
|
for (let cycle = 1; cycle <= totalCycles; cycle++) {
|
|
@@ -311640,8 +311818,8 @@ ${result.summary}`;
|
|
|
311640
311818
|
if (mode !== "default" || cycle === totalCycles) {
|
|
311641
311819
|
renderDreamContraction(cycle);
|
|
311642
311820
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
311643
|
-
const summaryPath =
|
|
311644
|
-
|
|
311821
|
+
const summaryPath = join88(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
311822
|
+
writeFileSync39(summaryPath, cycleSummary, "utf-8");
|
|
311645
311823
|
}
|
|
311646
311824
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
311647
311825
|
this.saveVersionCheckpoint(cycle);
|
|
@@ -311880,7 +312058,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
311880
312058
|
}
|
|
311881
312059
|
/** Build role-specific tool sets for swarm agents */
|
|
311882
312060
|
buildSwarmTools(role, _workspace) {
|
|
311883
|
-
const autoresearchDir =
|
|
312061
|
+
const autoresearchDir = join88(this.repoRoot, ".oa", "autoresearch");
|
|
311884
312062
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
311885
312063
|
switch (role) {
|
|
311886
312064
|
case "researcher": {
|
|
@@ -312279,7 +312457,7 @@ Call task_complete with a human-readable summary of the autoresearch session.`,
|
|
|
312279
312457
|
workspace,
|
|
312280
312458
|
onEvent
|
|
312281
312459
|
);
|
|
312282
|
-
const reportPath =
|
|
312460
|
+
const reportPath = join88(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
312283
312461
|
const report = `# Autoresearch Swarm Report — Cycle ${cycleNum}
|
|
312284
312462
|
|
|
312285
312463
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -312301,8 +312479,8 @@ ${summaryResult}
|
|
|
312301
312479
|
*Generated by open-agents autoresearch swarm*
|
|
312302
312480
|
`;
|
|
312303
312481
|
try {
|
|
312304
|
-
|
|
312305
|
-
|
|
312482
|
+
mkdirSync42(this.dreamsDir, { recursive: true });
|
|
312483
|
+
writeFileSync39(reportPath, report, "utf-8");
|
|
312306
312484
|
} catch {
|
|
312307
312485
|
}
|
|
312308
312486
|
renderSwarmComplete(workspace);
|
|
@@ -312368,9 +312546,9 @@ ${summaryResult}
|
|
|
312368
312546
|
}
|
|
312369
312547
|
/** Save workspace backup for lucid mode */
|
|
312370
312548
|
saveVersionCheckpoint(cycle) {
|
|
312371
|
-
const checkpointDir =
|
|
312549
|
+
const checkpointDir = join88(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
312372
312550
|
try {
|
|
312373
|
-
|
|
312551
|
+
mkdirSync42(checkpointDir, { recursive: true });
|
|
312374
312552
|
try {
|
|
312375
312553
|
const gitStatus = execSync52("git status --porcelain", {
|
|
312376
312554
|
cwd: this.repoRoot,
|
|
@@ -312387,11 +312565,11 @@ ${summaryResult}
|
|
|
312387
312565
|
encoding: "utf-8",
|
|
312388
312566
|
timeout: 5e3
|
|
312389
312567
|
}).trim();
|
|
312390
|
-
|
|
312391
|
-
|
|
312392
|
-
|
|
312393
|
-
|
|
312394
|
-
|
|
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"),
|
|
312395
312573
|
JSON.stringify({
|
|
312396
312574
|
cycle,
|
|
312397
312575
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -312402,8 +312580,8 @@ ${summaryResult}
|
|
|
312402
312580
|
);
|
|
312403
312581
|
renderInfo2(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
312404
312582
|
} catch {
|
|
312405
|
-
|
|
312406
|
-
|
|
312583
|
+
writeFileSync39(
|
|
312584
|
+
join88(checkpointDir, "checkpoint.json"),
|
|
312407
312585
|
JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2),
|
|
312408
312586
|
"utf-8"
|
|
312409
312587
|
);
|
|
@@ -312464,7 +312642,7 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312464
312642
|
---
|
|
312465
312643
|
*Auto-generated by open-agents dream engine*
|
|
312466
312644
|
`;
|
|
312467
|
-
|
|
312645
|
+
writeFileSync39(join88(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
312468
312646
|
} catch {
|
|
312469
312647
|
}
|
|
312470
312648
|
}
|
|
@@ -312485,8 +312663,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312485
312663
|
results: []
|
|
312486
312664
|
};
|
|
312487
312665
|
renderInfo2("Memory consolidation starting — Phase 1: Orient → Phase 2: Gather → Phase 3: Consolidate → Phase 4: Prune");
|
|
312488
|
-
const memoryDir =
|
|
312489
|
-
|
|
312666
|
+
const memoryDir = join88(this.repoRoot, ".oa", "memory");
|
|
312667
|
+
mkdirSync42(memoryDir, { recursive: true });
|
|
312490
312668
|
let prompt;
|
|
312491
312669
|
try {
|
|
312492
312670
|
prompt = loadPrompt3("tui/dream-consolidate.md", {
|
|
@@ -312550,8 +312728,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312550
312728
|
durationMs
|
|
312551
312729
|
});
|
|
312552
312730
|
try {
|
|
312553
|
-
|
|
312554
|
-
|
|
312731
|
+
writeFileSync39(
|
|
312732
|
+
join88(memoryDir, ".last-consolidation"),
|
|
312555
312733
|
JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), summary: result.summary?.slice(0, 500) }) + "\n"
|
|
312556
312734
|
);
|
|
312557
312735
|
} catch {
|
|
@@ -312568,8 +312746,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
312568
312746
|
/** Save dream state for resume/inspection */
|
|
312569
312747
|
saveDreamState() {
|
|
312570
312748
|
try {
|
|
312571
|
-
|
|
312572
|
-
|
|
312749
|
+
writeFileSync39(
|
|
312750
|
+
join88(this.dreamsDir, "dream-state.json"),
|
|
312573
312751
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
312574
312752
|
"utf-8"
|
|
312575
312753
|
);
|
|
@@ -312939,8 +313117,8 @@ var init_bless_engine = __esm({
|
|
|
312939
313117
|
});
|
|
312940
313118
|
|
|
312941
313119
|
// packages/cli/src/tui/dmn-engine.ts
|
|
312942
|
-
import { existsSync as
|
|
312943
|
-
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";
|
|
312944
313122
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
312945
313123
|
const competenceReport = competence.length > 0 ? competence.map((c7) => {
|
|
312946
313124
|
const rate = c7.attempts > 0 ? Math.round(c7.successes / c7.attempts * 100) : 0;
|
|
@@ -313045,9 +313223,9 @@ var init_dmn_engine = __esm({
|
|
|
313045
313223
|
constructor(config, repoRoot) {
|
|
313046
313224
|
this.config = config;
|
|
313047
313225
|
this.repoRoot = repoRoot;
|
|
313048
|
-
this.stateDir =
|
|
313049
|
-
this.historyDir =
|
|
313050
|
-
|
|
313226
|
+
this.stateDir = join89(repoRoot, ".oa", "dmn");
|
|
313227
|
+
this.historyDir = join89(repoRoot, ".oa", "dmn", "cycles");
|
|
313228
|
+
mkdirSync43(this.historyDir, { recursive: true });
|
|
313051
313229
|
this.loadState();
|
|
313052
313230
|
}
|
|
313053
313231
|
state = {
|
|
@@ -313681,11 +313859,11 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313681
313859
|
async gatherMemoryTopics() {
|
|
313682
313860
|
const topics = [];
|
|
313683
313861
|
const dirs = [
|
|
313684
|
-
|
|
313685
|
-
|
|
313862
|
+
join89(this.repoRoot, ".oa", "memory"),
|
|
313863
|
+
join89(this.repoRoot, ".open-agents", "memory")
|
|
313686
313864
|
];
|
|
313687
313865
|
for (const dir of dirs) {
|
|
313688
|
-
if (!
|
|
313866
|
+
if (!existsSync72(dir)) continue;
|
|
313689
313867
|
try {
|
|
313690
313868
|
const files = readdirSync21(dir).filter((f2) => f2.endsWith(".json"));
|
|
313691
313869
|
for (const f2 of files) {
|
|
@@ -313699,8 +313877,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313699
313877
|
}
|
|
313700
313878
|
// ── State persistence ─────────────────────────────────────────────────
|
|
313701
313879
|
loadState() {
|
|
313702
|
-
const path5 =
|
|
313703
|
-
if (
|
|
313880
|
+
const path5 = join89(this.stateDir, "state.json");
|
|
313881
|
+
if (existsSync72(path5)) {
|
|
313704
313882
|
try {
|
|
313705
313883
|
this.state = JSON.parse(readFileSync57(path5, "utf-8"));
|
|
313706
313884
|
} catch {
|
|
@@ -313709,8 +313887,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313709
313887
|
}
|
|
313710
313888
|
saveState() {
|
|
313711
313889
|
try {
|
|
313712
|
-
|
|
313713
|
-
|
|
313890
|
+
writeFileSync40(
|
|
313891
|
+
join89(this.stateDir, "state.json"),
|
|
313714
313892
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
313715
313893
|
"utf-8"
|
|
313716
313894
|
);
|
|
@@ -313720,8 +313898,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313720
313898
|
saveCycleResult(result) {
|
|
313721
313899
|
try {
|
|
313722
313900
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
313723
|
-
|
|
313724
|
-
|
|
313901
|
+
writeFileSync40(
|
|
313902
|
+
join89(this.historyDir, filename),
|
|
313725
313903
|
JSON.stringify(result, null, 2) + "\n",
|
|
313726
313904
|
"utf-8"
|
|
313727
313905
|
);
|
|
@@ -313729,7 +313907,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313729
313907
|
if (files.length > 50) {
|
|
313730
313908
|
for (const old of files.slice(0, files.length - 50)) {
|
|
313731
313909
|
try {
|
|
313732
|
-
unlinkSync19(
|
|
313910
|
+
unlinkSync19(join89(this.historyDir, old));
|
|
313733
313911
|
} catch {
|
|
313734
313912
|
}
|
|
313735
313913
|
}
|
|
@@ -313742,8 +313920,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
313742
313920
|
});
|
|
313743
313921
|
|
|
313744
313922
|
// packages/cli/src/tui/snr-engine.ts
|
|
313745
|
-
import { existsSync as
|
|
313746
|
-
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";
|
|
313747
313925
|
function computeDPrime(signalScores, noiseScores) {
|
|
313748
313926
|
if (signalScores.length === 0 || noiseScores.length === 0) return 0;
|
|
313749
313927
|
const mean = (arr) => arr.reduce((s2, v) => s2 + v, 0) / arr.length;
|
|
@@ -314027,18 +314205,18 @@ Call task_complete with the JSON array when done.`,
|
|
|
314027
314205
|
loadMemoryEntries(topics) {
|
|
314028
314206
|
const entries = [];
|
|
314029
314207
|
const dirs = [
|
|
314030
|
-
|
|
314031
|
-
|
|
314208
|
+
join90(this.repoRoot, ".oa", "memory"),
|
|
314209
|
+
join90(this.repoRoot, ".open-agents", "memory")
|
|
314032
314210
|
];
|
|
314033
314211
|
for (const dir of dirs) {
|
|
314034
|
-
if (!
|
|
314212
|
+
if (!existsSync73(dir)) continue;
|
|
314035
314213
|
try {
|
|
314036
314214
|
const files = readdirSync22(dir).filter((f2) => f2.endsWith(".json"));
|
|
314037
314215
|
for (const f2 of files) {
|
|
314038
314216
|
const topic = basename17(f2, ".json");
|
|
314039
314217
|
if (topics.length > 0 && !topics.includes(topic)) continue;
|
|
314040
314218
|
try {
|
|
314041
|
-
const data = JSON.parse(readFileSync58(
|
|
314219
|
+
const data = JSON.parse(readFileSync58(join90(dir, f2), "utf-8"));
|
|
314042
314220
|
for (const [key, val] of Object.entries(data)) {
|
|
314043
314221
|
const value2 = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
314044
314222
|
entries.push({ topic, key, value: value2 });
|
|
@@ -314582,8 +314760,8 @@ var init_tool_policy = __esm({
|
|
|
314582
314760
|
});
|
|
314583
314761
|
|
|
314584
314762
|
// packages/cli/src/tui/telegram-bridge.ts
|
|
314585
|
-
import { mkdirSync as
|
|
314586
|
-
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";
|
|
314587
314765
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
314588
314766
|
function convertMarkdownToTelegramHTML(md) {
|
|
314589
314767
|
let html = md;
|
|
@@ -314906,7 +315084,7 @@ with summary "no_reply" to silently skip without responding.
|
|
|
314906
315084
|
this.polling = true;
|
|
314907
315085
|
this.abortController = new AbortController();
|
|
314908
315086
|
try {
|
|
314909
|
-
|
|
315087
|
+
mkdirSync44(this.mediaCacheDir, { recursive: true });
|
|
314910
315088
|
} catch {
|
|
314911
315089
|
}
|
|
314912
315090
|
this.mediaCacheCleanupTimer = setInterval(() => this.cleanupMediaCache(), 5 * 60 * 1e3);
|
|
@@ -315339,7 +315517,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
|
|
|
315339
315517
|
if (!res.ok) return null;
|
|
315340
315518
|
const buffer2 = Buffer.from(await res.arrayBuffer());
|
|
315341
315519
|
const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension2}`;
|
|
315342
|
-
const localPath =
|
|
315520
|
+
const localPath = join91(this.mediaCacheDir, fileName);
|
|
315343
315521
|
await writeFileAsync(localPath, buffer2);
|
|
315344
315522
|
return localPath;
|
|
315345
315523
|
} catch {
|
|
@@ -315802,43 +315980,43 @@ __export(chat_session_exports, {
|
|
|
315802
315980
|
});
|
|
315803
315981
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
315804
315982
|
import {
|
|
315805
|
-
existsSync as
|
|
315983
|
+
existsSync as existsSync75,
|
|
315806
315984
|
readFileSync as readFileSync59,
|
|
315807
315985
|
readdirSync as readdirSync24,
|
|
315808
|
-
writeFileSync as
|
|
315986
|
+
writeFileSync as writeFileSync41,
|
|
315809
315987
|
renameSync as renameSync4,
|
|
315810
|
-
mkdirSync as
|
|
315988
|
+
mkdirSync as mkdirSync45,
|
|
315811
315989
|
unlinkSync as unlinkSync21
|
|
315812
315990
|
} from "node:fs";
|
|
315813
|
-
import { join as
|
|
315814
|
-
import { homedir as
|
|
315991
|
+
import { join as join92 } from "node:path";
|
|
315992
|
+
import { homedir as homedir33 } from "node:os";
|
|
315815
315993
|
function sessionsDir() {
|
|
315816
|
-
return
|
|
315994
|
+
return join92(homedir33(), ".open-agents", "chat-sessions");
|
|
315817
315995
|
}
|
|
315818
315996
|
function sessionPath(id) {
|
|
315819
315997
|
const safe = id.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
315820
|
-
return
|
|
315998
|
+
return join92(sessionsDir(), `${safe}.json`);
|
|
315821
315999
|
}
|
|
315822
316000
|
function inFlightPath(id) {
|
|
315823
316001
|
const safe = id.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
315824
|
-
return
|
|
316002
|
+
return join92(sessionsDir(), `${safe}.inflight.json`);
|
|
315825
316003
|
}
|
|
315826
316004
|
function persistSession(s2) {
|
|
315827
316005
|
try {
|
|
315828
|
-
|
|
316006
|
+
mkdirSync45(sessionsDir(), { recursive: true });
|
|
315829
316007
|
const final2 = sessionPath(s2.id);
|
|
315830
316008
|
const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
|
|
315831
|
-
|
|
316009
|
+
writeFileSync41(tmp, JSON.stringify(s2, null, 2), "utf-8");
|
|
315832
316010
|
renameSync4(tmp, final2);
|
|
315833
316011
|
} catch {
|
|
315834
316012
|
}
|
|
315835
316013
|
}
|
|
315836
316014
|
function persistInFlight(j) {
|
|
315837
316015
|
try {
|
|
315838
|
-
|
|
316016
|
+
mkdirSync45(sessionsDir(), { recursive: true });
|
|
315839
316017
|
const final2 = inFlightPath(j.sessionId);
|
|
315840
316018
|
const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
|
|
315841
|
-
|
|
316019
|
+
writeFileSync41(tmp, JSON.stringify(j, null, 2), "utf-8");
|
|
315842
316020
|
renameSync4(tmp, final2);
|
|
315843
316021
|
} catch {
|
|
315844
316022
|
}
|
|
@@ -315846,7 +316024,7 @@ function persistInFlight(j) {
|
|
|
315846
316024
|
function deleteInFlightFile(id) {
|
|
315847
316025
|
try {
|
|
315848
316026
|
const p2 = inFlightPath(id);
|
|
315849
|
-
if (
|
|
316027
|
+
if (existsSync75(p2)) unlinkSync21(p2);
|
|
315850
316028
|
} catch {
|
|
315851
316029
|
}
|
|
315852
316030
|
}
|
|
@@ -315854,11 +316032,11 @@ function loadPersistedSessions() {
|
|
|
315854
316032
|
const report = { restored: 0, staleInFlight: 0 };
|
|
315855
316033
|
try {
|
|
315856
316034
|
const dir = sessionsDir();
|
|
315857
|
-
if (!
|
|
316035
|
+
if (!existsSync75(dir)) return report;
|
|
315858
316036
|
const cutoff = Date.now() - SESSION_TTL_MS;
|
|
315859
316037
|
for (const f2 of readdirSync24(dir)) {
|
|
315860
316038
|
if (!f2.endsWith(".json") || f2.includes(".tmp.")) continue;
|
|
315861
|
-
const fp =
|
|
316039
|
+
const fp = join92(dir, f2);
|
|
315862
316040
|
try {
|
|
315863
316041
|
const parsed = JSON.parse(readFileSync59(fp, "utf-8"));
|
|
315864
316042
|
if (f2.endsWith(".inflight.json")) {
|
|
@@ -315870,7 +316048,7 @@ function loadPersistedSessions() {
|
|
|
315870
316048
|
parsed.error = "Daemon restart while subprocess was running";
|
|
315871
316049
|
parsed.completedAt = Date.now();
|
|
315872
316050
|
try {
|
|
315873
|
-
|
|
316051
|
+
writeFileSync41(fp, JSON.stringify(parsed, null, 2), "utf-8");
|
|
315874
316052
|
} catch {
|
|
315875
316053
|
}
|
|
315876
316054
|
report.staleInFlight++;
|
|
@@ -315897,23 +316075,23 @@ function buildSystemPrompt(cwd4) {
|
|
|
315897
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."
|
|
315898
316076
|
);
|
|
315899
316077
|
parts.push(`\\nEnvironment: ${process.platform}, Node ${process.version}, CWD: ${cwd4}`);
|
|
315900
|
-
const diaryPath =
|
|
315901
|
-
if (
|
|
316078
|
+
const diaryPath = join92(cwd4, ".oa", "context", "session-diary.md");
|
|
316079
|
+
if (existsSync75(diaryPath)) {
|
|
315902
316080
|
try {
|
|
315903
316081
|
const diary = readFileSync59(diaryPath, "utf-8").slice(0, 1e3);
|
|
315904
316082
|
parts.push(`\\nPrevious session history:\\n${diary}`);
|
|
315905
316083
|
} catch {
|
|
315906
316084
|
}
|
|
315907
316085
|
}
|
|
315908
|
-
const memDir =
|
|
315909
|
-
if (
|
|
316086
|
+
const memDir = join92(cwd4, ".oa", "memory");
|
|
316087
|
+
if (existsSync75(memDir)) {
|
|
315910
316088
|
try {
|
|
315911
316089
|
const files = readdirSync24(memDir).filter((f2) => f2.endsWith(".json")).slice(0, 5);
|
|
315912
316090
|
if (files.length > 0) {
|
|
315913
316091
|
parts.push("\\nPersistent memory topics: " + files.map((f2) => f2.replace(".json", "")).join(", "));
|
|
315914
316092
|
for (const f2 of files.slice(0, 3)) {
|
|
315915
316093
|
try {
|
|
315916
|
-
const data = JSON.parse(readFileSync59(
|
|
316094
|
+
const data = JSON.parse(readFileSync59(join92(memDir, f2), "utf-8"));
|
|
315917
316095
|
const entries = Object.entries(data).slice(0, 3);
|
|
315918
316096
|
if (entries.length > 0) {
|
|
315919
316097
|
parts.push(`\\nMemory [${f2.replace(".json", "")}]: ` + entries.map(([k, v]) => `${k}: ${String(v.value ?? v).slice(0, 100)}`).join("; "));
|
|
@@ -315926,8 +316104,8 @@ function buildSystemPrompt(cwd4) {
|
|
|
315926
316104
|
}
|
|
315927
316105
|
}
|
|
315928
316106
|
for (const name11 of ["AGENTS.md", "OA.md", ".open-agents.md"]) {
|
|
315929
|
-
const p2 =
|
|
315930
|
-
if (
|
|
316107
|
+
const p2 = join92(cwd4, name11);
|
|
316108
|
+
if (existsSync75(p2)) {
|
|
315931
316109
|
try {
|
|
315932
316110
|
const content = readFileSync59(p2, "utf-8").slice(0, 500);
|
|
315933
316111
|
parts.push(`\\nProject instructions (${name11}):\\n${content}`);
|
|
@@ -315946,7 +316124,7 @@ function getSession(sessionId, model, cwd4) {
|
|
|
315946
316124
|
if (sessionId) {
|
|
315947
316125
|
try {
|
|
315948
316126
|
const fp = sessionPath(sessionId);
|
|
315949
|
-
if (
|
|
316127
|
+
if (existsSync75(fp)) {
|
|
315950
316128
|
const parsed = JSON.parse(readFileSync59(fp, "utf-8"));
|
|
315951
316129
|
if (parsed && parsed.id === sessionId) {
|
|
315952
316130
|
parsed.lastActivity = Date.now();
|
|
@@ -316049,11 +316227,11 @@ function addTriageResponseMessage(session, acknowledgment, steering) {
|
|
|
316049
316227
|
}
|
|
316050
316228
|
function checkinPath(sessionId) {
|
|
316051
316229
|
const safe = sessionId.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
316052
|
-
return
|
|
316230
|
+
return join92(sessionsDir(), `${safe}.checkins.jsonl`);
|
|
316053
316231
|
}
|
|
316054
316232
|
function appendCheckin(sessionId, steering) {
|
|
316055
316233
|
try {
|
|
316056
|
-
|
|
316234
|
+
mkdirSync45(sessionsDir(), { recursive: true });
|
|
316057
316235
|
const fp = checkinPath(sessionId);
|
|
316058
316236
|
const entry = JSON.stringify({ ts: Date.now(), steering }) + "\n";
|
|
316059
316237
|
const { appendFileSync: appendFileSync7 } = __require("node:fs");
|
|
@@ -316063,7 +316241,7 @@ function appendCheckin(sessionId, steering) {
|
|
|
316063
316241
|
}
|
|
316064
316242
|
function drainCheckins(sessionId) {
|
|
316065
316243
|
const fp = checkinPath(sessionId);
|
|
316066
|
-
if (!
|
|
316244
|
+
if (!existsSync75(fp)) return [];
|
|
316067
316245
|
try {
|
|
316068
316246
|
const raw = readFileSync59(fp, "utf-8");
|
|
316069
316247
|
try {
|
|
@@ -316105,7 +316283,7 @@ function listSessions2() {
|
|
|
316105
316283
|
function deleteSession2(id) {
|
|
316106
316284
|
try {
|
|
316107
316285
|
const p2 = sessionPath(id);
|
|
316108
|
-
if (
|
|
316286
|
+
if (existsSync75(p2)) unlinkSync21(p2);
|
|
316109
316287
|
} catch {
|
|
316110
316288
|
}
|
|
316111
316289
|
deleteInFlightFile(id);
|
|
@@ -316117,7 +316295,7 @@ function lookupSession(id) {
|
|
|
316117
316295
|
if (cached) return cached;
|
|
316118
316296
|
try {
|
|
316119
316297
|
const fp = sessionPath(id);
|
|
316120
|
-
if (
|
|
316298
|
+
if (existsSync75(fp)) {
|
|
316121
316299
|
const parsed = JSON.parse(readFileSync59(fp, "utf-8"));
|
|
316122
316300
|
if (parsed && parsed.id === id) {
|
|
316123
316301
|
sessions.set(id, parsed);
|
|
@@ -316170,7 +316348,7 @@ function getInFlightChat(sessionId) {
|
|
|
316170
316348
|
if (cached) return cached;
|
|
316171
316349
|
try {
|
|
316172
316350
|
const p2 = inFlightPath(sessionId);
|
|
316173
|
-
if (
|
|
316351
|
+
if (existsSync75(p2)) {
|
|
316174
316352
|
const parsed = JSON.parse(readFileSync59(p2, "utf-8"));
|
|
316175
316353
|
if (parsed && parsed.sessionId === sessionId) {
|
|
316176
316354
|
return parsed;
|
|
@@ -316816,13 +316994,13 @@ __export(audit_log_exports, {
|
|
|
316816
316994
|
recordAudit: () => recordAudit,
|
|
316817
316995
|
sanitizeBody: () => sanitizeBody
|
|
316818
316996
|
});
|
|
316819
|
-
import { mkdirSync as
|
|
316820
|
-
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";
|
|
316821
316999
|
function initAuditLog(oaDir) {
|
|
316822
|
-
auditDir =
|
|
316823
|
-
auditFile =
|
|
317000
|
+
auditDir = join93(oaDir, "audit");
|
|
317001
|
+
auditFile = join93(auditDir, "audit.jsonl");
|
|
316824
317002
|
try {
|
|
316825
|
-
|
|
317003
|
+
mkdirSync46(auditDir, { recursive: true });
|
|
316826
317004
|
initialized = true;
|
|
316827
317005
|
} catch {
|
|
316828
317006
|
}
|
|
@@ -316851,7 +317029,7 @@ function sanitizeBody(body, maxLen = 200) {
|
|
|
316851
317029
|
return safe.length > maxLen ? safe.slice(0, maxLen) + "..." : safe;
|
|
316852
317030
|
}
|
|
316853
317031
|
function queryAudit(opts) {
|
|
316854
|
-
if (!initialized || !
|
|
317032
|
+
if (!initialized || !existsSync76(auditFile)) return [];
|
|
316855
317033
|
try {
|
|
316856
317034
|
const raw = readFileSync60(auditFile, "utf-8");
|
|
316857
317035
|
const lines = raw.split("\n").filter(Boolean);
|
|
@@ -316890,7 +317068,7 @@ var init_audit_log = __esm({
|
|
|
316890
317068
|
|
|
316891
317069
|
// packages/cli/src/api/disk-task-output.ts
|
|
316892
317070
|
import { open } from "node:fs/promises";
|
|
316893
|
-
import { existsSync as
|
|
317071
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync47, statSync as statSync21 } from "node:fs";
|
|
316894
317072
|
import { dirname as dirname27 } from "node:path";
|
|
316895
317073
|
import * as fsConstants from "node:constants";
|
|
316896
317074
|
var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
|
|
@@ -316910,7 +317088,7 @@ var init_disk_task_output = __esm({
|
|
|
316910
317088
|
fileSize = 0;
|
|
316911
317089
|
constructor(outputPath) {
|
|
316912
317090
|
this.path = outputPath;
|
|
316913
|
-
|
|
317091
|
+
mkdirSync47(dirname27(outputPath), { recursive: true });
|
|
316914
317092
|
}
|
|
316915
317093
|
/** Queue content for async append. Non-blocking. */
|
|
316916
317094
|
append(chunk) {
|
|
@@ -316986,7 +317164,7 @@ var init_disk_task_output = __esm({
|
|
|
316986
317164
|
async readFrom(offset, limit = 65536) {
|
|
316987
317165
|
let handle2 = null;
|
|
316988
317166
|
try {
|
|
316989
|
-
if (!
|
|
317167
|
+
if (!existsSync77(this.path)) {
|
|
316990
317168
|
return { content: "", nextOffset: offset, eof: true, size: 0 };
|
|
316991
317169
|
}
|
|
316992
317170
|
const st = statSync21(this.path);
|
|
@@ -317188,19 +317366,19 @@ __export(aiwg_exports, {
|
|
|
317188
317366
|
resolveAiwgRoot: () => resolveAiwgRoot,
|
|
317189
317367
|
tryRouteAiwg: () => tryRouteAiwg
|
|
317190
317368
|
});
|
|
317191
|
-
import { existsSync as
|
|
317192
|
-
import { join as
|
|
317193
|
-
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";
|
|
317194
317372
|
import { execSync as execSync53 } from "node:child_process";
|
|
317195
317373
|
function resolveAiwgRoot() {
|
|
317196
317374
|
if (_cachedAiwgRoot !== void 0) return _cachedAiwgRoot;
|
|
317197
317375
|
const envRoot = process.env["OA_AIWG_ROOT"];
|
|
317198
|
-
if (envRoot &&
|
|
317376
|
+
if (envRoot && existsSync78(join94(envRoot, "package.json"))) {
|
|
317199
317377
|
_cachedAiwgRoot = envRoot;
|
|
317200
317378
|
return envRoot;
|
|
317201
317379
|
}
|
|
317202
|
-
const shareDir =
|
|
317203
|
-
if (
|
|
317380
|
+
const shareDir = join94(homedir34(), ".local", "share", "ai-writing-guide");
|
|
317381
|
+
if (existsSync78(join94(shareDir, "agentic"))) {
|
|
317204
317382
|
_cachedAiwgRoot = shareDir;
|
|
317205
317383
|
return shareDir;
|
|
317206
317384
|
}
|
|
@@ -317210,8 +317388,8 @@ function resolveAiwgRoot() {
|
|
|
317210
317388
|
timeout: 5e3,
|
|
317211
317389
|
stdio: ["pipe", "pipe", "pipe"]
|
|
317212
317390
|
}).trim();
|
|
317213
|
-
const candidate =
|
|
317214
|
-
if (
|
|
317391
|
+
const candidate = join94(globalRoot, "aiwg");
|
|
317392
|
+
if (existsSync78(join94(candidate, "package.json"))) {
|
|
317215
317393
|
_cachedAiwgRoot = candidate;
|
|
317216
317394
|
return candidate;
|
|
317217
317395
|
}
|
|
@@ -317222,22 +317400,22 @@ function resolveAiwgRoot() {
|
|
|
317222
317400
|
"/usr/lib/node_modules/aiwg",
|
|
317223
317401
|
"/opt/homebrew/lib/node_modules/aiwg"
|
|
317224
317402
|
]) {
|
|
317225
|
-
if (
|
|
317403
|
+
if (existsSync78(join94(p2, "package.json"))) {
|
|
317226
317404
|
_cachedAiwgRoot = p2;
|
|
317227
317405
|
return p2;
|
|
317228
317406
|
}
|
|
317229
317407
|
}
|
|
317230
317408
|
const versionDirs = [
|
|
317231
|
-
|
|
317232
|
-
|
|
317409
|
+
join94(homedir34(), ".nvm", "versions", "node"),
|
|
317410
|
+
join94(homedir34(), ".local", "share", "fnm", "node-versions")
|
|
317233
317411
|
];
|
|
317234
317412
|
for (const vdir of versionDirs) {
|
|
317235
|
-
if (!
|
|
317413
|
+
if (!existsSync78(vdir)) continue;
|
|
317236
317414
|
try {
|
|
317237
317415
|
for (const ver of readdirSync25(vdir)) {
|
|
317238
317416
|
for (const prefix of ["lib/node_modules/aiwg", "installation/lib/node_modules/aiwg"]) {
|
|
317239
|
-
const cand =
|
|
317240
|
-
if (
|
|
317417
|
+
const cand = join94(vdir, ver, prefix);
|
|
317418
|
+
if (existsSync78(join94(cand, "package.json"))) {
|
|
317241
317419
|
_cachedAiwgRoot = cand;
|
|
317242
317420
|
return cand;
|
|
317243
317421
|
}
|
|
@@ -317255,9 +317433,9 @@ function resolveAiwgRoot() {
|
|
|
317255
317433
|
if (whichAiwg) {
|
|
317256
317434
|
let cur = whichAiwg;
|
|
317257
317435
|
for (let i2 = 0; i2 < 8; i2++) {
|
|
317258
|
-
cur =
|
|
317259
|
-
const pj =
|
|
317260
|
-
if (
|
|
317436
|
+
cur = join94(cur, "..");
|
|
317437
|
+
const pj = join94(cur, "package.json");
|
|
317438
|
+
if (existsSync78(pj)) {
|
|
317261
317439
|
try {
|
|
317262
317440
|
const pkg = JSON.parse(readFileSync61(pj, "utf-8"));
|
|
317263
317441
|
if (pkg.name === "aiwg") {
|
|
@@ -317281,14 +317459,14 @@ function listAiwgFrameworks() {
|
|
|
317281
317459
|
_cachedFrameworks = [];
|
|
317282
317460
|
return _cachedFrameworks;
|
|
317283
317461
|
}
|
|
317284
|
-
const frameworksDir =
|
|
317285
|
-
if (!
|
|
317462
|
+
const frameworksDir = join94(root, "agentic", "code", "frameworks");
|
|
317463
|
+
if (!existsSync78(frameworksDir)) {
|
|
317286
317464
|
_cachedFrameworks = [];
|
|
317287
317465
|
return _cachedFrameworks;
|
|
317288
317466
|
}
|
|
317289
317467
|
const out = [];
|
|
317290
317468
|
for (const name11 of readdirSync25(frameworksDir)) {
|
|
317291
|
-
const p2 =
|
|
317469
|
+
const p2 = join94(frameworksDir, name11);
|
|
317292
317470
|
try {
|
|
317293
317471
|
const st = statSync22(p2);
|
|
317294
317472
|
if (!st.isDirectory()) continue;
|
|
@@ -317316,7 +317494,7 @@ function aggregateDir(dir, depth = 0) {
|
|
|
317316
317494
|
try {
|
|
317317
317495
|
for (const e2 of readdirSync25(dir, { withFileTypes: true })) {
|
|
317318
317496
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
317319
|
-
const p2 =
|
|
317497
|
+
const p2 = join94(dir, e2.name);
|
|
317320
317498
|
if (e2.isDirectory()) {
|
|
317321
317499
|
const sub = aggregateDir(p2, depth + 1);
|
|
317322
317500
|
out.files += sub.files;
|
|
@@ -317346,8 +317524,8 @@ function aggregateDir(dir, depth = 0) {
|
|
|
317346
317524
|
}
|
|
317347
317525
|
function readFirstLineDescription(dir) {
|
|
317348
317526
|
for (const candidate of ["README.md", "SKILL.md", "INDEX.md"]) {
|
|
317349
|
-
const p2 =
|
|
317350
|
-
if (!
|
|
317527
|
+
const p2 = join94(dir, candidate);
|
|
317528
|
+
if (!existsSync78(p2)) continue;
|
|
317351
317529
|
try {
|
|
317352
317530
|
const txt = readFileSync61(p2, "utf-8");
|
|
317353
317531
|
const descMatch = txt.match(/^description:\s*(.+)$/m);
|
|
@@ -317371,12 +317549,12 @@ function listAiwgItems() {
|
|
|
317371
317549
|
}
|
|
317372
317550
|
const out = [];
|
|
317373
317551
|
const walkRoots = [
|
|
317374
|
-
|
|
317375
|
-
|
|
317376
|
-
|
|
317552
|
+
join94(root, "agentic", "code", "frameworks"),
|
|
317553
|
+
join94(root, "agentic", "code", "addons"),
|
|
317554
|
+
join94(root, "plugins")
|
|
317377
317555
|
];
|
|
317378
317556
|
for (const wr of walkRoots) {
|
|
317379
|
-
if (!
|
|
317557
|
+
if (!existsSync78(wr)) continue;
|
|
317380
317558
|
walkForItems(wr, out, 0);
|
|
317381
317559
|
}
|
|
317382
317560
|
_cachedItems = out;
|
|
@@ -317387,7 +317565,7 @@ function walkForItems(dir, out, depth) {
|
|
|
317387
317565
|
try {
|
|
317388
317566
|
for (const e2 of readdirSync25(dir, { withFileTypes: true })) {
|
|
317389
317567
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
317390
|
-
const p2 =
|
|
317568
|
+
const p2 = join94(dir, e2.name);
|
|
317391
317569
|
if (e2.isDirectory()) {
|
|
317392
317570
|
walkForItems(p2, out, depth + 1);
|
|
317393
317571
|
} else if (e2.isFile() && e2.name.endsWith(".md")) {
|
|
@@ -317438,7 +317616,7 @@ function deriveSource(p2) {
|
|
|
317438
317616
|
}
|
|
317439
317617
|
function loadAiwgItemContent(path5, maxBytes = 2e4) {
|
|
317440
317618
|
try {
|
|
317441
|
-
if (!
|
|
317619
|
+
if (!existsSync78(path5)) return null;
|
|
317442
317620
|
const raw = readFileSync61(path5, "utf-8");
|
|
317443
317621
|
return raw.length > maxBytes ? raw.slice(0, maxBytes) + "\n\n...(truncated for context budget)" : raw;
|
|
317444
317622
|
} catch {
|
|
@@ -317452,14 +317630,14 @@ function listAiwgAddons() {
|
|
|
317452
317630
|
_cachedAddons = [];
|
|
317453
317631
|
return _cachedAddons;
|
|
317454
317632
|
}
|
|
317455
|
-
const addonsDir =
|
|
317456
|
-
if (!
|
|
317633
|
+
const addonsDir = join94(root, "agentic", "code", "addons");
|
|
317634
|
+
if (!existsSync78(addonsDir)) {
|
|
317457
317635
|
_cachedAddons = [];
|
|
317458
317636
|
return _cachedAddons;
|
|
317459
317637
|
}
|
|
317460
317638
|
const out = [];
|
|
317461
317639
|
for (const name11 of readdirSync25(addonsDir)) {
|
|
317462
|
-
const p2 =
|
|
317640
|
+
const p2 = join94(addonsDir, name11);
|
|
317463
317641
|
try {
|
|
317464
317642
|
const st = statSync22(p2);
|
|
317465
317643
|
if (!st.isDirectory()) continue;
|
|
@@ -317941,9 +318119,9 @@ var init_aiwg = __esm({
|
|
|
317941
318119
|
});
|
|
317942
318120
|
|
|
317943
318121
|
// packages/cli/src/api/routes-v1.ts
|
|
317944
|
-
import { existsSync as
|
|
317945
|
-
import { join as
|
|
317946
|
-
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";
|
|
317947
318125
|
async function tryRouteV1(ctx3) {
|
|
317948
318126
|
const { pathname, method } = ctx3;
|
|
317949
318127
|
if (pathname === "/v1/skills" && method === "GET") {
|
|
@@ -318148,11 +318326,11 @@ async function handleGetSkill(ctx3, name11) {
|
|
|
318148
318326
|
async function fallbackDiscoverSkills() {
|
|
318149
318327
|
return (_root) => {
|
|
318150
318328
|
const roots = [
|
|
318151
|
-
|
|
318329
|
+
join95(homedir35(), ".local", "share", "ai-writing-guide")
|
|
318152
318330
|
];
|
|
318153
318331
|
const out = [];
|
|
318154
318332
|
for (const root of roots) {
|
|
318155
|
-
if (!
|
|
318333
|
+
if (!existsSync79(root)) continue;
|
|
318156
318334
|
walkForSkills(root, out, 0);
|
|
318157
318335
|
}
|
|
318158
318336
|
return out;
|
|
@@ -318163,7 +318341,7 @@ function walkForSkills(dir, out, depth) {
|
|
|
318163
318341
|
try {
|
|
318164
318342
|
for (const e2 of readdirSync26(dir, { withFileTypes: true })) {
|
|
318165
318343
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
318166
|
-
const p2 =
|
|
318344
|
+
const p2 = join95(dir, e2.name);
|
|
318167
318345
|
if (e2.isDirectory()) {
|
|
318168
318346
|
walkForSkills(p2, out, depth + 1);
|
|
318169
318347
|
} else if (e2.isFile() && e2.name === "SKILL.md") {
|
|
@@ -318352,7 +318530,7 @@ async function getMemoryStores() {
|
|
|
318352
318530
|
if (memoryInitTried) return null;
|
|
318353
318531
|
memoryInitTried = true;
|
|
318354
318532
|
try {
|
|
318355
|
-
const dbPath =
|
|
318533
|
+
const dbPath = join95(homedir35(), ".open-agents", "memory.db");
|
|
318356
318534
|
const sharedDb = initDb(dbPath);
|
|
318357
318535
|
memoryStoresCache = {
|
|
318358
318536
|
episode: new EpisodeStore(dbPath),
|
|
@@ -318610,7 +318788,7 @@ async function handleFilesRead(ctx3) {
|
|
|
318610
318788
|
}));
|
|
318611
318789
|
return true;
|
|
318612
318790
|
}
|
|
318613
|
-
if (!
|
|
318791
|
+
if (!existsSync79(resolved)) {
|
|
318614
318792
|
sendProblem(res, problemDetails({
|
|
318615
318793
|
type: P.notFound,
|
|
318616
318794
|
status: 404,
|
|
@@ -318873,12 +319051,12 @@ async function handleNexusStatus(ctx3) {
|
|
|
318873
319051
|
const { res, requestId } = ctx3;
|
|
318874
319052
|
try {
|
|
318875
319053
|
const statePaths = [
|
|
318876
|
-
|
|
318877
|
-
|
|
319054
|
+
join95(process.cwd(), ".oa", "nexus-peer-state.json"),
|
|
319055
|
+
join95(homedir35(), ".open-agents", "nexus-peer-cache.json")
|
|
318878
319056
|
];
|
|
318879
319057
|
const states = [];
|
|
318880
319058
|
for (const p2 of statePaths) {
|
|
318881
|
-
if (!
|
|
319059
|
+
if (!existsSync79(p2)) continue;
|
|
318882
319060
|
try {
|
|
318883
319061
|
const raw = readFileSync62(p2, "utf-8");
|
|
318884
319062
|
states.push({ source: p2, data: JSON.parse(raw) });
|
|
@@ -318907,8 +319085,8 @@ async function handleNexusStatus(ctx3) {
|
|
|
318907
319085
|
}
|
|
318908
319086
|
function loadAgentName() {
|
|
318909
319087
|
try {
|
|
318910
|
-
const p2 =
|
|
318911
|
-
if (
|
|
319088
|
+
const p2 = join95(homedir35(), ".open-agents", "agent-name");
|
|
319089
|
+
if (existsSync79(p2)) return readFileSync62(p2, "utf-8").trim();
|
|
318912
319090
|
} catch {
|
|
318913
319091
|
}
|
|
318914
319092
|
return null;
|
|
@@ -318917,12 +319095,12 @@ async function handleSponsors(ctx3) {
|
|
|
318917
319095
|
const { req: req2, res, url, requestId } = ctx3;
|
|
318918
319096
|
try {
|
|
318919
319097
|
const candidates = [
|
|
318920
|
-
|
|
318921
|
-
|
|
319098
|
+
join95(homedir35(), ".open-agents", "sponsor-cache.json"),
|
|
319099
|
+
join95(homedir35(), ".open-agents", "sponsors.json")
|
|
318922
319100
|
];
|
|
318923
319101
|
let sponsors = [];
|
|
318924
319102
|
for (const p2 of candidates) {
|
|
318925
|
-
if (!
|
|
319103
|
+
if (!existsSync79(p2)) continue;
|
|
318926
319104
|
try {
|
|
318927
319105
|
const raw = JSON.parse(readFileSync62(p2, "utf-8"));
|
|
318928
319106
|
if (Array.isArray(raw)) {
|
|
@@ -318993,8 +319171,8 @@ async function handleEvaluate(ctx3) {
|
|
|
318993
319171
|
}));
|
|
318994
319172
|
return true;
|
|
318995
319173
|
}
|
|
318996
|
-
const jobPath =
|
|
318997
|
-
if (!
|
|
319174
|
+
const jobPath = join95(process.cwd(), ".oa", "jobs", `${runId}.json`);
|
|
319175
|
+
if (!existsSync79(jobPath)) {
|
|
318998
319176
|
sendProblem(res, problemDetails({
|
|
318999
319177
|
type: P.notFound,
|
|
319000
319178
|
status: 404,
|
|
@@ -319142,17 +319320,17 @@ async function handleListAgentTypes(ctx3) {
|
|
|
319142
319320
|
}
|
|
319143
319321
|
async function handleListEngines(ctx3) {
|
|
319144
319322
|
const { res } = ctx3;
|
|
319145
|
-
const home =
|
|
319323
|
+
const home = homedir35();
|
|
319146
319324
|
sendJson(res, 200, {
|
|
319147
319325
|
engines: [
|
|
319148
|
-
{ name: "dream", state_file:
|
|
319149
|
-
{ name: "bless", state_file:
|
|
319150
|
-
{ name: "call", state_file:
|
|
319151
|
-
{ name: "listen", state_file:
|
|
319152
|
-
{ name: "telegram", state_file:
|
|
319153
|
-
{ name: "expose", state_file:
|
|
319154
|
-
{ name: "nexus", state_file:
|
|
319155
|
-
{ 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" }
|
|
319156
319334
|
],
|
|
319157
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."
|
|
319158
319336
|
});
|
|
@@ -319235,12 +319413,12 @@ async function tryAimsRoute(ctx3) {
|
|
|
319235
319413
|
return false;
|
|
319236
319414
|
}
|
|
319237
319415
|
function aimsDir() {
|
|
319238
|
-
return
|
|
319416
|
+
return join95(homedir35(), ".open-agents", "aims");
|
|
319239
319417
|
}
|
|
319240
319418
|
function readAimsFile(name11, fallback) {
|
|
319241
319419
|
try {
|
|
319242
|
-
const p2 =
|
|
319243
|
-
if (
|
|
319420
|
+
const p2 = join95(aimsDir(), name11);
|
|
319421
|
+
if (existsSync79(p2)) return JSON.parse(readFileSync62(p2, "utf-8"));
|
|
319244
319422
|
} catch {
|
|
319245
319423
|
}
|
|
319246
319424
|
return fallback;
|
|
@@ -319249,7 +319427,7 @@ function writeAimsFile(name11, data) {
|
|
|
319249
319427
|
const dir = aimsDir();
|
|
319250
319428
|
const { mkdirSync: mkdirSync55, writeFileSync: wf, renameSync: rn } = __require("node:fs");
|
|
319251
319429
|
mkdirSync55(dir, { recursive: true });
|
|
319252
|
-
const finalPath =
|
|
319430
|
+
const finalPath = join95(dir, name11);
|
|
319253
319431
|
const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
|
|
319254
319432
|
try {
|
|
319255
319433
|
wf(tmpPath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
@@ -319579,10 +319757,10 @@ async function handleAimsSuppliers(ctx3) {
|
|
|
319579
319757
|
}
|
|
319580
319758
|
];
|
|
319581
319759
|
const sponsorPaths = [
|
|
319582
|
-
|
|
319760
|
+
join95(homedir35(), ".open-agents", "sponsor-cache.json")
|
|
319583
319761
|
];
|
|
319584
319762
|
for (const p2 of sponsorPaths) {
|
|
319585
|
-
if (!
|
|
319763
|
+
if (!existsSync79(p2)) continue;
|
|
319586
319764
|
try {
|
|
319587
319765
|
const raw = JSON.parse(readFileSync62(p2, "utf-8"));
|
|
319588
319766
|
const list = Array.isArray(raw) ? raw : raw?.sponsors ?? [];
|
|
@@ -321597,7 +321775,11 @@ async function loadScheduled() {
|
|
|
321597
321775
|
return row;
|
|
321598
321776
|
}).join('');
|
|
321599
321777
|
el.innerHTML = '<h3 style="color:#b2920a;font-size:0.7rem;margin-bottom:8px">Scheduled Tasks</h3>' + rows
|
|
321600
|
-
+ '<div style="margin-top:6px
|
|
321778
|
+
+ '<div style="margin-top:6px;display:flex;gap:8px">'
|
|
321779
|
+
+ '<button onclick="disableAllScheduled()" title="Disable all scheduled tasks" style="background:#2a2a30;border:1px solid #5a2a2a;color:#b25f5f;padding:3px 8px;border-radius:3px;font-size:0.65rem;cursor:pointer">disable all</button>'
|
|
321780
|
+
+ '<button onclick="enableAllScheduled()" title="Enable all scheduled tasks" style="background:#2a2a30;border:1px solid #2a3a2a;color:#4ec94e;padding:3px 8px;border-radius:3px;font-size:0.65rem;cursor:pointer">enable all</button>'
|
|
321781
|
+
+ '<button onclick="killScheduled()" title="Kill OA scheduler processes" style="background:#2a2a30;border:1px solid #5a2a2a;color:#b25f5f;padding:3px 8px;border-radius:3px;font-size:0.65rem;cursor:pointer">kill OA schedulers</button>'
|
|
321782
|
+
+ '</div>';
|
|
321601
321783
|
} catch {}
|
|
321602
321784
|
}
|
|
321603
321785
|
|
|
@@ -321615,6 +321797,40 @@ async function loadScheduled() {
|
|
|
321615
321797
|
} catch {}
|
|
321616
321798
|
}
|
|
321617
321799
|
|
|
321800
|
+
(window as any).disableAllScheduled = async function() {
|
|
321801
|
+
try {
|
|
321802
|
+
const r = await fetch('/v1/scheduled', { headers: headers() });
|
|
321803
|
+
const d = await r.json();
|
|
321804
|
+
const tasks = Array.isArray(d.tasks) ? d.tasks : [];
|
|
321805
|
+
let changed = 0;
|
|
321806
|
+
for (const t of tasks) {
|
|
321807
|
+
if (t.enabled) {
|
|
321808
|
+
const rr = await fetch('/v1/scheduled/' + encodeURIComponent(t.id), { method:'POST', headers: headers(), body: JSON.stringify({ enabled: false }) });
|
|
321809
|
+
if (rr.ok) changed++;
|
|
321810
|
+
}
|
|
321811
|
+
}
|
|
321812
|
+
alert('Disabled ' + changed + ' tasks');
|
|
321813
|
+
loadScheduled();
|
|
321814
|
+
} catch {}
|
|
321815
|
+
}
|
|
321816
|
+
|
|
321817
|
+
(window as any).enableAllScheduled = async function() {
|
|
321818
|
+
try {
|
|
321819
|
+
const r = await fetch('/v1/scheduled', { headers: headers() });
|
|
321820
|
+
const d = await r.json();
|
|
321821
|
+
const tasks = Array.isArray(d.tasks) ? d.tasks : [];
|
|
321822
|
+
let changed = 0;
|
|
321823
|
+
for (const t of tasks) {
|
|
321824
|
+
if (!t.enabled) {
|
|
321825
|
+
const rr = await fetch('/v1/scheduled/' + encodeURIComponent(t.id), { method:'POST', headers: headers(), body: JSON.stringify({ enabled: true }) });
|
|
321826
|
+
if (rr.ok) changed++;
|
|
321827
|
+
}
|
|
321828
|
+
}
|
|
321829
|
+
alert('Enabled ' + changed + ' tasks');
|
|
321830
|
+
loadScheduled();
|
|
321831
|
+
} catch {}
|
|
321832
|
+
}
|
|
321833
|
+
|
|
321618
321834
|
// Agent task
|
|
321619
321835
|
let currentRunId = null;
|
|
321620
321836
|
async function loadProfiles() {
|
|
@@ -323841,14 +324057,14 @@ var init_auth_oidc = __esm({
|
|
|
323841
324057
|
});
|
|
323842
324058
|
|
|
323843
324059
|
// packages/cli/src/api/usage-tracker.ts
|
|
323844
|
-
import { mkdirSync as
|
|
323845
|
-
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";
|
|
323846
324062
|
function initUsageTracker(oaDir) {
|
|
323847
|
-
const dir =
|
|
323848
|
-
|
|
323849
|
-
usageFile =
|
|
324063
|
+
const dir = join96(oaDir, "usage");
|
|
324064
|
+
mkdirSync48(dir, { recursive: true });
|
|
324065
|
+
usageFile = join96(dir, "token-usage.json");
|
|
323850
324066
|
try {
|
|
323851
|
-
if (
|
|
324067
|
+
if (existsSync80(usageFile)) {
|
|
323852
324068
|
store = JSON.parse(readFileSync63(usageFile, "utf-8"));
|
|
323853
324069
|
}
|
|
323854
324070
|
} catch {
|
|
@@ -323885,7 +324101,7 @@ function flush2() {
|
|
|
323885
324101
|
if (!initialized2 || !dirty) return;
|
|
323886
324102
|
try {
|
|
323887
324103
|
store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
|
|
323888
|
-
|
|
324104
|
+
writeFileSync42(usageFile, JSON.stringify(store, null, 2), "utf-8");
|
|
323889
324105
|
dirty = false;
|
|
323890
324106
|
} catch {
|
|
323891
324107
|
}
|
|
@@ -323913,24 +324129,24 @@ var init_usage_tracker = __esm({
|
|
|
323913
324129
|
});
|
|
323914
324130
|
|
|
323915
324131
|
// packages/cli/src/api/profiles.ts
|
|
323916
|
-
import { existsSync as
|
|
323917
|
-
import { join as
|
|
323918
|
-
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";
|
|
323919
324135
|
import { createCipheriv as createCipheriv4, createDecipheriv as createDecipheriv4, randomBytes as randomBytes20, scryptSync as scryptSync3 } from "node:crypto";
|
|
323920
324136
|
function globalProfileDir() {
|
|
323921
|
-
return
|
|
324137
|
+
return join97(homedir36(), ".open-agents", "profiles");
|
|
323922
324138
|
}
|
|
323923
324139
|
function projectProfileDir(projectDir) {
|
|
323924
|
-
return
|
|
324140
|
+
return join97(projectDir || process.cwd(), ".oa", "profiles");
|
|
323925
324141
|
}
|
|
323926
324142
|
function listProfiles(projectDir) {
|
|
323927
324143
|
const result = [];
|
|
323928
324144
|
const seen = /* @__PURE__ */ new Set();
|
|
323929
324145
|
const projDir = projectProfileDir(projectDir);
|
|
323930
|
-
if (
|
|
324146
|
+
if (existsSync81(projDir)) {
|
|
323931
324147
|
for (const f2 of readdirSync27(projDir).filter((f3) => f3.endsWith(".json"))) {
|
|
323932
324148
|
try {
|
|
323933
|
-
const raw = JSON.parse(readFileSync64(
|
|
324149
|
+
const raw = JSON.parse(readFileSync64(join97(projDir, f2), "utf8"));
|
|
323934
324150
|
const name11 = f2.replace(".json", "");
|
|
323935
324151
|
seen.add(name11);
|
|
323936
324152
|
result.push({
|
|
@@ -323944,12 +324160,12 @@ function listProfiles(projectDir) {
|
|
|
323944
324160
|
}
|
|
323945
324161
|
}
|
|
323946
324162
|
const globDir = globalProfileDir();
|
|
323947
|
-
if (
|
|
324163
|
+
if (existsSync81(globDir)) {
|
|
323948
324164
|
for (const f2 of readdirSync27(globDir).filter((f3) => f3.endsWith(".json"))) {
|
|
323949
324165
|
const name11 = f2.replace(".json", "");
|
|
323950
324166
|
if (seen.has(name11)) continue;
|
|
323951
324167
|
try {
|
|
323952
|
-
const raw = JSON.parse(readFileSync64(
|
|
324168
|
+
const raw = JSON.parse(readFileSync64(join97(globDir, f2), "utf8"));
|
|
323953
324169
|
result.push({
|
|
323954
324170
|
name: name11,
|
|
323955
324171
|
description: raw.description || "",
|
|
@@ -323964,9 +324180,9 @@ function listProfiles(projectDir) {
|
|
|
323964
324180
|
}
|
|
323965
324181
|
function loadProfile(name11, password, projectDir) {
|
|
323966
324182
|
const sanitized = name11.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
323967
|
-
const projPath =
|
|
323968
|
-
const globPath =
|
|
323969
|
-
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;
|
|
323970
324186
|
if (!filePath) return null;
|
|
323971
324187
|
const raw = JSON.parse(readFileSync64(filePath, "utf8"));
|
|
323972
324188
|
if (raw.encrypted === true) {
|
|
@@ -323977,23 +324193,23 @@ function loadProfile(name11, password, projectDir) {
|
|
|
323977
324193
|
}
|
|
323978
324194
|
function saveProfile(profile, password, scope = "global", projectDir) {
|
|
323979
324195
|
const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
|
|
323980
|
-
|
|
324196
|
+
mkdirSync49(dir, { recursive: true });
|
|
323981
324197
|
const sanitized = profile.name.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
323982
|
-
const filePath =
|
|
324198
|
+
const filePath = join97(dir, `${sanitized}.json`);
|
|
323983
324199
|
profile.modified = (/* @__PURE__ */ new Date()).toISOString();
|
|
323984
324200
|
if (password) {
|
|
323985
324201
|
const encrypted = encryptProfile(profile, password);
|
|
323986
|
-
|
|
324202
|
+
writeFileSync43(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
323987
324203
|
} else {
|
|
323988
324204
|
profile.encrypted = false;
|
|
323989
|
-
|
|
324205
|
+
writeFileSync43(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
|
|
323990
324206
|
}
|
|
323991
324207
|
}
|
|
323992
324208
|
function deleteProfile(name11, scope = "global", projectDir) {
|
|
323993
324209
|
const sanitized = name11.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
323994
324210
|
const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
|
|
323995
|
-
const filePath =
|
|
323996
|
-
if (
|
|
324211
|
+
const filePath = join97(dir, `${sanitized}.json`);
|
|
324212
|
+
if (existsSync81(filePath)) {
|
|
323997
324213
|
unlinkSync22(filePath);
|
|
323998
324214
|
return true;
|
|
323999
324215
|
}
|
|
@@ -324108,23 +324324,23 @@ var init_profiles = __esm({
|
|
|
324108
324324
|
|
|
324109
324325
|
// packages/cli/src/docker.ts
|
|
324110
324326
|
import { execSync as execSync54, spawn as spawn24 } from "node:child_process";
|
|
324111
|
-
import { existsSync as
|
|
324112
|
-
import { join as
|
|
324113
|
-
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";
|
|
324114
324330
|
import { fileURLToPath as fileURLToPath16 } from "node:url";
|
|
324115
324331
|
function getDockerDir() {
|
|
324116
324332
|
try {
|
|
324117
324333
|
if (typeof __dirname !== "undefined") {
|
|
324118
|
-
return
|
|
324334
|
+
return join98(__dirname, "..", "..", "..", "docker");
|
|
324119
324335
|
}
|
|
324120
324336
|
} catch {
|
|
324121
324337
|
}
|
|
324122
324338
|
try {
|
|
324123
324339
|
const thisDir = dirname28(fileURLToPath16(import.meta.url));
|
|
324124
|
-
return
|
|
324340
|
+
return join98(thisDir, "..", "..", "..", "docker");
|
|
324125
324341
|
} catch {
|
|
324126
324342
|
}
|
|
324127
|
-
return
|
|
324343
|
+
return join98(process.cwd(), "docker");
|
|
324128
324344
|
}
|
|
324129
324345
|
function isDockerAvailable() {
|
|
324130
324346
|
try {
|
|
@@ -324255,11 +324471,11 @@ async function ensureOaImage(force = false) {
|
|
|
324255
324471
|
}
|
|
324256
324472
|
let buildContext;
|
|
324257
324473
|
const dockerDir = getDockerDir();
|
|
324258
|
-
if (
|
|
324474
|
+
if (existsSync82(join98(dockerDir, "Dockerfile"))) {
|
|
324259
324475
|
buildContext = dockerDir;
|
|
324260
324476
|
} else {
|
|
324261
|
-
buildContext =
|
|
324262
|
-
|
|
324477
|
+
buildContext = join98(homedir37(), ".oa", "docker-build");
|
|
324478
|
+
mkdirSync50(buildContext, { recursive: true });
|
|
324263
324479
|
writeDockerfiles(buildContext);
|
|
324264
324480
|
}
|
|
324265
324481
|
try {
|
|
@@ -324333,8 +324549,8 @@ chown -R node:node /workspace /home/node/.oa /home/node/.open-agents 2>/dev/null
|
|
|
324333
324549
|
if [ "$1" = "oa" ]; then shift; exec su - node -c "cd /workspace && oa $*"; fi
|
|
324334
324550
|
exec "$@"
|
|
324335
324551
|
`;
|
|
324336
|
-
|
|
324337
|
-
|
|
324552
|
+
writeFileSync44(join98(dir, "Dockerfile"), dockerfile);
|
|
324553
|
+
writeFileSync44(join98(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
|
|
324338
324554
|
}
|
|
324339
324555
|
function hasNvidiaGpu() {
|
|
324340
324556
|
try {
|
|
@@ -324401,119 +324617,6 @@ var init_docker = __esm({
|
|
|
324401
324617
|
}
|
|
324402
324618
|
});
|
|
324403
324619
|
|
|
324404
|
-
// packages/cli/src/api/py-embed.ts
|
|
324405
|
-
var py_embed_exports = {};
|
|
324406
|
-
__export(py_embed_exports, {
|
|
324407
|
-
ensureEmbedDeps: () => ensureEmbedDeps,
|
|
324408
|
-
runEmbedAudio: () => runEmbedAudio,
|
|
324409
|
-
runEmbedImage: () => runEmbedImage,
|
|
324410
|
-
runEmbedText: () => runEmbedText,
|
|
324411
|
-
runTranscribeFile: () => runTranscribeFile
|
|
324412
|
-
});
|
|
324413
|
-
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
324414
|
-
import { existsSync as existsSync82, mkdirSync as mkdirSync50, writeFileSync as writeFileSync44 } from "node:fs";
|
|
324415
|
-
import { join as join98 } from "node:path";
|
|
324416
|
-
import { homedir as homedir37 } from "node:os";
|
|
324417
|
-
function getVenvDir2() {
|
|
324418
|
-
return join98(homedir37(), ".open-agents", "venv");
|
|
324419
|
-
}
|
|
324420
|
-
function getVenvPython() {
|
|
324421
|
-
const base3 = getVenvDir2();
|
|
324422
|
-
const bin = process.platform === "win32" ? "Scripts" : "bin";
|
|
324423
|
-
const exe = process.platform === "win32" ? "python.exe" : "python3";
|
|
324424
|
-
return join98(base3, bin, exe);
|
|
324425
|
-
}
|
|
324426
|
-
function ensureEmbedDeps() {
|
|
324427
|
-
const venv = getVenvDir2();
|
|
324428
|
-
let log22 = "";
|
|
324429
|
-
try {
|
|
324430
|
-
mkdirSync50(venv, { recursive: true });
|
|
324431
|
-
} catch {
|
|
324432
|
-
}
|
|
324433
|
-
if (!existsSync82(getVenvPython())) {
|
|
324434
|
-
const mk = spawnSync5("python3", ["-m", "venv", venv], { encoding: "utf8" });
|
|
324435
|
-
log22 += mk.stdout + mk.stderr;
|
|
324436
|
-
}
|
|
324437
|
-
const pip = process.platform === "win32" ? join98(venv, "Scripts", "pip.exe") : join98(venv, "bin", "pip");
|
|
324438
|
-
const pkgs = [
|
|
324439
|
-
"open-clip-torch",
|
|
324440
|
-
"torch",
|
|
324441
|
-
"torchvision",
|
|
324442
|
-
"torchaudio",
|
|
324443
|
-
"Pillow",
|
|
324444
|
-
"speechbrain",
|
|
324445
|
-
"soundfile",
|
|
324446
|
-
"openai-whisper"
|
|
324447
|
-
];
|
|
324448
|
-
const ins = spawnSync5(pip, ["install", "--upgrade", ...pkgs], { encoding: "utf8", timeout: 9e5 });
|
|
324449
|
-
log22 += ins.stdout + ins.stderr;
|
|
324450
|
-
const ok2 = ins.status === 0;
|
|
324451
|
-
return { ok: ok2, log: log22 };
|
|
324452
|
-
}
|
|
324453
|
-
function runEmbedImage(input) {
|
|
324454
|
-
const py = getVenvPython();
|
|
324455
|
-
const script = locateScript("embed-image.py");
|
|
324456
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8" });
|
|
324457
|
-
try {
|
|
324458
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324459
|
-
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
324460
|
-
} catch {
|
|
324461
|
-
}
|
|
324462
|
-
return null;
|
|
324463
|
-
}
|
|
324464
|
-
function runEmbedAudio(input) {
|
|
324465
|
-
const py = getVenvPython();
|
|
324466
|
-
const script = locateScript("embed-audio.py");
|
|
324467
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8" });
|
|
324468
|
-
try {
|
|
324469
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324470
|
-
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
324471
|
-
} catch {
|
|
324472
|
-
}
|
|
324473
|
-
return null;
|
|
324474
|
-
}
|
|
324475
|
-
function runEmbedText(text) {
|
|
324476
|
-
const py = getVenvPython();
|
|
324477
|
-
const script = locateScript("embed-text.py");
|
|
324478
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify({ text }), encoding: "utf8" });
|
|
324479
|
-
try {
|
|
324480
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324481
|
-
if (Array.isArray(out.embedding)) return new Float32Array(out.embedding);
|
|
324482
|
-
} catch {
|
|
324483
|
-
}
|
|
324484
|
-
return null;
|
|
324485
|
-
}
|
|
324486
|
-
function runTranscribeFile(input) {
|
|
324487
|
-
const py = getVenvPython();
|
|
324488
|
-
const script = locateScript("transcribe-file.py");
|
|
324489
|
-
const p2 = spawnSync5(py, [script], { input: JSON.stringify(input), encoding: "utf8", timeout: 6e5 });
|
|
324490
|
-
try {
|
|
324491
|
-
const out = JSON.parse(p2.stdout || "{}");
|
|
324492
|
-
if (typeof out.text === "string") return out.text;
|
|
324493
|
-
} catch {
|
|
324494
|
-
}
|
|
324495
|
-
return null;
|
|
324496
|
-
}
|
|
324497
|
-
function locateScript(name11) {
|
|
324498
|
-
const candidates = [
|
|
324499
|
-
join98(process.cwd(), "dist", "scripts", name11),
|
|
324500
|
-
join98(process.cwd(), name11),
|
|
324501
|
-
join98(process.cwd(), "scripts", name11)
|
|
324502
|
-
];
|
|
324503
|
-
for (const c7 of candidates) if (existsSync82(c7)) return c7;
|
|
324504
|
-
const fallback = join98(process.cwd(), name11);
|
|
324505
|
-
try {
|
|
324506
|
-
writeFileSync44(fallback, 'print("missing script")\n');
|
|
324507
|
-
} catch {
|
|
324508
|
-
}
|
|
324509
|
-
return fallback;
|
|
324510
|
-
}
|
|
324511
|
-
var init_py_embed = __esm({
|
|
324512
|
-
"packages/cli/src/api/py-embed.ts"() {
|
|
324513
|
-
"use strict";
|
|
324514
|
-
}
|
|
324515
|
-
});
|
|
324516
|
-
|
|
324517
324620
|
// packages/cli/src/api/embedding-workers.ts
|
|
324518
324621
|
var embedding_workers_exports = {};
|
|
324519
324622
|
__export(embedding_workers_exports, {
|