open-agents-ai 0.136.0 → 0.137.0
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 +519 -353
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9371,6 +9371,164 @@ ${lines.join("\n")}`,
|
|
|
9371
9371
|
}
|
|
9372
9372
|
});
|
|
9373
9373
|
|
|
9374
|
+
// packages/execution/dist/tools/image-generate.js
|
|
9375
|
+
import { writeFile as writeFile13, mkdir as mkdir9 } from "node:fs/promises";
|
|
9376
|
+
import { join as join24 } from "node:path";
|
|
9377
|
+
var ImageGenerateTool;
|
|
9378
|
+
var init_image_generate = __esm({
|
|
9379
|
+
"packages/execution/dist/tools/image-generate.js"() {
|
|
9380
|
+
"use strict";
|
|
9381
|
+
ImageGenerateTool = class {
|
|
9382
|
+
name = "generate_image";
|
|
9383
|
+
description = "Generate an image from a text prompt using a local Ollama diffusion model (e.g., x/z-image-turbo, x/flux2-klein). Saves the generated image as a PNG file and returns the file path. Requires an image gen model to be pulled in Ollama.";
|
|
9384
|
+
parameters = {
|
|
9385
|
+
type: "object",
|
|
9386
|
+
properties: {
|
|
9387
|
+
prompt: {
|
|
9388
|
+
type: "string",
|
|
9389
|
+
description: "Text description of the image to generate"
|
|
9390
|
+
},
|
|
9391
|
+
width: {
|
|
9392
|
+
type: "number",
|
|
9393
|
+
description: "Image width in pixels (default: 1024)"
|
|
9394
|
+
},
|
|
9395
|
+
height: {
|
|
9396
|
+
type: "number",
|
|
9397
|
+
description: "Image height in pixels (default: 1024)"
|
|
9398
|
+
},
|
|
9399
|
+
steps: {
|
|
9400
|
+
type: "number",
|
|
9401
|
+
description: "Number of diffusion steps (default: model default, ~20-30)"
|
|
9402
|
+
},
|
|
9403
|
+
model: {
|
|
9404
|
+
type: "string",
|
|
9405
|
+
description: "Specific image gen model to use (default: auto-detect best available)"
|
|
9406
|
+
}
|
|
9407
|
+
},
|
|
9408
|
+
required: ["prompt"]
|
|
9409
|
+
};
|
|
9410
|
+
cwd;
|
|
9411
|
+
ollamaUrl;
|
|
9412
|
+
cachedImageModel = null;
|
|
9413
|
+
constructor(cwd4, ollamaUrl = "http://localhost:11434") {
|
|
9414
|
+
this.cwd = cwd4;
|
|
9415
|
+
this.ollamaUrl = ollamaUrl;
|
|
9416
|
+
}
|
|
9417
|
+
async execute(args) {
|
|
9418
|
+
const prompt = String(args.prompt ?? "");
|
|
9419
|
+
const width = Number(args.width ?? 1024);
|
|
9420
|
+
const height = Number(args.height ?? 1024);
|
|
9421
|
+
const steps = args.steps ? Number(args.steps) : void 0;
|
|
9422
|
+
const requestedModel = args.model ? String(args.model) : void 0;
|
|
9423
|
+
const start = performance.now();
|
|
9424
|
+
if (!prompt.trim()) {
|
|
9425
|
+
return { success: false, output: "No prompt provided", error: "Empty prompt", durationMs: 0 };
|
|
9426
|
+
}
|
|
9427
|
+
try {
|
|
9428
|
+
const model = requestedModel ?? await this.findImageGenModel();
|
|
9429
|
+
if (!model) {
|
|
9430
|
+
return {
|
|
9431
|
+
success: false,
|
|
9432
|
+
output: "No image generation model available.\nPull one with: ollama pull x/z-image-turbo\nOr: ollama pull x/flux2-klein",
|
|
9433
|
+
error: "No image gen model",
|
|
9434
|
+
durationMs: performance.now() - start
|
|
9435
|
+
};
|
|
9436
|
+
}
|
|
9437
|
+
const body = {
|
|
9438
|
+
model,
|
|
9439
|
+
prompt,
|
|
9440
|
+
width,
|
|
9441
|
+
height,
|
|
9442
|
+
stream: false
|
|
9443
|
+
};
|
|
9444
|
+
if (steps)
|
|
9445
|
+
body.steps = steps;
|
|
9446
|
+
const resp = await fetch(`${this.ollamaUrl}/api/generate`, {
|
|
9447
|
+
method: "POST",
|
|
9448
|
+
headers: { "Content-Type": "application/json" },
|
|
9449
|
+
body: JSON.stringify(body),
|
|
9450
|
+
signal: AbortSignal.timeout(3e5)
|
|
9451
|
+
// 5 min timeout for image gen
|
|
9452
|
+
});
|
|
9453
|
+
if (!resp.ok) {
|
|
9454
|
+
const errText = await resp.text().catch(() => "");
|
|
9455
|
+
return {
|
|
9456
|
+
success: false,
|
|
9457
|
+
output: `Image generation failed: HTTP ${resp.status}
|
|
9458
|
+
${errText.slice(0, 200)}`,
|
|
9459
|
+
durationMs: performance.now() - start
|
|
9460
|
+
};
|
|
9461
|
+
}
|
|
9462
|
+
const data = await resp.json();
|
|
9463
|
+
if (!data.image) {
|
|
9464
|
+
return {
|
|
9465
|
+
success: false,
|
|
9466
|
+
output: "No image data in response \u2014 model may not support image generation",
|
|
9467
|
+
durationMs: performance.now() - start
|
|
9468
|
+
};
|
|
9469
|
+
}
|
|
9470
|
+
const imgDir = join24(this.cwd, ".oa", "images");
|
|
9471
|
+
await mkdir9(imgDir, { recursive: true });
|
|
9472
|
+
const filename = `img-${Date.now()}.png`;
|
|
9473
|
+
const filepath = join24(imgDir, filename);
|
|
9474
|
+
const imgBuffer = Buffer.from(data.image, "base64");
|
|
9475
|
+
await writeFile13(filepath, imgBuffer);
|
|
9476
|
+
const sizeKB = Math.round(imgBuffer.length / 1024);
|
|
9477
|
+
return {
|
|
9478
|
+
success: true,
|
|
9479
|
+
output: `Image generated: ${filepath}
|
|
9480
|
+
Model: ${model}
|
|
9481
|
+
Size: ${width}x${height} (${sizeKB}KB)
|
|
9482
|
+
Prompt: "${prompt.slice(0, 80)}${prompt.length > 80 ? "..." : ""}"`,
|
|
9483
|
+
durationMs: performance.now() - start
|
|
9484
|
+
};
|
|
9485
|
+
} catch (err) {
|
|
9486
|
+
return {
|
|
9487
|
+
success: false,
|
|
9488
|
+
output: `Image generation error: ${err instanceof Error ? err.message : String(err)}`,
|
|
9489
|
+
durationMs: performance.now() - start
|
|
9490
|
+
};
|
|
9491
|
+
}
|
|
9492
|
+
}
|
|
9493
|
+
/** Find the best available image gen model on Ollama */
|
|
9494
|
+
async findImageGenModel() {
|
|
9495
|
+
if (this.cachedImageModel)
|
|
9496
|
+
return this.cachedImageModel;
|
|
9497
|
+
try {
|
|
9498
|
+
const resp = await fetch(`${this.ollamaUrl}/api/tags`, {
|
|
9499
|
+
signal: AbortSignal.timeout(5e3)
|
|
9500
|
+
});
|
|
9501
|
+
if (!resp.ok)
|
|
9502
|
+
return null;
|
|
9503
|
+
const data = await resp.json();
|
|
9504
|
+
const models = data.models ?? [];
|
|
9505
|
+
for (const m of models) {
|
|
9506
|
+
try {
|
|
9507
|
+
const showResp = await fetch(`${this.ollamaUrl}/api/show`, {
|
|
9508
|
+
method: "POST",
|
|
9509
|
+
headers: { "Content-Type": "application/json" },
|
|
9510
|
+
body: JSON.stringify({ model: m.name }),
|
|
9511
|
+
signal: AbortSignal.timeout(3e3)
|
|
9512
|
+
});
|
|
9513
|
+
if (!showResp.ok)
|
|
9514
|
+
continue;
|
|
9515
|
+
const showData = await showResp.json();
|
|
9516
|
+
if (showData.capabilities?.includes("image")) {
|
|
9517
|
+
this.cachedImageModel = m.name;
|
|
9518
|
+
return m.name;
|
|
9519
|
+
}
|
|
9520
|
+
} catch {
|
|
9521
|
+
continue;
|
|
9522
|
+
}
|
|
9523
|
+
}
|
|
9524
|
+
} catch {
|
|
9525
|
+
}
|
|
9526
|
+
return null;
|
|
9527
|
+
}
|
|
9528
|
+
};
|
|
9529
|
+
}
|
|
9530
|
+
});
|
|
9531
|
+
|
|
9374
9532
|
// packages/execution/dist/tools/structured-read.js
|
|
9375
9533
|
import { readFile as readFile13, stat as stat2 } from "node:fs/promises";
|
|
9376
9534
|
import { resolve as resolve15, extname as extname5 } from "node:path";
|
|
@@ -9709,7 +9867,7 @@ ${parts.join("\n\n")}`,
|
|
|
9709
9867
|
// packages/execution/dist/tools/vision.js
|
|
9710
9868
|
import { readFileSync as readFileSync11, existsSync as existsSync14, statSync as statSync5 } from "node:fs";
|
|
9711
9869
|
import { execSync as execSync10, spawn as spawn7 } from "node:child_process";
|
|
9712
|
-
import { resolve as resolve16, extname as extname6, basename as basename5, dirname as dirname6, join as
|
|
9870
|
+
import { resolve as resolve16, extname as extname6, basename as basename5, dirname as dirname6, join as join25 } from "node:path";
|
|
9713
9871
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
9714
9872
|
async function probeStation(endpoint) {
|
|
9715
9873
|
try {
|
|
@@ -9724,7 +9882,7 @@ async function probeStation(endpoint) {
|
|
|
9724
9882
|
}
|
|
9725
9883
|
}
|
|
9726
9884
|
function findStationBinary() {
|
|
9727
|
-
const oaVenvPython =
|
|
9885
|
+
const oaVenvPython = join25(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "python");
|
|
9728
9886
|
if (existsSync14(oaVenvPython)) {
|
|
9729
9887
|
try {
|
|
9730
9888
|
execSync10(`${JSON.stringify(oaVenvPython)} -c "import moondream_station"`, { stdio: "pipe", timeout: 5e3 });
|
|
@@ -9732,7 +9890,7 @@ function findStationBinary() {
|
|
|
9732
9890
|
} catch {
|
|
9733
9891
|
}
|
|
9734
9892
|
}
|
|
9735
|
-
const oaVenvBin =
|
|
9893
|
+
const oaVenvBin = join25(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "moondream-station");
|
|
9736
9894
|
if (existsSync14(oaVenvBin))
|
|
9737
9895
|
return oaVenvBin;
|
|
9738
9896
|
const thisDir = dirname6(fileURLToPath2(import.meta.url));
|
|
@@ -10084,7 +10242,7 @@ ${response}`, durationMs: performance.now() - start };
|
|
|
10084
10242
|
import { readFileSync as readFileSync12, existsSync as existsSync15 } from "node:fs";
|
|
10085
10243
|
import { execSync as execSync11 } from "node:child_process";
|
|
10086
10244
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
10087
|
-
import { join as
|
|
10245
|
+
import { join as join26, dirname as dirname7 } from "node:path";
|
|
10088
10246
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
10089
10247
|
function hasCommand2(cmd) {
|
|
10090
10248
|
try {
|
|
@@ -10208,7 +10366,7 @@ for i in range(${clicks}):
|
|
|
10208
10366
|
} catch {
|
|
10209
10367
|
}
|
|
10210
10368
|
try {
|
|
10211
|
-
const venvPy =
|
|
10369
|
+
const venvPy = join26(__dirname2, "../../../../.moondream-venv/bin/python");
|
|
10212
10370
|
execSync11(`DISPLAY=:0 ${JSON.stringify(venvPy)} -c "${pyScript}"`, { stdio: "pipe", timeout: 5e3 });
|
|
10213
10371
|
return;
|
|
10214
10372
|
} catch {
|
|
@@ -10300,7 +10458,7 @@ var init_desktop_click = __esm({
|
|
|
10300
10458
|
if (delayMs > 0) {
|
|
10301
10459
|
await new Promise((r) => setTimeout(r, delayMs));
|
|
10302
10460
|
}
|
|
10303
|
-
const screenshotPath =
|
|
10461
|
+
const screenshotPath = join26(tmpdir4(), `oa-desktop-click-${Date.now()}.png`);
|
|
10304
10462
|
captureScreenshot(screenshotPath);
|
|
10305
10463
|
const dims = getImageDimensions2(screenshotPath);
|
|
10306
10464
|
if (!dims) {
|
|
@@ -10475,7 +10633,7 @@ Screenshot: ${screenshotPath}`,
|
|
|
10475
10633
|
if (delayMs > 0) {
|
|
10476
10634
|
await new Promise((r) => setTimeout(r, delayMs));
|
|
10477
10635
|
}
|
|
10478
|
-
const screenshotPath =
|
|
10636
|
+
const screenshotPath = join26(tmpdir4(), `oa-desktop-describe-${Date.now()}.png`);
|
|
10479
10637
|
captureScreenshot(screenshotPath);
|
|
10480
10638
|
const dims = getImageDimensions2(screenshotPath);
|
|
10481
10639
|
const imageBuffer = readFileSync12(screenshotPath);
|
|
@@ -10714,7 +10872,7 @@ Language: ${language}
|
|
|
10714
10872
|
|
|
10715
10873
|
// packages/execution/dist/tools/pdf-to-text.js
|
|
10716
10874
|
import { existsSync as existsSync17, statSync as statSync7, readFileSync as readFileSync13, unlinkSync as unlinkSync3 } from "node:fs";
|
|
10717
|
-
import { resolve as resolve18, basename as basename7, join as
|
|
10875
|
+
import { resolve as resolve18, basename as basename7, join as join27 } from "node:path";
|
|
10718
10876
|
import { execSync as execSync13 } from "node:child_process";
|
|
10719
10877
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
10720
10878
|
var PdfToTextTool;
|
|
@@ -10868,7 +11026,7 @@ ${text}`,
|
|
|
10868
11026
|
if (!ocrCheck.available || !tesCheck.available || !gsCheck.available) {
|
|
10869
11027
|
return null;
|
|
10870
11028
|
}
|
|
10871
|
-
const tmpPdf =
|
|
11029
|
+
const tmpPdf = join27(tmpdir5(), `oa-ocr-${Date.now()}.pdf`);
|
|
10872
11030
|
try {
|
|
10873
11031
|
const ocrCmd = `ocrmypdf -l ${language} --skip-text ${JSON.stringify(inputPath)} ${JSON.stringify(tmpPdf)}`;
|
|
10874
11032
|
execSync13(ocrCmd, { stdio: "pipe", timeout: 6e5 });
|
|
@@ -10899,7 +11057,7 @@ ${text}`,
|
|
|
10899
11057
|
|
|
10900
11058
|
// packages/execution/dist/tools/ocr-image-advanced.js
|
|
10901
11059
|
import { existsSync as existsSync18, statSync as statSync8 } from "node:fs";
|
|
10902
|
-
import { resolve as resolve19, basename as basename8, dirname as dirname8, join as
|
|
11060
|
+
import { resolve as resolve19, basename as basename8, dirname as dirname8, join as join28 } from "node:path";
|
|
10903
11061
|
import { execSync as execSync14 } from "node:child_process";
|
|
10904
11062
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
10905
11063
|
import { homedir as homedir7, tmpdir as tmpdir6 } from "node:os";
|
|
@@ -10917,7 +11075,7 @@ function findOcrScript() {
|
|
|
10917
11075
|
return null;
|
|
10918
11076
|
}
|
|
10919
11077
|
function findPython() {
|
|
10920
|
-
const venvPython =
|
|
11078
|
+
const venvPython = join28(homedir7(), ".open-agents", "venv", "bin", "python");
|
|
10921
11079
|
if (existsSync18(venvPython)) {
|
|
10922
11080
|
try {
|
|
10923
11081
|
execSync14(`${JSON.stringify(venvPython)} -c "import cv2, pytesseract, numpy, PIL"`, {
|
|
@@ -11063,7 +11221,7 @@ var init_ocr_image_advanced = __esm({
|
|
|
11063
11221
|
cmdParts.push("--output-dir", JSON.stringify(resolve19(this.workingDir, outputDir)));
|
|
11064
11222
|
let debugDir;
|
|
11065
11223
|
if (debug) {
|
|
11066
|
-
debugDir =
|
|
11224
|
+
debugDir = join28(tmpdir6(), `oa-ocr-debug-${Date.now()}`);
|
|
11067
11225
|
cmdParts.push("--debug-dir", debugDir);
|
|
11068
11226
|
}
|
|
11069
11227
|
try {
|
|
@@ -11162,7 +11320,7 @@ var init_ocr_image_advanced = __esm({
|
|
|
11162
11320
|
if (region) {
|
|
11163
11321
|
try {
|
|
11164
11322
|
const [x, y, w, h] = region.split(",").map(Number);
|
|
11165
|
-
const croppedPath =
|
|
11323
|
+
const croppedPath = join28(tmpdir6(), `oa-ocr-crop-${Date.now()}.png`);
|
|
11166
11324
|
execSync14(`convert ${JSON.stringify(imagePath)} -crop ${w}x${h}+${x}+${y} +repage ${JSON.stringify(croppedPath)}`, { stdio: "pipe", timeout: 1e4 });
|
|
11167
11325
|
inputPath = croppedPath;
|
|
11168
11326
|
} catch {
|
|
@@ -11203,18 +11361,18 @@ Note: Advanced Python pipeline not available \u2014 install pytesseract, opencv-
|
|
|
11203
11361
|
// packages/execution/dist/tools/browser-action.js
|
|
11204
11362
|
import { execSync as execSync15, spawn as spawn8 } from "node:child_process";
|
|
11205
11363
|
import { existsSync as existsSync19, readFileSync as readFileSync14 } from "node:fs";
|
|
11206
|
-
import { join as
|
|
11364
|
+
import { join as join29, dirname as dirname9 } from "node:path";
|
|
11207
11365
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
11208
11366
|
function findScrapeScript() {
|
|
11209
11367
|
const candidates = [
|
|
11210
11368
|
// Published npm package: dist/scripts/web_scrape.py
|
|
11211
|
-
|
|
11369
|
+
join29(__dirname3, "scripts", "web_scrape.py"),
|
|
11212
11370
|
// Published npm package (from node_modules): node_modules/open-agents-ai/dist/scripts/
|
|
11213
|
-
|
|
11371
|
+
join29(__dirname3, "..", "node_modules", "open-agents-ai", "dist", "scripts", "web_scrape.py"),
|
|
11214
11372
|
// Dev monorepo: packages/execution/src/tools/../../scripts/
|
|
11215
|
-
|
|
11373
|
+
join29(__dirname3, "..", "..", "scripts", "web_scrape.py"),
|
|
11216
11374
|
// Dev monorepo alt: packages/execution/scripts/
|
|
11217
|
-
|
|
11375
|
+
join29(__dirname3, "..", "scripts", "web_scrape.py")
|
|
11218
11376
|
];
|
|
11219
11377
|
return candidates.find((p) => existsSync19(p)) || candidates[0];
|
|
11220
11378
|
}
|
|
@@ -11469,7 +11627,7 @@ var init_browser_action = __esm({
|
|
|
11469
11627
|
// packages/execution/dist/tools/autoresearch.js
|
|
11470
11628
|
import { execSync as execSync16, spawn as spawn9 } from "node:child_process";
|
|
11471
11629
|
import { existsSync as existsSync20, readFileSync as readFileSync15, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, appendFileSync, copyFileSync } from "node:fs";
|
|
11472
|
-
import { join as
|
|
11630
|
+
import { join as join30, resolve as resolve20, dirname as dirname10 } from "node:path";
|
|
11473
11631
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
11474
11632
|
function findAutoresearchScript(scriptName) {
|
|
11475
11633
|
const thisDir = dirname10(fileURLToPath6(import.meta.url));
|
|
@@ -11571,7 +11729,7 @@ Requires: NVIDIA GPU, Python 3.10+, uv (astral.sh package manager).`;
|
|
|
11571
11729
|
async execute(args) {
|
|
11572
11730
|
const start = Date.now();
|
|
11573
11731
|
const action = String(args["action"] ?? "status");
|
|
11574
|
-
const workspacePath = String(args["workspace"] ??
|
|
11732
|
+
const workspacePath = String(args["workspace"] ?? join30(this.repoRoot, ".oa", "autoresearch"));
|
|
11575
11733
|
try {
|
|
11576
11734
|
switch (action) {
|
|
11577
11735
|
case "setup":
|
|
@@ -11612,13 +11770,13 @@ Requires: NVIDIA GPU, Python 3.10+, uv (astral.sh package manager).`;
|
|
|
11612
11770
|
const prepareScript = findAutoresearchScript("autoresearch-prepare.py");
|
|
11613
11771
|
const trainScript = findAutoresearchScript("autoresearch-train.py");
|
|
11614
11772
|
if (prepareScript) {
|
|
11615
|
-
copyFileSync(prepareScript,
|
|
11773
|
+
copyFileSync(prepareScript, join30(workspace, "prepare.py"));
|
|
11616
11774
|
output.push("Copied prepare.py template");
|
|
11617
11775
|
} else {
|
|
11618
11776
|
return { success: false, output: output.join("\n"), error: "autoresearch-prepare.py template not found in distribution", durationMs: Date.now() - start };
|
|
11619
11777
|
}
|
|
11620
11778
|
if (trainScript) {
|
|
11621
|
-
copyFileSync(trainScript,
|
|
11779
|
+
copyFileSync(trainScript, join30(workspace, "train.py"));
|
|
11622
11780
|
output.push("Copied train.py template");
|
|
11623
11781
|
} else {
|
|
11624
11782
|
return { success: false, output: output.join("\n"), error: "autoresearch-train.py template not found in distribution", durationMs: Date.now() - start };
|
|
@@ -11650,7 +11808,7 @@ name = "pytorch-cu128"
|
|
|
11650
11808
|
url = "https://download.pytorch.org/whl/cu128"
|
|
11651
11809
|
explicit = true
|
|
11652
11810
|
`;
|
|
11653
|
-
writeFileSync6(
|
|
11811
|
+
writeFileSync6(join30(workspace, "pyproject.toml"), pyprojectContent, "utf-8");
|
|
11654
11812
|
output.push("Created pyproject.toml");
|
|
11655
11813
|
try {
|
|
11656
11814
|
execSync16("git rev-parse --git-dir", { cwd: workspace, encoding: "utf-8", timeout: 5e3 });
|
|
@@ -11692,7 +11850,7 @@ explicit = true
|
|
|
11692
11850
|
const e = err;
|
|
11693
11851
|
output.push(`Data prep warning: ${(e.stderr ?? e.stdout ?? "failed").slice(0, 500)}`);
|
|
11694
11852
|
}
|
|
11695
|
-
const tsvPath =
|
|
11853
|
+
const tsvPath = join30(workspace, "results.tsv");
|
|
11696
11854
|
if (!existsSync20(tsvPath)) {
|
|
11697
11855
|
writeFileSync6(tsvPath, "commit val_bpb memory_gb status description\n", "utf-8");
|
|
11698
11856
|
output.push("Created results.tsv");
|
|
@@ -11714,10 +11872,10 @@ Next steps:
|
|
|
11714
11872
|
}
|
|
11715
11873
|
// ── Run experiment ─────────────────────────────────────────────────────
|
|
11716
11874
|
async run(workspace, args, start) {
|
|
11717
|
-
if (!existsSync20(
|
|
11875
|
+
if (!existsSync20(join30(workspace, "train.py"))) {
|
|
11718
11876
|
return { success: false, output: "", error: `No train.py found in ${workspace}. Run autoresearch(action="setup") first.`, durationMs: Date.now() - start };
|
|
11719
11877
|
}
|
|
11720
|
-
if (!existsSync20(
|
|
11878
|
+
if (!existsSync20(join30(workspace, ".venv")) && existsSync20(join30(workspace, "pyproject.toml"))) {
|
|
11721
11879
|
try {
|
|
11722
11880
|
execSync16("uv sync 2>&1", { cwd: workspace, encoding: "utf-8", timeout: 3e5 });
|
|
11723
11881
|
} catch {
|
|
@@ -11725,7 +11883,7 @@ Next steps:
|
|
|
11725
11883
|
}
|
|
11726
11884
|
const timeoutMin = Number(args["timeout_minutes"] ?? 10);
|
|
11727
11885
|
const timeoutMs = timeoutMin * 60 * 1e3;
|
|
11728
|
-
const logPath =
|
|
11886
|
+
const logPath = join30(workspace, "run.log");
|
|
11729
11887
|
return new Promise((resolveResult) => {
|
|
11730
11888
|
const proc = spawn9("uv", ["run", "train.py"], {
|
|
11731
11889
|
cwd: workspace,
|
|
@@ -11796,7 +11954,7 @@ ${fullLog.slice(-2e3)}`,
|
|
|
11796
11954
|
return;
|
|
11797
11955
|
}
|
|
11798
11956
|
try {
|
|
11799
|
-
writeFileSync6(
|
|
11957
|
+
writeFileSync6(join30(workspace, ".last-result.json"), JSON.stringify(result, null, 2), "utf-8");
|
|
11800
11958
|
} catch {
|
|
11801
11959
|
}
|
|
11802
11960
|
const memGB = (result.peak_vram_mb / 1024).toFixed(1);
|
|
@@ -11832,7 +11990,7 @@ ${fullLog.slice(-2e3)}`,
|
|
|
11832
11990
|
}
|
|
11833
11991
|
// ── Results ────────────────────────────────────────────────────────────
|
|
11834
11992
|
getResults(workspace, start) {
|
|
11835
|
-
const tsvPath =
|
|
11993
|
+
const tsvPath = join30(workspace, "results.tsv");
|
|
11836
11994
|
if (!existsSync20(tsvPath)) {
|
|
11837
11995
|
return { success: false, output: "", error: `No results.tsv found. Run autoresearch(action="setup") first.`, durationMs: Date.now() - start };
|
|
11838
11996
|
}
|
|
@@ -11859,7 +12017,7 @@ ${fullLog.slice(-2e3)}`,
|
|
|
11859
12017
|
// ── Status ─────────────────────────────────────────────────────────────
|
|
11860
12018
|
getStatus(workspace, start) {
|
|
11861
12019
|
const output = [];
|
|
11862
|
-
if (!existsSync20(
|
|
12020
|
+
if (!existsSync20(join30(workspace, "train.py"))) {
|
|
11863
12021
|
return {
|
|
11864
12022
|
success: true,
|
|
11865
12023
|
output: `Autoresearch workspace not initialized at ${workspace}.
|
|
@@ -11882,7 +12040,7 @@ Run autoresearch(action="setup") to begin.`,
|
|
|
11882
12040
|
} catch {
|
|
11883
12041
|
output.push("GPU: not detected");
|
|
11884
12042
|
}
|
|
11885
|
-
const lastResultPath =
|
|
12043
|
+
const lastResultPath = join30(workspace, ".last-result.json");
|
|
11886
12044
|
if (existsSync20(lastResultPath)) {
|
|
11887
12045
|
try {
|
|
11888
12046
|
const last = JSON.parse(readFileSync15(lastResultPath, "utf-8"));
|
|
@@ -11890,20 +12048,20 @@ Run autoresearch(action="setup") to begin.`,
|
|
|
11890
12048
|
} catch {
|
|
11891
12049
|
}
|
|
11892
12050
|
}
|
|
11893
|
-
const tsvPath =
|
|
12051
|
+
const tsvPath = join30(workspace, "results.tsv");
|
|
11894
12052
|
if (existsSync20(tsvPath)) {
|
|
11895
12053
|
const lines = readFileSync15(tsvPath, "utf-8").trim().split("\n");
|
|
11896
12054
|
output.push(`Experiments recorded: ${lines.length - 1}`);
|
|
11897
12055
|
}
|
|
11898
|
-
const cacheDir =
|
|
12056
|
+
const cacheDir = join30(process.env["HOME"] ?? "~", ".cache", "autoresearch");
|
|
11899
12057
|
output.push(`Data cache: ${existsSync20(cacheDir) ? "present" : "not found"} (${cacheDir})`);
|
|
11900
12058
|
return { success: true, output: output.join("\n"), durationMs: Date.now() - start };
|
|
11901
12059
|
}
|
|
11902
12060
|
// ── Keep / Discard ─────────────────────────────────────────────────────
|
|
11903
12061
|
keepExperiment(workspace, args, start) {
|
|
11904
12062
|
const desc = String(args["description"] ?? "experiment");
|
|
11905
|
-
const tsvPath =
|
|
11906
|
-
const lastResultPath =
|
|
12063
|
+
const tsvPath = join30(workspace, "results.tsv");
|
|
12064
|
+
const lastResultPath = join30(workspace, ".last-result.json");
|
|
11907
12065
|
let valBpb = args["val_bpb"];
|
|
11908
12066
|
let memGb = args["memory_gb"];
|
|
11909
12067
|
if ((valBpb === void 0 || memGb === void 0) && existsSync20(lastResultPath)) {
|
|
@@ -11941,8 +12099,8 @@ Branch advanced. Ready for next experiment.`,
|
|
|
11941
12099
|
}
|
|
11942
12100
|
discardExperiment(workspace, args, start) {
|
|
11943
12101
|
const desc = String(args["description"] ?? "experiment");
|
|
11944
|
-
const tsvPath =
|
|
11945
|
-
const lastResultPath =
|
|
12102
|
+
const tsvPath = join30(workspace, "results.tsv");
|
|
12103
|
+
const lastResultPath = join30(workspace, ".last-result.json");
|
|
11946
12104
|
let valBpb = args["val_bpb"];
|
|
11947
12105
|
let memGb = args["memory_gb"];
|
|
11948
12106
|
if ((valBpb === void 0 || memGb === void 0) && existsSync20(lastResultPath)) {
|
|
@@ -11988,8 +12146,8 @@ train.py reverted to last kept state. Ready for next experiment.`,
|
|
|
11988
12146
|
|
|
11989
12147
|
// packages/execution/dist/tools/scheduler.js
|
|
11990
12148
|
import { execSync as execSync17, exec as execCb } from "node:child_process";
|
|
11991
|
-
import { readFile as readFile14, writeFile as
|
|
11992
|
-
import { resolve as resolve21, join as
|
|
12149
|
+
import { readFile as readFile14, writeFile as writeFile14, mkdir as mkdir10 } from "node:fs/promises";
|
|
12150
|
+
import { resolve as resolve21, join as join31 } from "node:path";
|
|
11993
12151
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
11994
12152
|
function isValidCron(expr) {
|
|
11995
12153
|
const parts = expr.trim().split(/\s+/);
|
|
@@ -12073,7 +12231,7 @@ function installCronJob(task, workingDir) {
|
|
|
12073
12231
|
const lines = getCurrentCrontab();
|
|
12074
12232
|
const oaBin = findOaBinary();
|
|
12075
12233
|
const logDir = resolve21(workingDir, ".oa", "scheduled", "logs");
|
|
12076
|
-
const logFile =
|
|
12234
|
+
const logFile = join31(logDir, `${task.id}.log`);
|
|
12077
12235
|
const storeFile = resolve21(workingDir, ".oa", "scheduled", "tasks.json");
|
|
12078
12236
|
const taskEscaped = task.task.replace(/'/g, "'\\''");
|
|
12079
12237
|
const taskId = task.id;
|
|
@@ -12114,10 +12272,10 @@ async function loadStore(workingDir) {
|
|
|
12114
12272
|
}
|
|
12115
12273
|
async function saveStore(workingDir, store) {
|
|
12116
12274
|
const dir = resolve21(workingDir, ".oa", "scheduled");
|
|
12117
|
-
await
|
|
12118
|
-
await
|
|
12275
|
+
await mkdir10(dir, { recursive: true });
|
|
12276
|
+
await mkdir10(join31(dir, "logs"), { recursive: true });
|
|
12119
12277
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12120
|
-
await
|
|
12278
|
+
await writeFile14(join31(dir, "tasks.json"), JSON.stringify(store, null, 2), "utf-8");
|
|
12121
12279
|
}
|
|
12122
12280
|
var SCHEDULE_PRESETS, CRON_MARKER, SchedulerTool;
|
|
12123
12281
|
var init_scheduler = __esm({
|
|
@@ -12350,8 +12508,8 @@ ${truncated}`, durationMs: performance.now() - start };
|
|
|
12350
12508
|
});
|
|
12351
12509
|
|
|
12352
12510
|
// packages/execution/dist/tools/reminder.js
|
|
12353
|
-
import { readFile as readFile15, writeFile as
|
|
12354
|
-
import { resolve as resolve22, join as
|
|
12511
|
+
import { readFile as readFile15, writeFile as writeFile15, mkdir as mkdir11 } from "node:fs/promises";
|
|
12512
|
+
import { resolve as resolve22, join as join32 } from "node:path";
|
|
12355
12513
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
12356
12514
|
function parseDueTime(due) {
|
|
12357
12515
|
const lower = due.toLowerCase().trim();
|
|
@@ -12402,8 +12560,8 @@ function parseDueTime(due) {
|
|
|
12402
12560
|
}
|
|
12403
12561
|
async function getStorePath(workingDir) {
|
|
12404
12562
|
const dir = resolve22(workingDir, ".oa", "scheduled");
|
|
12405
|
-
await
|
|
12406
|
-
return
|
|
12563
|
+
await mkdir11(dir, { recursive: true });
|
|
12564
|
+
return join32(dir, STORE_FILE);
|
|
12407
12565
|
}
|
|
12408
12566
|
async function loadReminderStore(workingDir) {
|
|
12409
12567
|
const storePath = await getStorePath(workingDir);
|
|
@@ -12417,7 +12575,7 @@ async function loadReminderStore(workingDir) {
|
|
|
12417
12575
|
async function saveReminderStore(workingDir, store) {
|
|
12418
12576
|
const storePath = await getStorePath(workingDir);
|
|
12419
12577
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12420
|
-
await
|
|
12578
|
+
await writeFile15(storePath, JSON.stringify(store, null, 2), "utf-8");
|
|
12421
12579
|
}
|
|
12422
12580
|
async function getDueReminders(workingDir) {
|
|
12423
12581
|
const store = await loadReminderStore(workingDir);
|
|
@@ -12663,8 +12821,8 @@ var init_reminder = __esm({
|
|
|
12663
12821
|
});
|
|
12664
12822
|
|
|
12665
12823
|
// packages/execution/dist/tools/agenda.js
|
|
12666
|
-
import { readFile as readFile16, writeFile as
|
|
12667
|
-
import { resolve as resolve23, join as
|
|
12824
|
+
import { readFile as readFile16, writeFile as writeFile16, mkdir as mkdir12 } from "node:fs/promises";
|
|
12825
|
+
import { resolve as resolve23, join as join33 } from "node:path";
|
|
12668
12826
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
12669
12827
|
async function loadAttentionStore(workingDir) {
|
|
12670
12828
|
const storePath = resolve23(workingDir, ".oa", "scheduled", "attention.json");
|
|
@@ -12677,9 +12835,9 @@ async function loadAttentionStore(workingDir) {
|
|
|
12677
12835
|
}
|
|
12678
12836
|
async function saveAttentionStore(workingDir, store) {
|
|
12679
12837
|
const dir = resolve23(workingDir, ".oa", "scheduled");
|
|
12680
|
-
await
|
|
12838
|
+
await mkdir12(dir, { recursive: true });
|
|
12681
12839
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12682
|
-
await
|
|
12840
|
+
await writeFile16(join33(dir, "attention.json"), JSON.stringify(store, null, 2), "utf-8");
|
|
12683
12841
|
}
|
|
12684
12842
|
async function getActiveAttentionItems(workingDir) {
|
|
12685
12843
|
const store = await loadAttentionStore(workingDir);
|
|
@@ -12989,7 +13147,7 @@ ${sections.join("\n")}`,
|
|
|
12989
13147
|
// packages/execution/dist/tools/opencode.js
|
|
12990
13148
|
import { execSync as execSync18, spawn as spawn10 } from "node:child_process";
|
|
12991
13149
|
import { existsSync as existsSync21 } from "node:fs";
|
|
12992
|
-
import { join as
|
|
13150
|
+
import { join as join34, resolve as resolve24 } from "node:path";
|
|
12993
13151
|
function findOpencode() {
|
|
12994
13152
|
for (const cmd of ["opencode"]) {
|
|
12995
13153
|
try {
|
|
@@ -13001,8 +13159,8 @@ function findOpencode() {
|
|
|
13001
13159
|
}
|
|
13002
13160
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
13003
13161
|
const candidates = [
|
|
13004
|
-
|
|
13005
|
-
|
|
13162
|
+
join34(homeDir, ".opencode", "bin", "opencode"),
|
|
13163
|
+
join34(homeDir, "bin", "opencode"),
|
|
13006
13164
|
"/usr/local/bin/opencode"
|
|
13007
13165
|
];
|
|
13008
13166
|
for (const p of candidates) {
|
|
@@ -13263,7 +13421,7 @@ var init_opencode = __esm({
|
|
|
13263
13421
|
// packages/execution/dist/tools/factory.js
|
|
13264
13422
|
import { execSync as execSync19, spawn as spawn11 } from "node:child_process";
|
|
13265
13423
|
import { existsSync as existsSync22 } from "node:fs";
|
|
13266
|
-
import { join as
|
|
13424
|
+
import { join as join35 } from "node:path";
|
|
13267
13425
|
function findDroid() {
|
|
13268
13426
|
for (const cmd of ["droid"]) {
|
|
13269
13427
|
try {
|
|
@@ -13275,8 +13433,8 @@ function findDroid() {
|
|
|
13275
13433
|
}
|
|
13276
13434
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
13277
13435
|
const candidates = [
|
|
13278
|
-
|
|
13279
|
-
|
|
13436
|
+
join35(homeDir, ".factory", "bin", "droid"),
|
|
13437
|
+
join35(homeDir, "bin", "droid"),
|
|
13280
13438
|
"/usr/local/bin/droid"
|
|
13281
13439
|
];
|
|
13282
13440
|
for (const p of candidates) {
|
|
@@ -13571,8 +13729,8 @@ var init_factory = __esm({
|
|
|
13571
13729
|
|
|
13572
13730
|
// packages/execution/dist/tools/cron-agent.js
|
|
13573
13731
|
import { execSync as execSync20 } from "node:child_process";
|
|
13574
|
-
import { readFile as readFile17, writeFile as
|
|
13575
|
-
import { resolve as resolve25, join as
|
|
13732
|
+
import { readFile as readFile17, writeFile as writeFile17, mkdir as mkdir13 } from "node:fs/promises";
|
|
13733
|
+
import { resolve as resolve25, join as join36 } from "node:path";
|
|
13576
13734
|
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
13577
13735
|
function isValidCron2(expr) {
|
|
13578
13736
|
const parts = expr.trim().split(/\s+/);
|
|
@@ -13658,7 +13816,7 @@ function installCronAgentJob(job, workingDir) {
|
|
|
13658
13816
|
const lines = getCurrentCrontab2();
|
|
13659
13817
|
const oaBin = findOaBinary2();
|
|
13660
13818
|
const logDir = resolve25(workingDir, ".oa", "cron-agents", "logs");
|
|
13661
|
-
const logFile =
|
|
13819
|
+
const logFile = join36(logDir, `${job.id}.log`);
|
|
13662
13820
|
const storeFile = resolve25(workingDir, ".oa", "cron-agents", "store.json");
|
|
13663
13821
|
const taskEscaped = job.task.replace(/'/g, "'\\''");
|
|
13664
13822
|
const jobId = job.id;
|
|
@@ -13696,10 +13854,10 @@ async function loadStore2(workingDir) {
|
|
|
13696
13854
|
}
|
|
13697
13855
|
async function saveStore2(workingDir, store) {
|
|
13698
13856
|
const dir = resolve25(workingDir, ".oa", "cron-agents");
|
|
13699
|
-
await
|
|
13700
|
-
await
|
|
13857
|
+
await mkdir13(dir, { recursive: true });
|
|
13858
|
+
await mkdir13(join36(dir, "logs"), { recursive: true });
|
|
13701
13859
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
13702
|
-
await
|
|
13860
|
+
await writeFile17(join36(dir, "store.json"), JSON.stringify(store, null, 2), "utf-8");
|
|
13703
13861
|
}
|
|
13704
13862
|
var LONG_HORIZON_PRESETS, CRON_AGENT_MARKER, CronAgentTool;
|
|
13705
13863
|
var init_cron_agent = __esm({
|
|
@@ -14035,9 +14193,9 @@ ${truncated}`, durationMs: performance.now() - start };
|
|
|
14035
14193
|
});
|
|
14036
14194
|
|
|
14037
14195
|
// packages/execution/dist/tools/nexus.js
|
|
14038
|
-
import { readFile as readFile18, writeFile as
|
|
14196
|
+
import { readFile as readFile18, writeFile as writeFile18, mkdir as mkdir14, chmod, unlink, readdir as readdir4, open as fsOpen } from "node:fs/promises";
|
|
14039
14197
|
import { existsSync as existsSync23, readFileSync as readFileSync16, watch as fsWatchLocal } from "node:fs";
|
|
14040
|
-
import { resolve as resolve26, join as
|
|
14198
|
+
import { resolve as resolve26, join as join37 } from "node:path";
|
|
14041
14199
|
import { randomBytes as randomBytes7, createCipheriv, createDecipheriv, scryptSync, createHash } from "node:crypto";
|
|
14042
14200
|
import { execSync as execSync21, spawn as spawn12 } from "node:child_process";
|
|
14043
14201
|
import { hostname, userInfo } from "node:os";
|
|
@@ -16011,7 +16169,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16011
16169
|
}
|
|
16012
16170
|
async ensureDir() {
|
|
16013
16171
|
if (!existsSync23(this.nexusDir)) {
|
|
16014
|
-
await
|
|
16172
|
+
await mkdir14(this.nexusDir, { recursive: true });
|
|
16015
16173
|
}
|
|
16016
16174
|
}
|
|
16017
16175
|
async execute(args) {
|
|
@@ -16134,7 +16292,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16134
16292
|
// Daemon management
|
|
16135
16293
|
// =========================================================================
|
|
16136
16294
|
getDaemonPid() {
|
|
16137
|
-
const pidFile =
|
|
16295
|
+
const pidFile = join37(this.nexusDir, "daemon.pid");
|
|
16138
16296
|
if (!existsSync23(pidFile))
|
|
16139
16297
|
return null;
|
|
16140
16298
|
try {
|
|
@@ -16160,12 +16318,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16160
16318
|
throw new Error("Nexus daemon not running. Use action 'connect' first.");
|
|
16161
16319
|
}
|
|
16162
16320
|
const cmdId = randomBytes7(8).toString("hex");
|
|
16163
|
-
const cmdFile =
|
|
16164
|
-
const respFile =
|
|
16321
|
+
const cmdFile = join37(this.nexusDir, "cmd.json");
|
|
16322
|
+
const respFile = join37(this.nexusDir, "resp.json");
|
|
16165
16323
|
if (existsSync23(respFile))
|
|
16166
16324
|
await unlink(respFile).catch(() => {
|
|
16167
16325
|
});
|
|
16168
|
-
await
|
|
16326
|
+
await writeFile18(cmdFile, JSON.stringify({ id: cmdId, action, args }, null, 2));
|
|
16169
16327
|
const pollMs = 50;
|
|
16170
16328
|
const polls = Math.ceil(timeoutMs / pollMs);
|
|
16171
16329
|
let resolved = false;
|
|
@@ -16245,7 +16403,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16245
16403
|
const currentScriptHash = createHash("sha256").update(DAEMON_SCRIPT).digest("hex").slice(0, 16);
|
|
16246
16404
|
const existingPid = this.getDaemonPid();
|
|
16247
16405
|
if (existingPid) {
|
|
16248
|
-
const daemonPath2 =
|
|
16406
|
+
const daemonPath2 = join37(this.nexusDir, "nexus-daemon.mjs");
|
|
16249
16407
|
let needsRestart = true;
|
|
16250
16408
|
if (existsSync23(daemonPath2)) {
|
|
16251
16409
|
try {
|
|
@@ -16269,13 +16427,13 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16269
16427
|
} catch {
|
|
16270
16428
|
}
|
|
16271
16429
|
for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
|
|
16272
|
-
const p =
|
|
16430
|
+
const p = join37(this.nexusDir, f);
|
|
16273
16431
|
if (existsSync23(p))
|
|
16274
16432
|
await unlink(p).catch(() => {
|
|
16275
16433
|
});
|
|
16276
16434
|
}
|
|
16277
16435
|
} else {
|
|
16278
|
-
const statusFile2 =
|
|
16436
|
+
const statusFile2 = join37(this.nexusDir, "status.json");
|
|
16279
16437
|
if (existsSync23(statusFile2)) {
|
|
16280
16438
|
try {
|
|
16281
16439
|
const status = JSON.parse(await readFile18(statusFile2, "utf8"));
|
|
@@ -16294,7 +16452,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16294
16452
|
}
|
|
16295
16453
|
}
|
|
16296
16454
|
for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
|
|
16297
|
-
const p =
|
|
16455
|
+
const p = join37(this.nexusDir, f);
|
|
16298
16456
|
if (existsSync23(p))
|
|
16299
16457
|
await unlink(p).catch(() => {
|
|
16300
16458
|
});
|
|
@@ -16332,7 +16490,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16332
16490
|
});
|
|
16333
16491
|
});
|
|
16334
16492
|
try {
|
|
16335
|
-
const nexusPkg =
|
|
16493
|
+
const nexusPkg = join37(nodeModulesDir, "open-agents-nexus", "package.json");
|
|
16336
16494
|
if (existsSync23(nexusPkg)) {
|
|
16337
16495
|
nexusResolved = true;
|
|
16338
16496
|
try {
|
|
@@ -16343,7 +16501,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16343
16501
|
} else {
|
|
16344
16502
|
try {
|
|
16345
16503
|
const globalDir = await execAsync2("npm root -g", { timeout: 5e3 });
|
|
16346
|
-
const globalPkg =
|
|
16504
|
+
const globalPkg = join37(globalDir, "open-agents-nexus", "package.json");
|
|
16347
16505
|
if (existsSync23(globalPkg)) {
|
|
16348
16506
|
nexusResolved = true;
|
|
16349
16507
|
try {
|
|
@@ -16388,8 +16546,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16388
16546
|
}
|
|
16389
16547
|
}
|
|
16390
16548
|
await this.ensureWallet();
|
|
16391
|
-
const daemonPath =
|
|
16392
|
-
await
|
|
16549
|
+
const daemonPath = join37(this.nexusDir, "nexus-daemon.mjs");
|
|
16550
|
+
await writeFile18(daemonPath, DAEMON_SCRIPT);
|
|
16393
16551
|
const agentName = args.agent_name || "oa-" + hostname().slice(0, 12) + "-" + process.pid;
|
|
16394
16552
|
const agentType = args.agent_type || "general";
|
|
16395
16553
|
const nodePaths = [nodeModulesDir];
|
|
@@ -16399,8 +16557,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16399
16557
|
} catch {
|
|
16400
16558
|
}
|
|
16401
16559
|
const { openSync: openSync2, closeSync: closeSync2 } = await import("node:fs");
|
|
16402
|
-
const daemonLogPath =
|
|
16403
|
-
const daemonErrPath =
|
|
16560
|
+
const daemonLogPath = join37(this.nexusDir, "daemon.log");
|
|
16561
|
+
const daemonErrPath = join37(this.nexusDir, "daemon.err");
|
|
16404
16562
|
const outFd = openSync2(daemonLogPath, "w");
|
|
16405
16563
|
const errFd = openSync2(daemonErrPath, "w");
|
|
16406
16564
|
const child = spawn12("node", [daemonPath, this.nexusDir, agentName, agentType], {
|
|
@@ -16418,7 +16576,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16418
16576
|
closeSync2(errFd);
|
|
16419
16577
|
} catch {
|
|
16420
16578
|
}
|
|
16421
|
-
const statusFile =
|
|
16579
|
+
const statusFile = join37(this.nexusDir, "status.json");
|
|
16422
16580
|
for (let i = 0; i < 40; i++) {
|
|
16423
16581
|
await new Promise((r) => setTimeout(r, 500));
|
|
16424
16582
|
if (existsSync23(statusFile)) {
|
|
@@ -16477,7 +16635,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16477
16635
|
} catch {
|
|
16478
16636
|
}
|
|
16479
16637
|
for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
|
|
16480
|
-
const p =
|
|
16638
|
+
const p = join37(this.nexusDir, f);
|
|
16481
16639
|
if (existsSync23(p))
|
|
16482
16640
|
await unlink(p).catch(() => {
|
|
16483
16641
|
});
|
|
@@ -16488,7 +16646,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16488
16646
|
const pid = this.getDaemonPid();
|
|
16489
16647
|
if (!pid)
|
|
16490
16648
|
return "Nexus daemon not running. Use action 'connect' to start.";
|
|
16491
|
-
const statusFile =
|
|
16649
|
+
const statusFile = join37(this.nexusDir, "status.json");
|
|
16492
16650
|
if (!existsSync23(statusFile))
|
|
16493
16651
|
return `Daemon running (pid: ${pid}) but no status yet.`;
|
|
16494
16652
|
try {
|
|
@@ -16503,7 +16661,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16503
16661
|
` Capabilities: ${(status.capabilities || []).length ? (status.capabilities || []).join(", ") : "none"}`,
|
|
16504
16662
|
` Blocked peers: ${(status.blockedPeers || []).length || 0}`
|
|
16505
16663
|
];
|
|
16506
|
-
const walletPath =
|
|
16664
|
+
const walletPath = join37(this.nexusDir, "wallet.enc");
|
|
16507
16665
|
if (existsSync23(walletPath)) {
|
|
16508
16666
|
try {
|
|
16509
16667
|
const w = JSON.parse(await readFile18(walletPath, "utf8"));
|
|
@@ -16514,14 +16672,14 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16514
16672
|
} else {
|
|
16515
16673
|
lines.push(` Wallet: not configured`);
|
|
16516
16674
|
}
|
|
16517
|
-
const inboxDir =
|
|
16675
|
+
const inboxDir = join37(this.nexusDir, "inbox");
|
|
16518
16676
|
if (existsSync23(inboxDir)) {
|
|
16519
16677
|
try {
|
|
16520
16678
|
const roomDirs = await readdir4(inboxDir);
|
|
16521
16679
|
let totalMsgs = 0;
|
|
16522
16680
|
for (const rd of roomDirs) {
|
|
16523
16681
|
try {
|
|
16524
|
-
totalMsgs += (await readdir4(
|
|
16682
|
+
totalMsgs += (await readdir4(join37(inboxDir, rd))).length;
|
|
16525
16683
|
} catch {
|
|
16526
16684
|
}
|
|
16527
16685
|
}
|
|
@@ -16568,9 +16726,9 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16568
16726
|
}
|
|
16569
16727
|
async doReadMessages(args) {
|
|
16570
16728
|
const roomId = args.room_id;
|
|
16571
|
-
const inboxDir =
|
|
16729
|
+
const inboxDir = join37(this.nexusDir, "inbox");
|
|
16572
16730
|
if (roomId) {
|
|
16573
|
-
const roomInbox =
|
|
16731
|
+
const roomInbox = join37(inboxDir, roomId);
|
|
16574
16732
|
if (!existsSync23(roomInbox))
|
|
16575
16733
|
return `No messages in room: ${roomId}`;
|
|
16576
16734
|
const files = (await readdir4(roomInbox)).sort().slice(-20);
|
|
@@ -16579,7 +16737,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16579
16737
|
const messages = [`Messages in ${roomId} (last ${files.length}):`];
|
|
16580
16738
|
for (const f of files) {
|
|
16581
16739
|
try {
|
|
16582
|
-
const msg = JSON.parse(await readFile18(
|
|
16740
|
+
const msg = JSON.parse(await readFile18(join37(roomInbox, f), "utf8"));
|
|
16583
16741
|
const sender = (msg.sender || "unknown").slice(0, 12);
|
|
16584
16742
|
messages.push(` [${new Date(msg.timestamp).toLocaleTimeString()}] ${sender}...: ${msg.content}`);
|
|
16585
16743
|
} catch {
|
|
@@ -16595,7 +16753,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16595
16753
|
const lines = ["Inbox:"];
|
|
16596
16754
|
for (const rd of roomDirs) {
|
|
16597
16755
|
try {
|
|
16598
|
-
const count = (await readdir4(
|
|
16756
|
+
const count = (await readdir4(join37(inboxDir, rd))).length;
|
|
16599
16757
|
lines.push(` ${rd}: ${count} message(s)`);
|
|
16600
16758
|
} catch {
|
|
16601
16759
|
}
|
|
@@ -16607,7 +16765,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16607
16765
|
// ---------------------------------------------------------------------------
|
|
16608
16766
|
async doWalletStatus() {
|
|
16609
16767
|
await this.ensureDir();
|
|
16610
|
-
const walletPath =
|
|
16768
|
+
const walletPath = join37(this.nexusDir, "wallet.enc");
|
|
16611
16769
|
if (!existsSync23(walletPath)) {
|
|
16612
16770
|
return "No wallet configured. Use wallet_create to set one up.";
|
|
16613
16771
|
}
|
|
@@ -16646,7 +16804,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16646
16804
|
}
|
|
16647
16805
|
async doWalletCreate(args) {
|
|
16648
16806
|
await this.ensureDir();
|
|
16649
|
-
const walletPath =
|
|
16807
|
+
const walletPath = join37(this.nexusDir, "wallet.enc");
|
|
16650
16808
|
if (existsSync23(walletPath))
|
|
16651
16809
|
return "Wallet already exists. Delete wallet.enc to create a new one.";
|
|
16652
16810
|
const userAddress = args.wallet_address;
|
|
@@ -16692,7 +16850,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16692
16850
|
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
16693
16851
|
let enc = cipher.update(privKeyHex, "utf8", "hex");
|
|
16694
16852
|
enc += cipher.final("hex");
|
|
16695
|
-
const x402KeyPath =
|
|
16853
|
+
const x402KeyPath = join37(this.nexusDir, "x402-wallet.key");
|
|
16696
16854
|
const x402Fh = await fsOpen(x402KeyPath, "w", 384);
|
|
16697
16855
|
await x402Fh.writeFile("0x" + privKeyHex);
|
|
16698
16856
|
await x402Fh.close();
|
|
@@ -16730,7 +16888,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16730
16888
|
* Silent — no user output, just ensures the files exist.
|
|
16731
16889
|
*/
|
|
16732
16890
|
async ensureWallet() {
|
|
16733
|
-
const walletPath =
|
|
16891
|
+
const walletPath = join37(this.nexusDir, "wallet.enc");
|
|
16734
16892
|
if (existsSync23(walletPath))
|
|
16735
16893
|
return;
|
|
16736
16894
|
let address;
|
|
@@ -16754,7 +16912,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16754
16912
|
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
16755
16913
|
let enc = cipher.update(privKeyHex, "utf8", "hex");
|
|
16756
16914
|
enc += cipher.final("hex");
|
|
16757
|
-
const x402KeyPath =
|
|
16915
|
+
const x402KeyPath = join37(this.nexusDir, "x402-wallet.key");
|
|
16758
16916
|
const x402Fh = await fsOpen(x402KeyPath, "w", 384);
|
|
16759
16917
|
await x402Fh.writeFile("0x" + privKeyHex);
|
|
16760
16918
|
await x402Fh.close();
|
|
@@ -16814,7 +16972,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16814
16972
|
// ---------------------------------------------------------------------------
|
|
16815
16973
|
async doLedgerStatus() {
|
|
16816
16974
|
await this.ensureDir();
|
|
16817
|
-
const ledgerPath =
|
|
16975
|
+
const ledgerPath = join37(this.nexusDir, "ledger.jsonl");
|
|
16818
16976
|
if (!existsSync23(ledgerPath)) {
|
|
16819
16977
|
return "No ledger entries. Earnings and spending will be tracked here after x402 transactions.";
|
|
16820
16978
|
}
|
|
@@ -16856,7 +17014,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16856
17014
|
}
|
|
16857
17015
|
}
|
|
16858
17016
|
async getLedgerSummary() {
|
|
16859
|
-
const ledgerPath =
|
|
17017
|
+
const ledgerPath = join37(this.nexusDir, "ledger.jsonl");
|
|
16860
17018
|
if (!existsSync23(ledgerPath))
|
|
16861
17019
|
return null;
|
|
16862
17020
|
try {
|
|
@@ -16881,15 +17039,15 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16881
17039
|
}
|
|
16882
17040
|
async appendLedger(entry) {
|
|
16883
17041
|
await this.ensureDir();
|
|
16884
|
-
const ledgerPath =
|
|
17042
|
+
const ledgerPath = join37(this.nexusDir, "ledger.jsonl");
|
|
16885
17043
|
const line = JSON.stringify(entry) + "\n";
|
|
16886
|
-
await
|
|
17044
|
+
await writeFile18(ledgerPath, existsSync23(ledgerPath) ? await readFile18(ledgerPath, "utf8") + line : line);
|
|
16887
17045
|
}
|
|
16888
17046
|
// ---------------------------------------------------------------------------
|
|
16889
17047
|
// Step 4: Budget Policy — Spending limits and auto-approve thresholds
|
|
16890
17048
|
// ---------------------------------------------------------------------------
|
|
16891
17049
|
async loadBudget() {
|
|
16892
|
-
const budgetPath =
|
|
17050
|
+
const budgetPath = join37(this.nexusDir, "budget.json");
|
|
16893
17051
|
if (!existsSync23(budgetPath))
|
|
16894
17052
|
return null;
|
|
16895
17053
|
try {
|
|
@@ -16899,7 +17057,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16899
17057
|
}
|
|
16900
17058
|
}
|
|
16901
17059
|
async ensureDefaultBudget() {
|
|
16902
|
-
const budgetPath =
|
|
17060
|
+
const budgetPath = join37(this.nexusDir, "budget.json");
|
|
16903
17061
|
if (existsSync23(budgetPath))
|
|
16904
17062
|
return;
|
|
16905
17063
|
const defaultBudget = {
|
|
@@ -16920,7 +17078,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16920
17078
|
deniedPeers: []
|
|
16921
17079
|
};
|
|
16922
17080
|
await this.ensureDir();
|
|
16923
|
-
await
|
|
17081
|
+
await writeFile18(budgetPath, JSON.stringify(defaultBudget, null, 2));
|
|
16924
17082
|
}
|
|
16925
17083
|
async doBudgetStatus() {
|
|
16926
17084
|
await this.ensureDir();
|
|
@@ -16969,12 +17127,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
16969
17127
|
if (changes.length === 0) {
|
|
16970
17128
|
return "No budget parameters provided. Use daily_limit, per_invoke_max, or auto_approve_below.";
|
|
16971
17129
|
}
|
|
16972
|
-
const budgetPath =
|
|
16973
|
-
await
|
|
17130
|
+
const budgetPath = join37(this.nexusDir, "budget.json");
|
|
17131
|
+
await writeFile18(budgetPath, JSON.stringify(budget, null, 2));
|
|
16974
17132
|
return `Budget updated: ${changes.join(", ")}`;
|
|
16975
17133
|
}
|
|
16976
17134
|
async getTodaySpending() {
|
|
16977
|
-
const ledgerPath =
|
|
17135
|
+
const ledgerPath = join37(this.nexusDir, "ledger.jsonl");
|
|
16978
17136
|
if (!existsSync23(ledgerPath))
|
|
16979
17137
|
return 0;
|
|
16980
17138
|
try {
|
|
@@ -17018,7 +17176,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17018
17176
|
if (todaySpent + amountUsdc > budget.dailyLimitUsdc) {
|
|
17019
17177
|
return { allowed: false, reason: `Would exceed daily limit ($${((todaySpent + amountUsdc) / 1e6).toFixed(6)} > $${(budget.dailyLimitUsdc / 1e6).toFixed(6)})` };
|
|
17020
17178
|
}
|
|
17021
|
-
const walletPath =
|
|
17179
|
+
const walletPath = join37(this.nexusDir, "wallet.enc");
|
|
17022
17180
|
if (existsSync23(walletPath)) {
|
|
17023
17181
|
try {
|
|
17024
17182
|
const w = JSON.parse(await readFile18(walletPath, "utf8"));
|
|
@@ -17049,7 +17207,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17049
17207
|
const budgetResult = await this.checkBudget(amountSmallest, "transfer:direct", targetAddress);
|
|
17050
17208
|
if (!budgetResult.allowed)
|
|
17051
17209
|
return `BLOCKED by budget policy: ${budgetResult.reason}`;
|
|
17052
|
-
const walletPath =
|
|
17210
|
+
const walletPath = join37(this.nexusDir, "wallet.enc");
|
|
17053
17211
|
if (!existsSync23(walletPath))
|
|
17054
17212
|
throw new Error("No wallet. Use wallet_create first.");
|
|
17055
17213
|
const w = JSON.parse(await readFile18(walletPath, "utf8"));
|
|
@@ -17110,7 +17268,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17110
17268
|
capability: "transfer:direct",
|
|
17111
17269
|
note: "signed, awaiting submission"
|
|
17112
17270
|
});
|
|
17113
|
-
const proofFile =
|
|
17271
|
+
const proofFile = join37(this.nexusDir, "pending-transfer.json");
|
|
17114
17272
|
const proof = {
|
|
17115
17273
|
from: account.address,
|
|
17116
17274
|
to: targetAddress,
|
|
@@ -17123,7 +17281,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17123
17281
|
usdcContract: USDC_ADDRESS,
|
|
17124
17282
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
17125
17283
|
};
|
|
17126
|
-
await
|
|
17284
|
+
await writeFile18(proofFile, JSON.stringify(proof, null, 2));
|
|
17127
17285
|
return [
|
|
17128
17286
|
`Transfer signed (EIP-3009 TransferWithAuthorization):`,
|
|
17129
17287
|
` From: ${account.address}`,
|
|
@@ -17152,7 +17310,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17152
17310
|
throw new Error("prompt is required");
|
|
17153
17311
|
const estimatedTokens = Math.ceil(prompt.length / 4) + 1e3;
|
|
17154
17312
|
let estimatedCostSmallest = 0;
|
|
17155
|
-
const pricingPath =
|
|
17313
|
+
const pricingPath = join37(this.nexusDir, "pricing.json");
|
|
17156
17314
|
if (existsSync23(pricingPath)) {
|
|
17157
17315
|
try {
|
|
17158
17316
|
const pricing = JSON.parse(await readFile18(pricingPath, "utf8"));
|
|
@@ -17272,7 +17430,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
17272
17430
|
const bar = (s) => "\u2588".repeat(Math.round(s / 5)) + "\u2591".repeat(20 - Math.round(s / 5));
|
|
17273
17431
|
const mem = vramMb > 24e3 ? 95 : vramMb > 16e3 ? 80 : vramMb > 8e3 ? 60 : vramMb > 0 ? 40 : 20;
|
|
17274
17432
|
await this.ensureDir();
|
|
17275
|
-
await
|
|
17433
|
+
await writeFile18(join37(this.nexusDir, "inference-proof.json"), JSON.stringify({
|
|
17276
17434
|
modelName,
|
|
17277
17435
|
gpuName,
|
|
17278
17436
|
vramMb,
|
|
@@ -17991,6 +18149,7 @@ __export(dist_exports, {
|
|
|
17991
18149
|
GlobFindTool: () => GlobFindTool,
|
|
17992
18150
|
GrepSearchTool: () => GrepSearchTool,
|
|
17993
18151
|
IdentityKernelTool: () => IdentityKernelTool,
|
|
18152
|
+
ImageGenerateTool: () => ImageGenerateTool,
|
|
17994
18153
|
ImageReadTool: () => ImageReadTool,
|
|
17995
18154
|
ListDirectoryTool: () => ListDirectoryTool,
|
|
17996
18155
|
ManageToolsTool: () => ManageToolsTool,
|
|
@@ -18097,6 +18256,7 @@ var init_dist2 = __esm({
|
|
|
18097
18256
|
init_reflection_integrity();
|
|
18098
18257
|
init_exploration_culture();
|
|
18099
18258
|
init_embedding_store();
|
|
18259
|
+
init_image_generate();
|
|
18100
18260
|
init_structured_read();
|
|
18101
18261
|
init_vision();
|
|
18102
18262
|
init_desktop_click();
|
|
@@ -18797,12 +18957,12 @@ var init_dist3 = __esm({
|
|
|
18797
18957
|
|
|
18798
18958
|
// packages/orchestrator/dist/promptLoader.js
|
|
18799
18959
|
import { readFileSync as readFileSync18, existsSync as existsSync25 } from "node:fs";
|
|
18800
|
-
import { join as
|
|
18960
|
+
import { join as join38, dirname as dirname12 } from "node:path";
|
|
18801
18961
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
18802
18962
|
function loadPrompt(promptPath, vars) {
|
|
18803
18963
|
let content = cache.get(promptPath);
|
|
18804
18964
|
if (content === void 0) {
|
|
18805
|
-
const fullPath =
|
|
18965
|
+
const fullPath = join38(PROMPTS_DIR, promptPath);
|
|
18806
18966
|
if (!existsSync25(fullPath)) {
|
|
18807
18967
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
18808
18968
|
}
|
|
@@ -18819,7 +18979,7 @@ var init_promptLoader = __esm({
|
|
|
18819
18979
|
"use strict";
|
|
18820
18980
|
__filename = fileURLToPath7(import.meta.url);
|
|
18821
18981
|
__dirname4 = dirname12(__filename);
|
|
18822
|
-
PROMPTS_DIR =
|
|
18982
|
+
PROMPTS_DIR = join38(__dirname4, "..", "prompts");
|
|
18823
18983
|
cache = /* @__PURE__ */ new Map();
|
|
18824
18984
|
}
|
|
18825
18985
|
});
|
|
@@ -19199,7 +19359,7 @@ var init_code_retriever = __esm({
|
|
|
19199
19359
|
import { execFile as execFile5 } from "node:child_process";
|
|
19200
19360
|
import { promisify as promisify4 } from "node:util";
|
|
19201
19361
|
import { readFile as readFile19, readdir as readdir5, stat as stat3 } from "node:fs/promises";
|
|
19202
|
-
import { join as
|
|
19362
|
+
import { join as join39, extname as extname7 } from "node:path";
|
|
19203
19363
|
async function searchByPath(pathPattern, options) {
|
|
19204
19364
|
const allFiles = await collectFiles(options.rootDir, options.includeGlobs ?? DEFAULT_INCLUDE_GLOBS, options.excludeGlobs ?? DEFAULT_EXCLUDE_GLOBS);
|
|
19205
19365
|
const pattern = options.caseInsensitive ? pathPattern.toLowerCase() : pathPattern;
|
|
@@ -19341,7 +19501,7 @@ async function walkForFiles(rootDir, dir, excludeGlobs, results) {
|
|
|
19341
19501
|
continue;
|
|
19342
19502
|
if (excludeGlobs.some((g) => entry.name === g || matchesGlob(entry.name, g)))
|
|
19343
19503
|
continue;
|
|
19344
|
-
const absPath =
|
|
19504
|
+
const absPath = join39(dir, entry.name);
|
|
19345
19505
|
if (entry.isDirectory()) {
|
|
19346
19506
|
await walkForFiles(rootDir, absPath, excludeGlobs, results);
|
|
19347
19507
|
} else if (entry.isFile()) {
|
|
@@ -19648,7 +19808,7 @@ var init_graphExpand = __esm({
|
|
|
19648
19808
|
|
|
19649
19809
|
// packages/retrieval/dist/snippetPacker.js
|
|
19650
19810
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
19651
|
-
import { join as
|
|
19811
|
+
import { join as join40 } from "node:path";
|
|
19652
19812
|
async function packSnippets(requests, opts = {}) {
|
|
19653
19813
|
const maxTokens = opts.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
19654
19814
|
const contextLines = opts.contextLines ?? DEFAULT_CONTEXT_LINES;
|
|
@@ -19674,7 +19834,7 @@ async function packSnippets(requests, opts = {}) {
|
|
|
19674
19834
|
return { packed, dropped, totalTokens };
|
|
19675
19835
|
}
|
|
19676
19836
|
async function extractSnippet(req, repoRoot, contextLines = DEFAULT_CONTEXT_LINES) {
|
|
19677
|
-
const absPath = req.filePath.startsWith("/") ? req.filePath :
|
|
19837
|
+
const absPath = req.filePath.startsWith("/") ? req.filePath : join40(repoRoot, req.filePath);
|
|
19678
19838
|
let content;
|
|
19679
19839
|
try {
|
|
19680
19840
|
content = await readFile20(absPath, "utf-8");
|
|
@@ -21422,6 +21582,10 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
21422
21582
|
this.emit({ type: "error", content: `Model not available. Use /model to select a different model.`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
21423
21583
|
break;
|
|
21424
21584
|
}
|
|
21585
|
+
if (/does not support tools|HTTP 400.*tools/i.test(errMsg)) {
|
|
21586
|
+
this.emit({ type: "error", content: `Model does not support tool calling. Use /model to select a model with tool support (e.g., qwen3.5, nemotron).`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
21587
|
+
break;
|
|
21588
|
+
}
|
|
21425
21589
|
messages.push({ role: "user", content: "[System: backend request failed, retrying on next turn. The previous request was lost.]" });
|
|
21426
21590
|
continue;
|
|
21427
21591
|
}
|
|
@@ -22272,8 +22436,8 @@ ${marker}` : marker);
|
|
|
22272
22436
|
return;
|
|
22273
22437
|
try {
|
|
22274
22438
|
const { mkdirSync: mkdirSync21, writeFileSync: writeFileSync20 } = __require("node:fs");
|
|
22275
|
-
const { join:
|
|
22276
|
-
const sessionDir =
|
|
22439
|
+
const { join: join64 } = __require("node:path");
|
|
22440
|
+
const sessionDir = join64(this._workingDirectory, ".oa", "session", this._sessionId);
|
|
22277
22441
|
mkdirSync21(sessionDir, { recursive: true });
|
|
22278
22442
|
const checkpoint = {
|
|
22279
22443
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -22286,7 +22450,7 @@ ${marker}` : marker);
|
|
|
22286
22450
|
memexEntryCount: this._memexArchive.size,
|
|
22287
22451
|
fileRegistrySize: this._fileRegistry.size
|
|
22288
22452
|
};
|
|
22289
|
-
writeFileSync20(
|
|
22453
|
+
writeFileSync20(join64(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
22290
22454
|
} catch {
|
|
22291
22455
|
}
|
|
22292
22456
|
}
|
|
@@ -23554,7 +23718,7 @@ ${transcript}`
|
|
|
23554
23718
|
// packages/orchestrator/dist/nexusBackend.js
|
|
23555
23719
|
import { existsSync as existsSync26, statSync as statSync9, openSync, readSync, closeSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "node:fs";
|
|
23556
23720
|
import { watch as fsWatch } from "node:fs";
|
|
23557
|
-
import { join as
|
|
23721
|
+
import { join as join41 } from "node:path";
|
|
23558
23722
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
23559
23723
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
23560
23724
|
var NexusAgenticBackend;
|
|
@@ -23704,7 +23868,7 @@ var init_nexusBackend = __esm({
|
|
|
23704
23868
|
* Falls back to unary + word-split if streaming setup fails.
|
|
23705
23869
|
*/
|
|
23706
23870
|
async *chatCompletionStream(request) {
|
|
23707
|
-
const streamFile =
|
|
23871
|
+
const streamFile = join41(tmpdir7(), `nexus-stream-${randomBytes8(6).toString("hex")}.jsonl`);
|
|
23708
23872
|
writeFileSync8(streamFile, "", "utf8");
|
|
23709
23873
|
const daemonArgs = {
|
|
23710
23874
|
model: this.model,
|
|
@@ -24741,7 +24905,7 @@ __export(listen_exports, {
|
|
|
24741
24905
|
});
|
|
24742
24906
|
import { spawn as spawn15, execSync as execSync22 } from "node:child_process";
|
|
24743
24907
|
import { existsSync as existsSync27, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readdirSync as readdirSync6 } from "node:fs";
|
|
24744
|
-
import { join as
|
|
24908
|
+
import { join as join42, dirname as dirname13 } from "node:path";
|
|
24745
24909
|
import { homedir as homedir8 } from "node:os";
|
|
24746
24910
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
24747
24911
|
import { EventEmitter } from "node:events";
|
|
@@ -24827,12 +24991,12 @@ function findMicCaptureCommand() {
|
|
|
24827
24991
|
function findLiveWhisperScript() {
|
|
24828
24992
|
const thisDir = dirname13(fileURLToPath8(import.meta.url));
|
|
24829
24993
|
const candidates = [
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
24994
|
+
join42(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
|
|
24995
|
+
join42(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
|
|
24996
|
+
join42(thisDir, "../../execution/scripts/live-whisper.py"),
|
|
24833
24997
|
// npm install layout — scripts bundled alongside dist
|
|
24834
|
-
|
|
24835
|
-
|
|
24998
|
+
join42(thisDir, "../scripts/live-whisper.py"),
|
|
24999
|
+
join42(thisDir, "../../scripts/live-whisper.py")
|
|
24836
25000
|
];
|
|
24837
25001
|
for (const p of candidates) {
|
|
24838
25002
|
if (existsSync27(p))
|
|
@@ -24845,8 +25009,8 @@ function findLiveWhisperScript() {
|
|
|
24845
25009
|
stdio: ["pipe", "pipe", "pipe"]
|
|
24846
25010
|
}).trim();
|
|
24847
25011
|
const candidates2 = [
|
|
24848
|
-
|
|
24849
|
-
|
|
25012
|
+
join42(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
|
|
25013
|
+
join42(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
|
|
24850
25014
|
];
|
|
24851
25015
|
for (const p of candidates2) {
|
|
24852
25016
|
if (existsSync27(p))
|
|
@@ -24854,11 +25018,11 @@ function findLiveWhisperScript() {
|
|
|
24854
25018
|
}
|
|
24855
25019
|
} catch {
|
|
24856
25020
|
}
|
|
24857
|
-
const nvmBase =
|
|
25021
|
+
const nvmBase = join42(homedir8(), ".nvm", "versions", "node");
|
|
24858
25022
|
if (existsSync27(nvmBase)) {
|
|
24859
25023
|
try {
|
|
24860
25024
|
for (const ver of readdirSync6(nvmBase)) {
|
|
24861
|
-
const p =
|
|
25025
|
+
const p = join42(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
|
|
24862
25026
|
if (existsSync27(p))
|
|
24863
25027
|
return p;
|
|
24864
25028
|
}
|
|
@@ -24877,7 +25041,7 @@ function ensureTranscribeCliBackground() {
|
|
|
24877
25041
|
timeout: 5e3,
|
|
24878
25042
|
stdio: ["pipe", "pipe", "pipe"]
|
|
24879
25043
|
}).trim();
|
|
24880
|
-
if (existsSync27(
|
|
25044
|
+
if (existsSync27(join42(globalRoot, "transcribe-cli", "dist", "index.js"))) {
|
|
24881
25045
|
return true;
|
|
24882
25046
|
}
|
|
24883
25047
|
} catch {
|
|
@@ -25100,24 +25264,24 @@ var init_listen = __esm({
|
|
|
25100
25264
|
timeout: 5e3,
|
|
25101
25265
|
stdio: ["pipe", "pipe", "pipe"]
|
|
25102
25266
|
}).trim();
|
|
25103
|
-
const tcPath =
|
|
25104
|
-
if (existsSync27(
|
|
25267
|
+
const tcPath = join42(globalRoot, "transcribe-cli");
|
|
25268
|
+
if (existsSync27(join42(tcPath, "dist", "index.js"))) {
|
|
25105
25269
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
25106
25270
|
const req = createRequire4(import.meta.url);
|
|
25107
|
-
return req(
|
|
25271
|
+
return req(join42(tcPath, "dist", "index.js"));
|
|
25108
25272
|
}
|
|
25109
25273
|
} catch {
|
|
25110
25274
|
}
|
|
25111
|
-
const nvmBase =
|
|
25275
|
+
const nvmBase = join42(homedir8(), ".nvm", "versions", "node");
|
|
25112
25276
|
if (existsSync27(nvmBase)) {
|
|
25113
25277
|
try {
|
|
25114
25278
|
const { readdirSync: readdirSync17 } = await import("node:fs");
|
|
25115
25279
|
for (const ver of readdirSync17(nvmBase)) {
|
|
25116
|
-
const tcPath =
|
|
25117
|
-
if (existsSync27(
|
|
25280
|
+
const tcPath = join42(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
|
|
25281
|
+
if (existsSync27(join42(tcPath, "dist", "index.js"))) {
|
|
25118
25282
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
25119
25283
|
const req = createRequire4(import.meta.url);
|
|
25120
|
-
return req(
|
|
25284
|
+
return req(join42(tcPath, "dist", "index.js"));
|
|
25121
25285
|
}
|
|
25122
25286
|
}
|
|
25123
25287
|
} catch {
|
|
@@ -25399,9 +25563,9 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
25399
25563
|
});
|
|
25400
25564
|
if (outputDir) {
|
|
25401
25565
|
const { basename: basename16 } = await import("node:path");
|
|
25402
|
-
const transcriptDir =
|
|
25566
|
+
const transcriptDir = join42(outputDir, ".oa", "transcripts");
|
|
25403
25567
|
mkdirSync8(transcriptDir, { recursive: true });
|
|
25404
|
-
const outFile =
|
|
25568
|
+
const outFile = join42(transcriptDir, `${basename16(filePath)}.txt`);
|
|
25405
25569
|
writeFileSync9(outFile, result.text, "utf-8");
|
|
25406
25570
|
}
|
|
25407
25571
|
return {
|
|
@@ -30760,7 +30924,7 @@ import { randomBytes as randomBytes9 } from "node:crypto";
|
|
|
30760
30924
|
import { URL as URL2 } from "node:url";
|
|
30761
30925
|
import { loadavg, cpus, totalmem, freemem } from "node:os";
|
|
30762
30926
|
import { existsSync as existsSync28, readFileSync as readFileSync19, writeFileSync as writeFileSync10, unlinkSync as unlinkSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync7, statSync as statSync10 } from "node:fs";
|
|
30763
|
-
import { join as
|
|
30927
|
+
import { join as join43 } from "node:path";
|
|
30764
30928
|
function cleanForwardHeaders(raw, targetHost) {
|
|
30765
30929
|
const out = {};
|
|
30766
30930
|
for (const [key, value] of Object.entries(raw)) {
|
|
@@ -30788,7 +30952,7 @@ function fmtTokens(n) {
|
|
|
30788
30952
|
}
|
|
30789
30953
|
function readExposeState(stateDir) {
|
|
30790
30954
|
try {
|
|
30791
|
-
const path =
|
|
30955
|
+
const path = join43(stateDir, STATE_FILE_NAME);
|
|
30792
30956
|
if (!existsSync28(path))
|
|
30793
30957
|
return null;
|
|
30794
30958
|
const raw = readFileSync19(path, "utf8");
|
|
@@ -30803,13 +30967,13 @@ function readExposeState(stateDir) {
|
|
|
30803
30967
|
function writeExposeState(stateDir, state) {
|
|
30804
30968
|
try {
|
|
30805
30969
|
mkdirSync9(stateDir, { recursive: true });
|
|
30806
|
-
writeFileSync10(
|
|
30970
|
+
writeFileSync10(join43(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
30807
30971
|
} catch {
|
|
30808
30972
|
}
|
|
30809
30973
|
}
|
|
30810
30974
|
function removeExposeState(stateDir) {
|
|
30811
30975
|
try {
|
|
30812
|
-
unlinkSync5(
|
|
30976
|
+
unlinkSync5(join43(stateDir, STATE_FILE_NAME));
|
|
30813
30977
|
} catch {
|
|
30814
30978
|
}
|
|
30815
30979
|
}
|
|
@@ -30898,7 +31062,7 @@ async function collectSystemMetricsAsync() {
|
|
|
30898
31062
|
}
|
|
30899
31063
|
function readP2PExposeState(stateDir) {
|
|
30900
31064
|
try {
|
|
30901
|
-
const path =
|
|
31065
|
+
const path = join43(stateDir, P2P_STATE_FILE_NAME);
|
|
30902
31066
|
if (!existsSync28(path))
|
|
30903
31067
|
return null;
|
|
30904
31068
|
const raw = readFileSync19(path, "utf8");
|
|
@@ -30913,13 +31077,13 @@ function readP2PExposeState(stateDir) {
|
|
|
30913
31077
|
function writeP2PExposeState(stateDir, state) {
|
|
30914
31078
|
try {
|
|
30915
31079
|
mkdirSync9(stateDir, { recursive: true });
|
|
30916
|
-
writeFileSync10(
|
|
31080
|
+
writeFileSync10(join43(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
30917
31081
|
} catch {
|
|
30918
31082
|
}
|
|
30919
31083
|
}
|
|
30920
31084
|
function removeP2PExposeState(stateDir) {
|
|
30921
31085
|
try {
|
|
30922
|
-
unlinkSync5(
|
|
31086
|
+
unlinkSync5(join43(stateDir, P2P_STATE_FILE_NAME));
|
|
30923
31087
|
} catch {
|
|
30924
31088
|
}
|
|
30925
31089
|
}
|
|
@@ -31767,7 +31931,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31767
31931
|
throw new Error(`Expose failed: ${exposeResult.error}`);
|
|
31768
31932
|
}
|
|
31769
31933
|
const nexusDir = this._nexusTool.getNexusDir();
|
|
31770
|
-
const statusPath =
|
|
31934
|
+
const statusPath = join43(nexusDir, "status.json");
|
|
31771
31935
|
for (let i = 0; i < 80; i++) {
|
|
31772
31936
|
try {
|
|
31773
31937
|
const raw = readFileSync19(statusPath, "utf8");
|
|
@@ -31801,7 +31965,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31801
31965
|
});
|
|
31802
31966
|
}
|
|
31803
31967
|
try {
|
|
31804
|
-
const invocDir =
|
|
31968
|
+
const invocDir = join43(nexusDir, "invocations");
|
|
31805
31969
|
if (existsSync28(invocDir)) {
|
|
31806
31970
|
this._prevInvocCount = readdirSync7(invocDir).filter((f) => f.endsWith(".json")).length;
|
|
31807
31971
|
this._stats.totalRequests = this._prevInvocCount;
|
|
@@ -31831,7 +31995,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31831
31995
|
if (!state)
|
|
31832
31996
|
return null;
|
|
31833
31997
|
const nexusDir = nexusTool.getNexusDir();
|
|
31834
|
-
const statusPath =
|
|
31998
|
+
const statusPath = join43(nexusDir, "status.json");
|
|
31835
31999
|
try {
|
|
31836
32000
|
if (!existsSync28(statusPath)) {
|
|
31837
32001
|
removeP2PExposeState(stateDir);
|
|
@@ -31890,7 +32054,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31890
32054
|
let lastMeteringLineCount = 0;
|
|
31891
32055
|
this._activityPollTimer = setInterval(() => {
|
|
31892
32056
|
try {
|
|
31893
|
-
const invocDir =
|
|
32057
|
+
const invocDir = join43(nexusDir, "invocations");
|
|
31894
32058
|
if (!existsSync28(invocDir))
|
|
31895
32059
|
return;
|
|
31896
32060
|
const files = readdirSync7(invocDir).filter((f) => f.endsWith(".json"));
|
|
@@ -31906,13 +32070,13 @@ ${this.formatConnectionInfo()}`);
|
|
|
31906
32070
|
let recentActive = 0;
|
|
31907
32071
|
for (const f of files.slice(-10)) {
|
|
31908
32072
|
try {
|
|
31909
|
-
const st = statSync10(
|
|
32073
|
+
const st = statSync10(join43(invocDir, f));
|
|
31910
32074
|
if (now - st.mtimeMs < 1e4)
|
|
31911
32075
|
recentActive++;
|
|
31912
32076
|
} catch {
|
|
31913
32077
|
}
|
|
31914
32078
|
}
|
|
31915
|
-
const meteringFile =
|
|
32079
|
+
const meteringFile = join43(nexusDir, "metering.jsonl");
|
|
31916
32080
|
let meteringLines = lastMeteringLineCount;
|
|
31917
32081
|
try {
|
|
31918
32082
|
if (existsSync28(meteringFile)) {
|
|
@@ -31942,7 +32106,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31942
32106
|
this._activityPollTimer.unref();
|
|
31943
32107
|
this._pollTimer = setInterval(() => {
|
|
31944
32108
|
try {
|
|
31945
|
-
const statusPath =
|
|
32109
|
+
const statusPath = join43(nexusDir, "status.json");
|
|
31946
32110
|
if (existsSync28(statusPath)) {
|
|
31947
32111
|
const status = JSON.parse(readFileSync19(statusPath, "utf8"));
|
|
31948
32112
|
if (status.peerId && !this._peerId) {
|
|
@@ -31953,7 +32117,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31953
32117
|
} catch {
|
|
31954
32118
|
}
|
|
31955
32119
|
try {
|
|
31956
|
-
const invocDir =
|
|
32120
|
+
const invocDir = join43(nexusDir, "invocations");
|
|
31957
32121
|
if (existsSync28(invocDir)) {
|
|
31958
32122
|
const files = readdirSync7(invocDir);
|
|
31959
32123
|
const invocCount = files.filter((f) => f.endsWith(".json")).length;
|
|
@@ -31965,7 +32129,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
31965
32129
|
} catch {
|
|
31966
32130
|
}
|
|
31967
32131
|
try {
|
|
31968
|
-
const meteringFile =
|
|
32132
|
+
const meteringFile = join43(nexusDir, "metering.jsonl");
|
|
31969
32133
|
if (existsSync28(meteringFile)) {
|
|
31970
32134
|
const content = readFileSync19(meteringFile, "utf8");
|
|
31971
32135
|
if (content.length > lastMeteringSize) {
|
|
@@ -32177,7 +32341,7 @@ var init_types = __esm({
|
|
|
32177
32341
|
// packages/cli/dist/tui/p2p/secret-vault.js
|
|
32178
32342
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes10, scryptSync as scryptSync2, createHash as createHash2 } from "node:crypto";
|
|
32179
32343
|
import { readFileSync as readFileSync20, writeFileSync as writeFileSync11, existsSync as existsSync29, mkdirSync as mkdirSync10 } from "node:fs";
|
|
32180
|
-
import { join as
|
|
32344
|
+
import { join as join44, dirname as dirname14 } from "node:path";
|
|
32181
32345
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
32182
32346
|
var init_secret_vault = __esm({
|
|
32183
32347
|
"packages/cli/dist/tui/p2p/secret-vault.js"() {
|
|
@@ -33522,13 +33686,13 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
33522
33686
|
try {
|
|
33523
33687
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
33524
33688
|
const { existsSync: existsSync45, readFileSync: readFileSync33 } = await import("node:fs");
|
|
33525
|
-
const { join:
|
|
33689
|
+
const { join: join64 } = await import("node:path");
|
|
33526
33690
|
const cwd4 = process.cwd();
|
|
33527
33691
|
const nexusTool = new NexusTool2(cwd4);
|
|
33528
33692
|
const nexusDir = nexusTool.getNexusDir();
|
|
33529
33693
|
let isLocalPeer = false;
|
|
33530
33694
|
try {
|
|
33531
|
-
const statusPath =
|
|
33695
|
+
const statusPath = join64(nexusDir, "status.json");
|
|
33532
33696
|
if (existsSync45(statusPath)) {
|
|
33533
33697
|
const status = JSON.parse(readFileSync33(statusPath, "utf8"));
|
|
33534
33698
|
if (status.peerId === peerId)
|
|
@@ -33537,7 +33701,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
33537
33701
|
} catch {
|
|
33538
33702
|
}
|
|
33539
33703
|
if (isLocalPeer) {
|
|
33540
|
-
const pricingPath =
|
|
33704
|
+
const pricingPath = join64(nexusDir, "pricing.json");
|
|
33541
33705
|
if (existsSync45(pricingPath)) {
|
|
33542
33706
|
try {
|
|
33543
33707
|
const pricing = JSON.parse(readFileSync33(pricingPath, "utf8"));
|
|
@@ -33554,7 +33718,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
33554
33718
|
}
|
|
33555
33719
|
}
|
|
33556
33720
|
}
|
|
33557
|
-
const cachePath =
|
|
33721
|
+
const cachePath = join64(nexusDir, "peer-models-cache.json");
|
|
33558
33722
|
if (existsSync45(cachePath)) {
|
|
33559
33723
|
try {
|
|
33560
33724
|
const cache4 = JSON.parse(readFileSync33(cachePath, "utf8"));
|
|
@@ -33672,7 +33836,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
33672
33836
|
} catch {
|
|
33673
33837
|
}
|
|
33674
33838
|
if (isLocalPeer) {
|
|
33675
|
-
const pricingPath =
|
|
33839
|
+
const pricingPath = join64(nexusDir, "pricing.json");
|
|
33676
33840
|
if (existsSync45(pricingPath)) {
|
|
33677
33841
|
try {
|
|
33678
33842
|
const pricing = JSON.parse(readFileSync33(pricingPath, "utf8"));
|
|
@@ -33956,12 +34120,12 @@ var init_render2 = __esm({
|
|
|
33956
34120
|
|
|
33957
34121
|
// packages/prompts/dist/promptLoader.js
|
|
33958
34122
|
import { readFileSync as readFileSync21, existsSync as existsSync30 } from "node:fs";
|
|
33959
|
-
import { join as
|
|
34123
|
+
import { join as join45, dirname as dirname15 } from "node:path";
|
|
33960
34124
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
33961
34125
|
function loadPrompt2(promptPath, vars) {
|
|
33962
34126
|
let content = cache2.get(promptPath);
|
|
33963
34127
|
if (content === void 0) {
|
|
33964
|
-
const fullPath =
|
|
34128
|
+
const fullPath = join45(PROMPTS_DIR2, promptPath);
|
|
33965
34129
|
if (!existsSync30(fullPath)) {
|
|
33966
34130
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
33967
34131
|
}
|
|
@@ -33978,8 +34142,8 @@ var init_promptLoader2 = __esm({
|
|
|
33978
34142
|
"use strict";
|
|
33979
34143
|
__filename2 = fileURLToPath9(import.meta.url);
|
|
33980
34144
|
__dirname5 = dirname15(__filename2);
|
|
33981
|
-
devPath =
|
|
33982
|
-
publishedPath =
|
|
34145
|
+
devPath = join45(__dirname5, "..", "templates");
|
|
34146
|
+
publishedPath = join45(__dirname5, "..", "prompts", "templates");
|
|
33983
34147
|
PROMPTS_DIR2 = existsSync30(devPath) ? devPath : publishedPath;
|
|
33984
34148
|
cache2 = /* @__PURE__ */ new Map();
|
|
33985
34149
|
}
|
|
@@ -34091,7 +34255,7 @@ var init_task_templates = __esm({
|
|
|
34091
34255
|
});
|
|
34092
34256
|
|
|
34093
34257
|
// packages/prompts/dist/index.js
|
|
34094
|
-
import { join as
|
|
34258
|
+
import { join as join46, dirname as dirname16 } from "node:path";
|
|
34095
34259
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
34096
34260
|
var _dir, _packageRoot;
|
|
34097
34261
|
var init_dist6 = __esm({
|
|
@@ -34102,21 +34266,21 @@ var init_dist6 = __esm({
|
|
|
34102
34266
|
init_task_templates();
|
|
34103
34267
|
init_render2();
|
|
34104
34268
|
_dir = dirname16(fileURLToPath10(import.meta.url));
|
|
34105
|
-
_packageRoot =
|
|
34269
|
+
_packageRoot = join46(_dir, "..");
|
|
34106
34270
|
}
|
|
34107
34271
|
});
|
|
34108
34272
|
|
|
34109
34273
|
// packages/cli/dist/tui/oa-directory.js
|
|
34110
34274
|
import { existsSync as existsSync31, mkdirSync as mkdirSync11, readFileSync as readFileSync22, writeFileSync as writeFileSync12, readdirSync as readdirSync8, statSync as statSync11, unlinkSync as unlinkSync6 } from "node:fs";
|
|
34111
|
-
import { join as
|
|
34275
|
+
import { join as join47, relative as relative2, basename as basename9, extname as extname8 } from "node:path";
|
|
34112
34276
|
import { homedir as homedir9 } from "node:os";
|
|
34113
34277
|
function initOaDirectory(repoRoot) {
|
|
34114
|
-
const oaPath =
|
|
34278
|
+
const oaPath = join47(repoRoot, OA_DIR);
|
|
34115
34279
|
for (const sub of SUBDIRS) {
|
|
34116
|
-
mkdirSync11(
|
|
34280
|
+
mkdirSync11(join47(oaPath, sub), { recursive: true });
|
|
34117
34281
|
}
|
|
34118
34282
|
try {
|
|
34119
|
-
const gitignorePath =
|
|
34283
|
+
const gitignorePath = join47(repoRoot, ".gitignore");
|
|
34120
34284
|
const settingsPattern = ".oa/settings.json";
|
|
34121
34285
|
if (existsSync31(gitignorePath)) {
|
|
34122
34286
|
const content = readFileSync22(gitignorePath, "utf-8");
|
|
@@ -34129,10 +34293,10 @@ function initOaDirectory(repoRoot) {
|
|
|
34129
34293
|
return oaPath;
|
|
34130
34294
|
}
|
|
34131
34295
|
function hasOaDirectory(repoRoot) {
|
|
34132
|
-
return existsSync31(
|
|
34296
|
+
return existsSync31(join47(repoRoot, OA_DIR, "index"));
|
|
34133
34297
|
}
|
|
34134
34298
|
function loadProjectSettings(repoRoot) {
|
|
34135
|
-
const settingsPath =
|
|
34299
|
+
const settingsPath = join47(repoRoot, OA_DIR, "settings.json");
|
|
34136
34300
|
try {
|
|
34137
34301
|
if (existsSync31(settingsPath)) {
|
|
34138
34302
|
return JSON.parse(readFileSync22(settingsPath, "utf-8"));
|
|
@@ -34142,14 +34306,14 @@ function loadProjectSettings(repoRoot) {
|
|
|
34142
34306
|
return {};
|
|
34143
34307
|
}
|
|
34144
34308
|
function saveProjectSettings(repoRoot, settings) {
|
|
34145
|
-
const oaPath =
|
|
34309
|
+
const oaPath = join47(repoRoot, OA_DIR);
|
|
34146
34310
|
mkdirSync11(oaPath, { recursive: true });
|
|
34147
34311
|
const existing = loadProjectSettings(repoRoot);
|
|
34148
34312
|
const merged = { ...existing, ...settings };
|
|
34149
|
-
writeFileSync12(
|
|
34313
|
+
writeFileSync12(join47(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
34150
34314
|
}
|
|
34151
34315
|
function loadGlobalSettings() {
|
|
34152
|
-
const settingsPath =
|
|
34316
|
+
const settingsPath = join47(homedir9(), ".open-agents", "settings.json");
|
|
34153
34317
|
try {
|
|
34154
34318
|
if (existsSync31(settingsPath)) {
|
|
34155
34319
|
return JSON.parse(readFileSync22(settingsPath, "utf-8"));
|
|
@@ -34159,11 +34323,11 @@ function loadGlobalSettings() {
|
|
|
34159
34323
|
return {};
|
|
34160
34324
|
}
|
|
34161
34325
|
function saveGlobalSettings(settings) {
|
|
34162
|
-
const dir =
|
|
34326
|
+
const dir = join47(homedir9(), ".open-agents");
|
|
34163
34327
|
mkdirSync11(dir, { recursive: true });
|
|
34164
34328
|
const existing = loadGlobalSettings();
|
|
34165
34329
|
const merged = { ...existing, ...settings };
|
|
34166
|
-
writeFileSync12(
|
|
34330
|
+
writeFileSync12(join47(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
34167
34331
|
}
|
|
34168
34332
|
function resolveSettings(repoRoot) {
|
|
34169
34333
|
const global = loadGlobalSettings();
|
|
@@ -34178,7 +34342,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
34178
34342
|
while (dir && !visited.has(dir)) {
|
|
34179
34343
|
visited.add(dir);
|
|
34180
34344
|
for (const name of CONTEXT_FILES) {
|
|
34181
|
-
const filePath =
|
|
34345
|
+
const filePath = join47(dir, name);
|
|
34182
34346
|
const normalizedName = name.toLowerCase();
|
|
34183
34347
|
if (existsSync31(filePath) && !seen.has(filePath)) {
|
|
34184
34348
|
seen.add(filePath);
|
|
@@ -34197,7 +34361,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
34197
34361
|
}
|
|
34198
34362
|
}
|
|
34199
34363
|
}
|
|
34200
|
-
const projectMap =
|
|
34364
|
+
const projectMap = join47(dir, OA_DIR, "context", "project-map.md");
|
|
34201
34365
|
if (existsSync31(projectMap) && !seen.has(projectMap)) {
|
|
34202
34366
|
seen.add(projectMap);
|
|
34203
34367
|
try {
|
|
@@ -34213,7 +34377,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
34213
34377
|
} catch {
|
|
34214
34378
|
}
|
|
34215
34379
|
}
|
|
34216
|
-
const parent =
|
|
34380
|
+
const parent = join47(dir, "..");
|
|
34217
34381
|
if (parent === dir)
|
|
34218
34382
|
break;
|
|
34219
34383
|
dir = parent;
|
|
@@ -34231,7 +34395,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
34231
34395
|
return found;
|
|
34232
34396
|
}
|
|
34233
34397
|
function readIndexMeta(repoRoot) {
|
|
34234
|
-
const metaPath =
|
|
34398
|
+
const metaPath = join47(repoRoot, OA_DIR, "index", "meta.json");
|
|
34235
34399
|
try {
|
|
34236
34400
|
return JSON.parse(readFileSync22(metaPath, "utf-8"));
|
|
34237
34401
|
} catch {
|
|
@@ -34284,28 +34448,28 @@ ${tree}\`\`\`
|
|
|
34284
34448
|
sections.push("");
|
|
34285
34449
|
}
|
|
34286
34450
|
const content = sections.join("\n");
|
|
34287
|
-
const contextDir =
|
|
34451
|
+
const contextDir = join47(repoRoot, OA_DIR, "context");
|
|
34288
34452
|
mkdirSync11(contextDir, { recursive: true });
|
|
34289
|
-
writeFileSync12(
|
|
34453
|
+
writeFileSync12(join47(contextDir, "project-map.md"), content, "utf-8");
|
|
34290
34454
|
return content;
|
|
34291
34455
|
}
|
|
34292
34456
|
function saveSession(repoRoot, session) {
|
|
34293
|
-
const historyDir =
|
|
34457
|
+
const historyDir = join47(repoRoot, OA_DIR, "history");
|
|
34294
34458
|
mkdirSync11(historyDir, { recursive: true });
|
|
34295
|
-
writeFileSync12(
|
|
34459
|
+
writeFileSync12(join47(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
|
|
34296
34460
|
}
|
|
34297
34461
|
function loadRecentSessions(repoRoot, limit = 5) {
|
|
34298
|
-
const historyDir =
|
|
34462
|
+
const historyDir = join47(repoRoot, OA_DIR, "history");
|
|
34299
34463
|
if (!existsSync31(historyDir))
|
|
34300
34464
|
return [];
|
|
34301
34465
|
try {
|
|
34302
34466
|
const files = readdirSync8(historyDir).filter((f) => f.endsWith(".json") && f !== "pending-task.json").map((f) => {
|
|
34303
|
-
const stat5 = statSync11(
|
|
34467
|
+
const stat5 = statSync11(join47(historyDir, f));
|
|
34304
34468
|
return { file: f, mtime: stat5.mtimeMs };
|
|
34305
34469
|
}).sort((a, b) => b.mtime - a.mtime).slice(0, limit);
|
|
34306
34470
|
return files.map((f) => {
|
|
34307
34471
|
try {
|
|
34308
|
-
return JSON.parse(readFileSync22(
|
|
34472
|
+
return JSON.parse(readFileSync22(join47(historyDir, f.file), "utf-8"));
|
|
34309
34473
|
} catch {
|
|
34310
34474
|
return null;
|
|
34311
34475
|
}
|
|
@@ -34315,12 +34479,12 @@ function loadRecentSessions(repoRoot, limit = 5) {
|
|
|
34315
34479
|
}
|
|
34316
34480
|
}
|
|
34317
34481
|
function savePendingTask(repoRoot, task) {
|
|
34318
|
-
const historyDir =
|
|
34482
|
+
const historyDir = join47(repoRoot, OA_DIR, "history");
|
|
34319
34483
|
mkdirSync11(historyDir, { recursive: true });
|
|
34320
|
-
writeFileSync12(
|
|
34484
|
+
writeFileSync12(join47(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
|
|
34321
34485
|
}
|
|
34322
34486
|
function loadPendingTask(repoRoot) {
|
|
34323
|
-
const filePath =
|
|
34487
|
+
const filePath = join47(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
|
|
34324
34488
|
try {
|
|
34325
34489
|
if (!existsSync31(filePath))
|
|
34326
34490
|
return null;
|
|
@@ -34335,9 +34499,9 @@ function loadPendingTask(repoRoot) {
|
|
|
34335
34499
|
}
|
|
34336
34500
|
}
|
|
34337
34501
|
function saveSessionContext(repoRoot, entry) {
|
|
34338
|
-
const contextDir =
|
|
34502
|
+
const contextDir = join47(repoRoot, OA_DIR, "context");
|
|
34339
34503
|
mkdirSync11(contextDir, { recursive: true });
|
|
34340
|
-
const filePath =
|
|
34504
|
+
const filePath = join47(contextDir, CONTEXT_SAVE_FILE);
|
|
34341
34505
|
let ctx;
|
|
34342
34506
|
try {
|
|
34343
34507
|
if (existsSync31(filePath)) {
|
|
@@ -34356,7 +34520,7 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
34356
34520
|
writeFileSync12(filePath, JSON.stringify(ctx, null, 2) + "\n", "utf-8");
|
|
34357
34521
|
}
|
|
34358
34522
|
function loadSessionContext(repoRoot) {
|
|
34359
|
-
const filePath =
|
|
34523
|
+
const filePath = join47(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
|
|
34360
34524
|
try {
|
|
34361
34525
|
if (!existsSync31(filePath))
|
|
34362
34526
|
return null;
|
|
@@ -34407,7 +34571,7 @@ function detectManifests(repoRoot) {
|
|
|
34407
34571
|
{ file: "docker-compose.yaml", type: "Docker Compose" }
|
|
34408
34572
|
];
|
|
34409
34573
|
for (const check of checks) {
|
|
34410
|
-
const filePath =
|
|
34574
|
+
const filePath = join47(repoRoot, check.file);
|
|
34411
34575
|
if (existsSync31(filePath)) {
|
|
34412
34576
|
let name;
|
|
34413
34577
|
if (check.nameField) {
|
|
@@ -34441,7 +34605,7 @@ function findKeyFiles(repoRoot) {
|
|
|
34441
34605
|
{ pattern: "CLAUDE.md", description: "Claude Code context" }
|
|
34442
34606
|
];
|
|
34443
34607
|
for (const check of checks) {
|
|
34444
|
-
if (existsSync31(
|
|
34608
|
+
if (existsSync31(join47(repoRoot, check.pattern))) {
|
|
34445
34609
|
keyFiles.push({ path: check.pattern, description: check.description });
|
|
34446
34610
|
}
|
|
34447
34611
|
}
|
|
@@ -34467,12 +34631,12 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
34467
34631
|
if (entry.isDirectory()) {
|
|
34468
34632
|
let fileCount = 0;
|
|
34469
34633
|
try {
|
|
34470
|
-
fileCount = readdirSync8(
|
|
34634
|
+
fileCount = readdirSync8(join47(root, entry.name)).filter((f) => !f.startsWith(".")).length;
|
|
34471
34635
|
} catch {
|
|
34472
34636
|
}
|
|
34473
34637
|
result += `${prefix}${connector}${entry.name}/ (${fileCount})
|
|
34474
34638
|
`;
|
|
34475
|
-
result += buildDirTree(
|
|
34639
|
+
result += buildDirTree(join47(root, entry.name), maxDepth, childPrefix, depth + 1);
|
|
34476
34640
|
} else if (depth < maxDepth) {
|
|
34477
34641
|
result += `${prefix}${connector}${entry.name}
|
|
34478
34642
|
`;
|
|
@@ -34492,7 +34656,7 @@ function loadUsageFile(filePath) {
|
|
|
34492
34656
|
return { records: [] };
|
|
34493
34657
|
}
|
|
34494
34658
|
function saveUsageFile(filePath, data) {
|
|
34495
|
-
const dir =
|
|
34659
|
+
const dir = join47(filePath, "..");
|
|
34496
34660
|
mkdirSync11(dir, { recursive: true });
|
|
34497
34661
|
writeFileSync12(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
34498
34662
|
}
|
|
@@ -34522,15 +34686,15 @@ function recordUsage(kind, value, opts) {
|
|
|
34522
34686
|
}
|
|
34523
34687
|
saveUsageFile(filePath, data);
|
|
34524
34688
|
};
|
|
34525
|
-
update(
|
|
34689
|
+
update(join47(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
|
|
34526
34690
|
if (opts?.repoRoot) {
|
|
34527
|
-
update(
|
|
34691
|
+
update(join47(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
34528
34692
|
}
|
|
34529
34693
|
}
|
|
34530
34694
|
function loadUsageHistory(kind, repoRoot) {
|
|
34531
|
-
const globalPath =
|
|
34695
|
+
const globalPath = join47(homedir9(), ".open-agents", USAGE_HISTORY_FILE);
|
|
34532
34696
|
const globalData = loadUsageFile(globalPath);
|
|
34533
|
-
const localData = repoRoot ? loadUsageFile(
|
|
34697
|
+
const localData = repoRoot ? loadUsageFile(join47(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
|
|
34534
34698
|
const map = /* @__PURE__ */ new Map();
|
|
34535
34699
|
for (const r of globalData.records) {
|
|
34536
34700
|
if (r.kind !== kind)
|
|
@@ -34561,9 +34725,9 @@ function deleteUsageRecord(kind, value, repoRoot) {
|
|
|
34561
34725
|
saveUsageFile(filePath, data);
|
|
34562
34726
|
}
|
|
34563
34727
|
};
|
|
34564
|
-
remove(
|
|
34728
|
+
remove(join47(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
|
|
34565
34729
|
if (repoRoot) {
|
|
34566
|
-
remove(
|
|
34730
|
+
remove(join47(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
34567
34731
|
}
|
|
34568
34732
|
}
|
|
34569
34733
|
var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
@@ -34614,7 +34778,7 @@ import * as readline from "node:readline";
|
|
|
34614
34778
|
import { execSync as execSync24, spawn as spawn18, exec as exec2 } from "node:child_process";
|
|
34615
34779
|
import { promisify as promisify5 } from "node:util";
|
|
34616
34780
|
import { existsSync as existsSync32, writeFileSync as writeFileSync13, readFileSync as readFileSync23, appendFileSync as appendFileSync2, mkdirSync as mkdirSync12 } from "node:fs";
|
|
34617
|
-
import { join as
|
|
34781
|
+
import { join as join48 } from "node:path";
|
|
34618
34782
|
import { homedir as homedir10, platform } from "node:os";
|
|
34619
34783
|
function detectSystemSpecs() {
|
|
34620
34784
|
let totalRamGB = 0;
|
|
@@ -35655,9 +35819,9 @@ async function doSetup(config, rl) {
|
|
|
35655
35819
|
`PARAMETER num_predict ${numPredict}`,
|
|
35656
35820
|
`PARAMETER stop "<|endoftext|>"`
|
|
35657
35821
|
].join("\n");
|
|
35658
|
-
const modelDir2 =
|
|
35822
|
+
const modelDir2 = join48(homedir10(), ".open-agents", "models");
|
|
35659
35823
|
mkdirSync12(modelDir2, { recursive: true });
|
|
35660
|
-
const modelfilePath =
|
|
35824
|
+
const modelfilePath = join48(modelDir2, `Modelfile.${customName}`);
|
|
35661
35825
|
writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
|
|
35662
35826
|
process.stdout.write(` ${c2.dim("Creating model...")} `);
|
|
35663
35827
|
execSync24(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
@@ -35703,7 +35867,7 @@ async function isModelAvailable(config) {
|
|
|
35703
35867
|
}
|
|
35704
35868
|
function isFirstRun() {
|
|
35705
35869
|
try {
|
|
35706
|
-
return !existsSync32(
|
|
35870
|
+
return !existsSync32(join48(homedir10(), ".open-agents", "config.json"));
|
|
35707
35871
|
} catch {
|
|
35708
35872
|
return true;
|
|
35709
35873
|
}
|
|
@@ -35740,7 +35904,7 @@ function detectPkgManager() {
|
|
|
35740
35904
|
return null;
|
|
35741
35905
|
}
|
|
35742
35906
|
function getVenvDir() {
|
|
35743
|
-
return
|
|
35907
|
+
return join48(homedir10(), ".open-agents", "venv");
|
|
35744
35908
|
}
|
|
35745
35909
|
function hasVenvModule() {
|
|
35746
35910
|
try {
|
|
@@ -35752,7 +35916,7 @@ function hasVenvModule() {
|
|
|
35752
35916
|
}
|
|
35753
35917
|
function ensureVenv(log) {
|
|
35754
35918
|
const venvDir = getVenvDir();
|
|
35755
|
-
const venvPip =
|
|
35919
|
+
const venvPip = join48(venvDir, "bin", "pip");
|
|
35756
35920
|
if (existsSync32(venvPip))
|
|
35757
35921
|
return venvDir;
|
|
35758
35922
|
log("Creating Python venv for vision deps...");
|
|
@@ -35765,9 +35929,9 @@ function ensureVenv(log) {
|
|
|
35765
35929
|
return null;
|
|
35766
35930
|
}
|
|
35767
35931
|
try {
|
|
35768
|
-
mkdirSync12(
|
|
35932
|
+
mkdirSync12(join48(homedir10(), ".open-agents"), { recursive: true });
|
|
35769
35933
|
execSync24(`python3 -m venv "${venvDir}"`, { stdio: "pipe", timeout: 3e4 });
|
|
35770
|
-
execSync24(`"${
|
|
35934
|
+
execSync24(`"${join48(venvDir, "bin", "pip")}" install --upgrade pip`, {
|
|
35771
35935
|
stdio: "pipe",
|
|
35772
35936
|
timeout: 6e4
|
|
35773
35937
|
});
|
|
@@ -35958,11 +36122,11 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
35958
36122
|
}
|
|
35959
36123
|
}
|
|
35960
36124
|
const venvDir = getVenvDir();
|
|
35961
|
-
const venvBin =
|
|
35962
|
-
const venvMoondream =
|
|
36125
|
+
const venvBin = join48(venvDir, "bin");
|
|
36126
|
+
const venvMoondream = join48(venvBin, "moondream-station");
|
|
35963
36127
|
const venv = ensureVenv(log);
|
|
35964
36128
|
if (venv && !hasCmd("moondream-station") && !existsSync32(venvMoondream)) {
|
|
35965
|
-
const venvPip =
|
|
36129
|
+
const venvPip = join48(venvBin, "pip");
|
|
35966
36130
|
log("Installing moondream-station in ~/.open-agents/venv...");
|
|
35967
36131
|
try {
|
|
35968
36132
|
execSync24(`"${venvPip}" install moondream-station`, { stdio: "pipe", timeout: 3e5 });
|
|
@@ -35983,8 +36147,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
35983
36147
|
}
|
|
35984
36148
|
}
|
|
35985
36149
|
if (venv) {
|
|
35986
|
-
const venvPython =
|
|
35987
|
-
const venvPip2 =
|
|
36150
|
+
const venvPython = join48(venvBin, "python");
|
|
36151
|
+
const venvPip2 = join48(venvBin, "pip");
|
|
35988
36152
|
let ocrStackInstalled = false;
|
|
35989
36153
|
try {
|
|
35990
36154
|
execSync24(`"${venvPython}" -c "import cv2, pytesseract, numpy, PIL"`, { stdio: "pipe", timeout: 1e4 });
|
|
@@ -36128,9 +36292,9 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
|
|
|
36128
36292
|
`PARAMETER num_predict ${numPredict}`,
|
|
36129
36293
|
`PARAMETER stop "<|endoftext|>"`
|
|
36130
36294
|
].join("\n");
|
|
36131
|
-
const modelDir2 =
|
|
36295
|
+
const modelDir2 = join48(homedir10(), ".open-agents", "models");
|
|
36132
36296
|
mkdirSync12(modelDir2, { recursive: true });
|
|
36133
|
-
const modelfilePath =
|
|
36297
|
+
const modelfilePath = join48(modelDir2, `Modelfile.${customName}`);
|
|
36134
36298
|
writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
|
|
36135
36299
|
await execAsync(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
36136
36300
|
timeout: 12e4
|
|
@@ -36205,8 +36369,8 @@ async function ensureNeovim() {
|
|
|
36205
36369
|
const platform5 = process.platform;
|
|
36206
36370
|
const arch = process.arch;
|
|
36207
36371
|
if (platform5 === "linux") {
|
|
36208
|
-
const binDir =
|
|
36209
|
-
const nvimDest =
|
|
36372
|
+
const binDir = join48(homedir10(), ".local", "bin");
|
|
36373
|
+
const nvimDest = join48(binDir, "nvim");
|
|
36210
36374
|
try {
|
|
36211
36375
|
mkdirSync12(binDir, { recursive: true });
|
|
36212
36376
|
} catch {
|
|
@@ -36277,7 +36441,7 @@ async function ensureNeovim() {
|
|
|
36277
36441
|
}
|
|
36278
36442
|
function ensurePathInShellRc(binDir) {
|
|
36279
36443
|
const shell = process.env.SHELL ?? "";
|
|
36280
|
-
const rcFile = shell.includes("zsh") ?
|
|
36444
|
+
const rcFile = shell.includes("zsh") ? join48(homedir10(), ".zshrc") : join48(homedir10(), ".bashrc");
|
|
36281
36445
|
try {
|
|
36282
36446
|
const rcContent = existsSync32(rcFile) ? readFileSync23(rcFile, "utf8") : "";
|
|
36283
36447
|
if (rcContent.includes(binDir))
|
|
@@ -37049,7 +37213,7 @@ var init_drop_panel = __esm({
|
|
|
37049
37213
|
// packages/cli/dist/tui/neovim-mode.js
|
|
37050
37214
|
import { existsSync as existsSync34, unlinkSync as unlinkSync7 } from "node:fs";
|
|
37051
37215
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
37052
|
-
import { join as
|
|
37216
|
+
import { join as join49 } from "node:path";
|
|
37053
37217
|
import { execSync as execSync25 } from "node:child_process";
|
|
37054
37218
|
function isNeovimActive() {
|
|
37055
37219
|
return _state !== null && !_state.cleanedUp;
|
|
@@ -37097,7 +37261,7 @@ async function startNeovimMode(opts) {
|
|
|
37097
37261
|
);
|
|
37098
37262
|
} catch {
|
|
37099
37263
|
}
|
|
37100
|
-
const socketPath =
|
|
37264
|
+
const socketPath = join49(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
|
|
37101
37265
|
try {
|
|
37102
37266
|
if (existsSync34(socketPath))
|
|
37103
37267
|
unlinkSync7(socketPath);
|
|
@@ -37449,7 +37613,7 @@ __export(voice_exports, {
|
|
|
37449
37613
|
resetNarrationContext: () => resetNarrationContext
|
|
37450
37614
|
});
|
|
37451
37615
|
import { existsSync as existsSync35, mkdirSync as mkdirSync13, writeFileSync as writeFileSync14, readFileSync as readFileSync24, unlinkSync as unlinkSync8, readdirSync as readdirSync9, renameSync, statSync as statSync12 } from "node:fs";
|
|
37452
|
-
import { join as
|
|
37616
|
+
import { join as join50 } from "node:path";
|
|
37453
37617
|
import { homedir as homedir11, tmpdir as tmpdir9, platform as platform2 } from "node:os";
|
|
37454
37618
|
import { execSync as execSync26, spawn as nodeSpawn } from "node:child_process";
|
|
37455
37619
|
import { createRequire } from "node:module";
|
|
@@ -37471,34 +37635,34 @@ function listVoiceModels() {
|
|
|
37471
37635
|
}));
|
|
37472
37636
|
}
|
|
37473
37637
|
function voiceDir() {
|
|
37474
|
-
return
|
|
37638
|
+
return join50(homedir11(), ".open-agents", "voice");
|
|
37475
37639
|
}
|
|
37476
37640
|
function modelsDir() {
|
|
37477
|
-
return
|
|
37641
|
+
return join50(voiceDir(), "models");
|
|
37478
37642
|
}
|
|
37479
37643
|
function modelDir(id) {
|
|
37480
|
-
return
|
|
37644
|
+
return join50(modelsDir(), id);
|
|
37481
37645
|
}
|
|
37482
37646
|
function modelOnnxPath(id) {
|
|
37483
|
-
return
|
|
37647
|
+
return join50(modelDir(id), "model.onnx");
|
|
37484
37648
|
}
|
|
37485
37649
|
function modelConfigPath(id) {
|
|
37486
|
-
return
|
|
37650
|
+
return join50(modelDir(id), "config.json");
|
|
37487
37651
|
}
|
|
37488
37652
|
function luxttsVenvDir() {
|
|
37489
|
-
return
|
|
37653
|
+
return join50(voiceDir(), "luxtts-venv");
|
|
37490
37654
|
}
|
|
37491
37655
|
function luxttsVenvPy() {
|
|
37492
|
-
return platform2() === "win32" ?
|
|
37656
|
+
return platform2() === "win32" ? join50(luxttsVenvDir(), "Scripts", "python.exe") : join50(luxttsVenvDir(), "bin", "python3");
|
|
37493
37657
|
}
|
|
37494
37658
|
function luxttsRepoDir() {
|
|
37495
|
-
return
|
|
37659
|
+
return join50(voiceDir(), "LuxTTS");
|
|
37496
37660
|
}
|
|
37497
37661
|
function luxttsCloneRefsDir() {
|
|
37498
|
-
return
|
|
37662
|
+
return join50(voiceDir(), "clone-refs");
|
|
37499
37663
|
}
|
|
37500
37664
|
function luxttsInferScript() {
|
|
37501
|
-
return
|
|
37665
|
+
return join50(voiceDir(), "luxtts-infer.py");
|
|
37502
37666
|
}
|
|
37503
37667
|
function emotionToPitchBias(emotion, stark = false, autist = false) {
|
|
37504
37668
|
if (autist)
|
|
@@ -38306,7 +38470,7 @@ var init_voice = __esm({
|
|
|
38306
38470
|
const refsDir = luxttsCloneRefsDir();
|
|
38307
38471
|
const targets = ["glados", "overwatch"];
|
|
38308
38472
|
for (const modelId of targets) {
|
|
38309
|
-
const refFile =
|
|
38473
|
+
const refFile = join50(refsDir, `${modelId}-ref.wav`);
|
|
38310
38474
|
if (existsSync35(refFile))
|
|
38311
38475
|
continue;
|
|
38312
38476
|
try {
|
|
@@ -38386,7 +38550,7 @@ var init_voice = __esm({
|
|
|
38386
38550
|
}
|
|
38387
38551
|
p = p.replace(/\\ /g, " ");
|
|
38388
38552
|
if (p.startsWith("~/") || p === "~") {
|
|
38389
|
-
p =
|
|
38553
|
+
p = join50(homedir11(), p.slice(1));
|
|
38390
38554
|
}
|
|
38391
38555
|
if (!existsSync35(p)) {
|
|
38392
38556
|
return `File not found: ${p}
|
|
@@ -38400,7 +38564,7 @@ var init_voice = __esm({
|
|
|
38400
38564
|
const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
38401
38565
|
const ts = Date.now().toString(36);
|
|
38402
38566
|
const destFilename = `clone-${srcName}-${ts}.${ext}`;
|
|
38403
|
-
const destPath =
|
|
38567
|
+
const destPath = join50(refsDir, destFilename);
|
|
38404
38568
|
try {
|
|
38405
38569
|
const data = readFileSync24(audioPath);
|
|
38406
38570
|
writeFileSync14(destPath, data);
|
|
@@ -38445,7 +38609,7 @@ var init_voice = __esm({
|
|
|
38445
38609
|
const refsDir = luxttsCloneRefsDir();
|
|
38446
38610
|
if (!existsSync35(refsDir))
|
|
38447
38611
|
mkdirSync13(refsDir, { recursive: true });
|
|
38448
|
-
const destPath =
|
|
38612
|
+
const destPath = join50(refsDir, `${sourceModelId}-ref.wav`);
|
|
38449
38613
|
const sampleRate = this.config?.audio?.sample_rate ?? 22050;
|
|
38450
38614
|
this.writeWav(audioData, sampleRate, destPath);
|
|
38451
38615
|
this.luxttsCloneRef = destPath;
|
|
@@ -38461,7 +38625,7 @@ var init_voice = __esm({
|
|
|
38461
38625
|
// -------------------------------------------------------------------------
|
|
38462
38626
|
/** Metadata file for friendly names of clone refs */
|
|
38463
38627
|
static cloneMetaFile() {
|
|
38464
|
-
return
|
|
38628
|
+
return join50(luxttsCloneRefsDir(), "meta.json");
|
|
38465
38629
|
}
|
|
38466
38630
|
loadCloneMeta() {
|
|
38467
38631
|
const p = _VoiceEngine.cloneMetaFile();
|
|
@@ -38495,7 +38659,7 @@ var init_voice = __esm({
|
|
|
38495
38659
|
return _VoiceEngine.AUDIO_EXTS.has(ext);
|
|
38496
38660
|
});
|
|
38497
38661
|
return files.map((f) => {
|
|
38498
|
-
const p =
|
|
38662
|
+
const p = join50(dir, f);
|
|
38499
38663
|
let size = 0;
|
|
38500
38664
|
try {
|
|
38501
38665
|
size = statSync12(p).size;
|
|
@@ -38512,7 +38676,7 @@ var init_voice = __esm({
|
|
|
38512
38676
|
}
|
|
38513
38677
|
/** Delete a clone reference file by filename. Returns true if deleted. */
|
|
38514
38678
|
deleteCloneRef(filename) {
|
|
38515
|
-
const p =
|
|
38679
|
+
const p = join50(luxttsCloneRefsDir(), filename);
|
|
38516
38680
|
if (!existsSync35(p))
|
|
38517
38681
|
return false;
|
|
38518
38682
|
try {
|
|
@@ -38537,7 +38701,7 @@ var init_voice = __esm({
|
|
|
38537
38701
|
}
|
|
38538
38702
|
/** Set the active clone reference by filename. */
|
|
38539
38703
|
setActiveCloneRef(filename) {
|
|
38540
|
-
const p =
|
|
38704
|
+
const p = join50(luxttsCloneRefsDir(), filename);
|
|
38541
38705
|
if (!existsSync35(p))
|
|
38542
38706
|
return `File not found: ${filename}`;
|
|
38543
38707
|
this.luxttsCloneRef = p;
|
|
@@ -38823,7 +38987,7 @@ var init_voice = __esm({
|
|
|
38823
38987
|
}
|
|
38824
38988
|
this.onPCMOutput(Buffer.from(int16.buffer), sampleRate);
|
|
38825
38989
|
}
|
|
38826
|
-
const wavPath =
|
|
38990
|
+
const wavPath = join50(tmpdir9(), `oa-voice-${Date.now()}.wav`);
|
|
38827
38991
|
this.writeWav(audioData, sampleRate, wavPath);
|
|
38828
38992
|
await this.playWav(wavPath);
|
|
38829
38993
|
try {
|
|
@@ -39166,7 +39330,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
39166
39330
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
39167
39331
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
39168
39332
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
39169
|
-
const wavPath =
|
|
39333
|
+
const wavPath = join50(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
|
|
39170
39334
|
const pyScript = [
|
|
39171
39335
|
"import sys, json",
|
|
39172
39336
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -39234,7 +39398,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
39234
39398
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
39235
39399
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
39236
39400
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
39237
|
-
const wavPath =
|
|
39401
|
+
const wavPath = join50(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
|
|
39238
39402
|
const pyScript = [
|
|
39239
39403
|
"import sys, json",
|
|
39240
39404
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -39345,7 +39509,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
39345
39509
|
}
|
|
39346
39510
|
}
|
|
39347
39511
|
const repoDir = luxttsRepoDir();
|
|
39348
|
-
if (!existsSync35(
|
|
39512
|
+
if (!existsSync35(join50(repoDir, "zipvoice", "luxvoice.py"))) {
|
|
39349
39513
|
renderInfo(" Cloning LuxTTS repository...");
|
|
39350
39514
|
try {
|
|
39351
39515
|
if (existsSync35(repoDir)) {
|
|
@@ -39394,7 +39558,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
39394
39558
|
if (!existsSync35(refsDir))
|
|
39395
39559
|
return;
|
|
39396
39560
|
for (const name of ["custom-clone.wav", "custom-clone.mp3", "glados-ref.wav", "overwatch-ref.wav"]) {
|
|
39397
|
-
const p =
|
|
39561
|
+
const p = join50(refsDir, name);
|
|
39398
39562
|
if (existsSync35(p)) {
|
|
39399
39563
|
this.luxttsCloneRef = p;
|
|
39400
39564
|
return;
|
|
@@ -39591,7 +39755,7 @@ if __name__ == '__main__':
|
|
|
39591
39755
|
const ready = await this.ensureLuxttsDaemon();
|
|
39592
39756
|
if (!ready)
|
|
39593
39757
|
return;
|
|
39594
|
-
const wavPath =
|
|
39758
|
+
const wavPath = join50(tmpdir9(), `oa-luxtts-${Date.now()}.wav`);
|
|
39595
39759
|
try {
|
|
39596
39760
|
await this.luxttsRequest({
|
|
39597
39761
|
action: "synthesize",
|
|
@@ -39665,7 +39829,7 @@ if __name__ == '__main__':
|
|
|
39665
39829
|
const ready = await this.ensureLuxttsDaemon();
|
|
39666
39830
|
if (!ready)
|
|
39667
39831
|
return null;
|
|
39668
|
-
const wavPath =
|
|
39832
|
+
const wavPath = join50(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
|
|
39669
39833
|
try {
|
|
39670
39834
|
await this.luxttsRequest({
|
|
39671
39835
|
action: "synthesize",
|
|
@@ -39695,7 +39859,7 @@ if __name__ == '__main__':
|
|
|
39695
39859
|
return;
|
|
39696
39860
|
const arch = process.arch;
|
|
39697
39861
|
mkdirSync13(voiceDir(), { recursive: true });
|
|
39698
|
-
const pkgPath =
|
|
39862
|
+
const pkgPath = join50(voiceDir(), "package.json");
|
|
39699
39863
|
const expectedDeps = {
|
|
39700
39864
|
"onnxruntime-node": "^1.21.0",
|
|
39701
39865
|
"phonemizer": "^1.2.1"
|
|
@@ -39717,17 +39881,17 @@ if __name__ == '__main__':
|
|
|
39717
39881
|
dependencies: expectedDeps
|
|
39718
39882
|
}, null, 2));
|
|
39719
39883
|
}
|
|
39720
|
-
const voiceRequire = createRequire(
|
|
39884
|
+
const voiceRequire = createRequire(join50(voiceDir(), "index.js"));
|
|
39721
39885
|
const probeOnnx = () => {
|
|
39722
39886
|
try {
|
|
39723
|
-
const result = execSync26(`node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, { cwd: voiceDir(), stdio: "pipe", timeout: 15e3, env: { ...process.env, NODE_PATH:
|
|
39887
|
+
const result = execSync26(`node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, { cwd: voiceDir(), stdio: "pipe", timeout: 15e3, env: { ...process.env, NODE_PATH: join50(voiceDir(), "node_modules") } });
|
|
39724
39888
|
const output = result.toString().trim();
|
|
39725
39889
|
return output === "OK";
|
|
39726
39890
|
} catch {
|
|
39727
39891
|
return false;
|
|
39728
39892
|
}
|
|
39729
39893
|
};
|
|
39730
|
-
const onnxNodeModules =
|
|
39894
|
+
const onnxNodeModules = join50(voiceDir(), "node_modules", "onnxruntime-node");
|
|
39731
39895
|
const onnxInstalled = existsSync35(onnxNodeModules);
|
|
39732
39896
|
if (onnxInstalled && !probeOnnx()) {
|
|
39733
39897
|
throw new Error(`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${arch}). 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.`);
|
|
@@ -42131,8 +42295,8 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
|
|
|
42131
42295
|
if (models.length > 0) {
|
|
42132
42296
|
try {
|
|
42133
42297
|
const { writeFileSync: writeFileSync20, mkdirSync: mkdirSync21 } = await import("node:fs");
|
|
42134
|
-
const { join:
|
|
42135
|
-
const cachePath =
|
|
42298
|
+
const { join: join64, dirname: dirname20 } = await import("node:path");
|
|
42299
|
+
const cachePath = join64(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
|
|
42136
42300
|
mkdirSync21(dirname20(cachePath), { recursive: true });
|
|
42137
42301
|
writeFileSync20(cachePath, JSON.stringify({
|
|
42138
42302
|
peerId,
|
|
@@ -42333,14 +42497,14 @@ async function handleUpdate(subcommand, ctx) {
|
|
|
42333
42497
|
try {
|
|
42334
42498
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
42335
42499
|
const { fileURLToPath: fileURLToPath14 } = await import("node:url");
|
|
42336
|
-
const { dirname: dirname20, join:
|
|
42500
|
+
const { dirname: dirname20, join: join64 } = await import("node:path");
|
|
42337
42501
|
const { existsSync: existsSync45 } = await import("node:fs");
|
|
42338
42502
|
const req = createRequire4(import.meta.url);
|
|
42339
42503
|
const thisDir = dirname20(fileURLToPath14(import.meta.url));
|
|
42340
42504
|
const candidates = [
|
|
42341
|
-
|
|
42342
|
-
|
|
42343
|
-
|
|
42505
|
+
join64(thisDir, "..", "package.json"),
|
|
42506
|
+
join64(thisDir, "..", "..", "package.json"),
|
|
42507
|
+
join64(thisDir, "..", "..", "..", "package.json")
|
|
42344
42508
|
];
|
|
42345
42509
|
for (const pkgPath of candidates) {
|
|
42346
42510
|
if (existsSync45(pkgPath)) {
|
|
@@ -43099,7 +43263,7 @@ var init_commands = __esm({
|
|
|
43099
43263
|
|
|
43100
43264
|
// packages/cli/dist/tui/project-context.js
|
|
43101
43265
|
import { existsSync as existsSync36, readFileSync as readFileSync25, readdirSync as readdirSync10 } from "node:fs";
|
|
43102
|
-
import { join as
|
|
43266
|
+
import { join as join51, basename as basename10 } from "node:path";
|
|
43103
43267
|
import { execSync as execSync27 } from "node:child_process";
|
|
43104
43268
|
import { homedir as homedir12, platform as platform3, release } from "node:os";
|
|
43105
43269
|
function getModelTier(modelName) {
|
|
@@ -43134,7 +43298,7 @@ function loadProjectMap(repoRoot) {
|
|
|
43134
43298
|
if (!hasOaDirectory(repoRoot)) {
|
|
43135
43299
|
initOaDirectory(repoRoot);
|
|
43136
43300
|
}
|
|
43137
|
-
const mapPath =
|
|
43301
|
+
const mapPath = join51(repoRoot, OA_DIR, "context", "project-map.md");
|
|
43138
43302
|
if (existsSync36(mapPath)) {
|
|
43139
43303
|
try {
|
|
43140
43304
|
const content = readFileSync25(mapPath, "utf-8");
|
|
@@ -43178,17 +43342,17 @@ ${log}`);
|
|
|
43178
43342
|
}
|
|
43179
43343
|
function loadMemoryContext(repoRoot) {
|
|
43180
43344
|
const sections = [];
|
|
43181
|
-
const oaMemDir =
|
|
43345
|
+
const oaMemDir = join51(repoRoot, OA_DIR, "memory");
|
|
43182
43346
|
const oaEntries = loadMemoryDir(oaMemDir, "project");
|
|
43183
43347
|
if (oaEntries)
|
|
43184
43348
|
sections.push(oaEntries);
|
|
43185
|
-
const legacyMemDir =
|
|
43349
|
+
const legacyMemDir = join51(repoRoot, ".open-agents", "memory");
|
|
43186
43350
|
if (legacyMemDir !== oaMemDir && existsSync36(legacyMemDir)) {
|
|
43187
43351
|
const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
|
|
43188
43352
|
if (legacyEntries)
|
|
43189
43353
|
sections.push(legacyEntries);
|
|
43190
43354
|
}
|
|
43191
|
-
const globalMemDir =
|
|
43355
|
+
const globalMemDir = join51(homedir12(), ".open-agents", "memory");
|
|
43192
43356
|
const globalEntries = loadMemoryDir(globalMemDir, "global");
|
|
43193
43357
|
if (globalEntries)
|
|
43194
43358
|
sections.push(globalEntries);
|
|
@@ -43202,7 +43366,7 @@ function loadMemoryDir(memDir, scope) {
|
|
|
43202
43366
|
const files = readdirSync10(memDir).filter((f) => f.endsWith(".json"));
|
|
43203
43367
|
for (const file of files.slice(0, 10)) {
|
|
43204
43368
|
try {
|
|
43205
|
-
const raw = readFileSync25(
|
|
43369
|
+
const raw = readFileSync25(join51(memDir, file), "utf-8");
|
|
43206
43370
|
const entries = JSON.parse(raw);
|
|
43207
43371
|
const topic = basename10(file, ".json");
|
|
43208
43372
|
const keys = Object.keys(entries);
|
|
@@ -44421,9 +44585,9 @@ var init_banner = __esm({
|
|
|
44421
44585
|
|
|
44422
44586
|
// packages/cli/dist/tui/carousel-descriptors.js
|
|
44423
44587
|
import { existsSync as existsSync37, readFileSync as readFileSync26, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, readdirSync as readdirSync11 } from "node:fs";
|
|
44424
|
-
import { join as
|
|
44588
|
+
import { join as join52, basename as basename11 } from "node:path";
|
|
44425
44589
|
function loadToolProfile(repoRoot) {
|
|
44426
|
-
const filePath =
|
|
44590
|
+
const filePath = join52(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
44427
44591
|
try {
|
|
44428
44592
|
if (!existsSync37(filePath))
|
|
44429
44593
|
return null;
|
|
@@ -44433,9 +44597,9 @@ function loadToolProfile(repoRoot) {
|
|
|
44433
44597
|
}
|
|
44434
44598
|
}
|
|
44435
44599
|
function saveToolProfile(repoRoot, profile) {
|
|
44436
|
-
const contextDir =
|
|
44600
|
+
const contextDir = join52(repoRoot, OA_DIR, "context");
|
|
44437
44601
|
mkdirSync14(contextDir, { recursive: true });
|
|
44438
|
-
writeFileSync15(
|
|
44602
|
+
writeFileSync15(join52(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
|
|
44439
44603
|
}
|
|
44440
44604
|
function categorizeToolCall(toolName) {
|
|
44441
44605
|
for (const cat of TOOL_CATEGORIES) {
|
|
@@ -44493,7 +44657,7 @@ function weightedColor(profile) {
|
|
|
44493
44657
|
return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
|
|
44494
44658
|
}
|
|
44495
44659
|
function loadCachedDescriptors(repoRoot) {
|
|
44496
|
-
const filePath =
|
|
44660
|
+
const filePath = join52(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
|
|
44497
44661
|
try {
|
|
44498
44662
|
if (!existsSync37(filePath))
|
|
44499
44663
|
return null;
|
|
@@ -44504,14 +44668,14 @@ function loadCachedDescriptors(repoRoot) {
|
|
|
44504
44668
|
}
|
|
44505
44669
|
}
|
|
44506
44670
|
function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
44507
|
-
const contextDir =
|
|
44671
|
+
const contextDir = join52(repoRoot, OA_DIR, "context");
|
|
44508
44672
|
mkdirSync14(contextDir, { recursive: true });
|
|
44509
44673
|
const cached = {
|
|
44510
44674
|
phrases,
|
|
44511
44675
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
44512
44676
|
sourceHash
|
|
44513
44677
|
};
|
|
44514
|
-
writeFileSync15(
|
|
44678
|
+
writeFileSync15(join52(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
44515
44679
|
}
|
|
44516
44680
|
function generateDescriptors(repoRoot) {
|
|
44517
44681
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -44559,7 +44723,7 @@ function generateDescriptors(repoRoot) {
|
|
|
44559
44723
|
return phrases;
|
|
44560
44724
|
}
|
|
44561
44725
|
function extractFromPackageJson(repoRoot, tags) {
|
|
44562
|
-
const pkgPath =
|
|
44726
|
+
const pkgPath = join52(repoRoot, "package.json");
|
|
44563
44727
|
try {
|
|
44564
44728
|
if (!existsSync37(pkgPath))
|
|
44565
44729
|
return;
|
|
@@ -44607,7 +44771,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
44607
44771
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
44608
44772
|
];
|
|
44609
44773
|
for (const check of manifestChecks) {
|
|
44610
|
-
if (existsSync37(
|
|
44774
|
+
if (existsSync37(join52(repoRoot, check.file))) {
|
|
44611
44775
|
tags.push(check.tag);
|
|
44612
44776
|
}
|
|
44613
44777
|
}
|
|
@@ -44629,7 +44793,7 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
44629
44793
|
}
|
|
44630
44794
|
}
|
|
44631
44795
|
function extractFromMemory(repoRoot, tags) {
|
|
44632
|
-
const memoryDir =
|
|
44796
|
+
const memoryDir = join52(repoRoot, OA_DIR, "memory");
|
|
44633
44797
|
try {
|
|
44634
44798
|
if (!existsSync37(memoryDir))
|
|
44635
44799
|
return;
|
|
@@ -44638,7 +44802,7 @@ function extractFromMemory(repoRoot, tags) {
|
|
|
44638
44802
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
44639
44803
|
tags.push(topic);
|
|
44640
44804
|
try {
|
|
44641
|
-
const data = JSON.parse(readFileSync26(
|
|
44805
|
+
const data = JSON.parse(readFileSync26(join52(memoryDir, file), "utf-8"));
|
|
44642
44806
|
if (data && typeof data === "object") {
|
|
44643
44807
|
const keys = Object.keys(data).slice(0, 3);
|
|
44644
44808
|
for (const key of keys) {
|
|
@@ -45261,10 +45425,10 @@ var init_stream_renderer = __esm({
|
|
|
45261
45425
|
|
|
45262
45426
|
// packages/cli/dist/tui/edit-history.js
|
|
45263
45427
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync15 } from "node:fs";
|
|
45264
|
-
import { join as
|
|
45428
|
+
import { join as join53 } from "node:path";
|
|
45265
45429
|
function createEditHistoryLogger(repoRoot, sessionId) {
|
|
45266
|
-
const historyDir =
|
|
45267
|
-
const logPath =
|
|
45430
|
+
const historyDir = join53(repoRoot, ".oa", "history");
|
|
45431
|
+
const logPath = join53(historyDir, "edits.jsonl");
|
|
45268
45432
|
try {
|
|
45269
45433
|
mkdirSync15(historyDir, { recursive: true });
|
|
45270
45434
|
} catch {
|
|
@@ -45376,12 +45540,12 @@ var init_edit_history = __esm({
|
|
|
45376
45540
|
|
|
45377
45541
|
// packages/cli/dist/tui/promptLoader.js
|
|
45378
45542
|
import { readFileSync as readFileSync27, existsSync as existsSync38 } from "node:fs";
|
|
45379
|
-
import { join as
|
|
45543
|
+
import { join as join54, dirname as dirname17 } from "node:path";
|
|
45380
45544
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
45381
45545
|
function loadPrompt3(promptPath, vars) {
|
|
45382
45546
|
let content = cache3.get(promptPath);
|
|
45383
45547
|
if (content === void 0) {
|
|
45384
|
-
const fullPath =
|
|
45548
|
+
const fullPath = join54(PROMPTS_DIR3, promptPath);
|
|
45385
45549
|
if (!existsSync38(fullPath)) {
|
|
45386
45550
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
45387
45551
|
}
|
|
@@ -45398,8 +45562,8 @@ var init_promptLoader3 = __esm({
|
|
|
45398
45562
|
"use strict";
|
|
45399
45563
|
__filename3 = fileURLToPath11(import.meta.url);
|
|
45400
45564
|
__dirname6 = dirname17(__filename3);
|
|
45401
|
-
devPath2 =
|
|
45402
|
-
publishedPath2 =
|
|
45565
|
+
devPath2 = join54(__dirname6, "..", "..", "prompts");
|
|
45566
|
+
publishedPath2 = join54(__dirname6, "..", "prompts");
|
|
45403
45567
|
PROMPTS_DIR3 = existsSync38(devPath2) ? devPath2 : publishedPath2;
|
|
45404
45568
|
cache3 = /* @__PURE__ */ new Map();
|
|
45405
45569
|
}
|
|
@@ -45407,10 +45571,10 @@ var init_promptLoader3 = __esm({
|
|
|
45407
45571
|
|
|
45408
45572
|
// packages/cli/dist/tui/dream-engine.js
|
|
45409
45573
|
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync16, readFileSync as readFileSync28, existsSync as existsSync39, cpSync, rmSync, readdirSync as readdirSync12 } from "node:fs";
|
|
45410
|
-
import { join as
|
|
45574
|
+
import { join as join55, basename as basename12 } from "node:path";
|
|
45411
45575
|
import { execSync as execSync28 } from "node:child_process";
|
|
45412
45576
|
function loadAutoresearchMemory(repoRoot) {
|
|
45413
|
-
const memoryPath =
|
|
45577
|
+
const memoryPath = join55(repoRoot, ".oa", "memory", "autoresearch.json");
|
|
45414
45578
|
if (!existsSync39(memoryPath))
|
|
45415
45579
|
return "";
|
|
45416
45580
|
try {
|
|
@@ -45604,12 +45768,12 @@ var init_dream_engine = __esm({
|
|
|
45604
45768
|
const content = String(args["content"] ?? "");
|
|
45605
45769
|
if (!rawPath)
|
|
45606
45770
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
45607
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
45771
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join55(this.autoresearchDir, basename12(rawPath)) : join55(this.autoresearchDir, rawPath);
|
|
45608
45772
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
45609
45773
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
45610
45774
|
}
|
|
45611
45775
|
try {
|
|
45612
|
-
const dir =
|
|
45776
|
+
const dir = join55(targetPath, "..");
|
|
45613
45777
|
mkdirSync16(dir, { recursive: true });
|
|
45614
45778
|
writeFileSync16(targetPath, content, "utf-8");
|
|
45615
45779
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
@@ -45639,7 +45803,7 @@ var init_dream_engine = __esm({
|
|
|
45639
45803
|
const rawPath = String(args["path"] ?? "");
|
|
45640
45804
|
const oldStr = String(args["old_string"] ?? "");
|
|
45641
45805
|
const newStr = String(args["new_string"] ?? "");
|
|
45642
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
45806
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join55(this.autoresearchDir, basename12(rawPath)) : join55(this.autoresearchDir, rawPath);
|
|
45643
45807
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
45644
45808
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
45645
45809
|
}
|
|
@@ -45693,12 +45857,12 @@ var init_dream_engine = __esm({
|
|
|
45693
45857
|
const content = String(args["content"] ?? "");
|
|
45694
45858
|
if (!rawPath)
|
|
45695
45859
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
45696
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
45860
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join55(this.dreamsDir, basename12(rawPath)) : join55(this.dreamsDir, rawPath);
|
|
45697
45861
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
45698
45862
|
return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
45699
45863
|
}
|
|
45700
45864
|
try {
|
|
45701
|
-
const dir =
|
|
45865
|
+
const dir = join55(targetPath, "..");
|
|
45702
45866
|
mkdirSync16(dir, { recursive: true });
|
|
45703
45867
|
writeFileSync16(targetPath, content, "utf-8");
|
|
45704
45868
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
@@ -45728,7 +45892,7 @@ var init_dream_engine = __esm({
|
|
|
45728
45892
|
const rawPath = String(args["path"] ?? "");
|
|
45729
45893
|
const oldStr = String(args["old_string"] ?? "");
|
|
45730
45894
|
const newStr = String(args["new_string"] ?? "");
|
|
45731
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
45895
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join55(this.dreamsDir, basename12(rawPath)) : join55(this.dreamsDir, rawPath);
|
|
45732
45896
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
45733
45897
|
return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
45734
45898
|
}
|
|
@@ -45795,7 +45959,7 @@ var init_dream_engine = __esm({
|
|
|
45795
45959
|
constructor(config, repoRoot) {
|
|
45796
45960
|
this.config = config;
|
|
45797
45961
|
this.repoRoot = repoRoot;
|
|
45798
|
-
this.dreamsDir =
|
|
45962
|
+
this.dreamsDir = join55(repoRoot, ".oa", "dreams");
|
|
45799
45963
|
this.state = {
|
|
45800
45964
|
mode: "default",
|
|
45801
45965
|
active: false,
|
|
@@ -45879,7 +46043,7 @@ ${result.summary}`;
|
|
|
45879
46043
|
if (mode !== "default" || cycle === totalCycles) {
|
|
45880
46044
|
renderDreamContraction(cycle);
|
|
45881
46045
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
45882
|
-
const summaryPath =
|
|
46046
|
+
const summaryPath = join55(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
45883
46047
|
writeFileSync16(summaryPath, cycleSummary, "utf-8");
|
|
45884
46048
|
}
|
|
45885
46049
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
@@ -46092,7 +46256,7 @@ After synthesis, call task_complete with the final prioritized summary.`, toolMo
|
|
|
46092
46256
|
}
|
|
46093
46257
|
/** Build role-specific tool sets for swarm agents */
|
|
46094
46258
|
buildSwarmTools(role, _workspace) {
|
|
46095
|
-
const autoresearchDir =
|
|
46259
|
+
const autoresearchDir = join55(this.repoRoot, ".oa", "autoresearch");
|
|
46096
46260
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
46097
46261
|
switch (role) {
|
|
46098
46262
|
case "researcher": {
|
|
@@ -46456,7 +46620,7 @@ INSTRUCTIONS:
|
|
|
46456
46620
|
2. Summarize the key learnings and next steps
|
|
46457
46621
|
|
|
46458
46622
|
Call task_complete with a human-readable summary of the autoresearch session.`, workspace, onEvent);
|
|
46459
|
-
const reportPath =
|
|
46623
|
+
const reportPath = join55(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
46460
46624
|
const report = `# Autoresearch Swarm Report \u2014 Cycle ${cycleNum}
|
|
46461
46625
|
|
|
46462
46626
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -46545,7 +46709,7 @@ ${summaryResult}
|
|
|
46545
46709
|
}
|
|
46546
46710
|
/** Save workspace backup for lucid mode */
|
|
46547
46711
|
saveVersionCheckpoint(cycle) {
|
|
46548
|
-
const checkpointDir =
|
|
46712
|
+
const checkpointDir = join55(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
46549
46713
|
try {
|
|
46550
46714
|
mkdirSync16(checkpointDir, { recursive: true });
|
|
46551
46715
|
try {
|
|
@@ -46564,10 +46728,10 @@ ${summaryResult}
|
|
|
46564
46728
|
encoding: "utf-8",
|
|
46565
46729
|
timeout: 5e3
|
|
46566
46730
|
}).trim();
|
|
46567
|
-
writeFileSync16(
|
|
46568
|
-
writeFileSync16(
|
|
46569
|
-
writeFileSync16(
|
|
46570
|
-
writeFileSync16(
|
|
46731
|
+
writeFileSync16(join55(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
|
|
46732
|
+
writeFileSync16(join55(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
|
|
46733
|
+
writeFileSync16(join55(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
|
|
46734
|
+
writeFileSync16(join55(checkpointDir, "checkpoint.json"), JSON.stringify({
|
|
46571
46735
|
cycle,
|
|
46572
46736
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
46573
46737
|
gitHash,
|
|
@@ -46575,7 +46739,7 @@ ${summaryResult}
|
|
|
46575
46739
|
}, null, 2), "utf-8");
|
|
46576
46740
|
renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
46577
46741
|
} catch {
|
|
46578
|
-
writeFileSync16(
|
|
46742
|
+
writeFileSync16(join55(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
|
|
46579
46743
|
renderInfo(`Checkpoint saved: cycle ${cycle} (no git)`);
|
|
46580
46744
|
}
|
|
46581
46745
|
} catch (err) {
|
|
@@ -46633,14 +46797,14 @@ ${files.map((f) => `- [\`${f}\`](./${f})`).join("\n")}
|
|
|
46633
46797
|
---
|
|
46634
46798
|
*Auto-generated by open-agents dream engine*
|
|
46635
46799
|
`;
|
|
46636
|
-
writeFileSync16(
|
|
46800
|
+
writeFileSync16(join55(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
46637
46801
|
} catch {
|
|
46638
46802
|
}
|
|
46639
46803
|
}
|
|
46640
46804
|
/** Save dream state for resume/inspection */
|
|
46641
46805
|
saveDreamState() {
|
|
46642
46806
|
try {
|
|
46643
|
-
writeFileSync16(
|
|
46807
|
+
writeFileSync16(join55(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
46644
46808
|
} catch {
|
|
46645
46809
|
}
|
|
46646
46810
|
}
|
|
@@ -47015,7 +47179,7 @@ var init_bless_engine = __esm({
|
|
|
47015
47179
|
|
|
47016
47180
|
// packages/cli/dist/tui/dmn-engine.js
|
|
47017
47181
|
import { existsSync as existsSync40, readFileSync as readFileSync29, writeFileSync as writeFileSync17, mkdirSync as mkdirSync17, readdirSync as readdirSync13, unlinkSync as unlinkSync9 } from "node:fs";
|
|
47018
|
-
import { join as
|
|
47182
|
+
import { join as join56, basename as basename13 } from "node:path";
|
|
47019
47183
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
47020
47184
|
const competenceReport = competence.length > 0 ? competence.map((c3) => {
|
|
47021
47185
|
const rate = c3.attempts > 0 ? Math.round(c3.successes / c3.attempts * 100) : 0;
|
|
@@ -47128,8 +47292,8 @@ var init_dmn_engine = __esm({
|
|
|
47128
47292
|
constructor(config, repoRoot) {
|
|
47129
47293
|
this.config = config;
|
|
47130
47294
|
this.repoRoot = repoRoot;
|
|
47131
|
-
this.stateDir =
|
|
47132
|
-
this.historyDir =
|
|
47295
|
+
this.stateDir = join56(repoRoot, ".oa", "dmn");
|
|
47296
|
+
this.historyDir = join56(repoRoot, ".oa", "dmn", "cycles");
|
|
47133
47297
|
mkdirSync17(this.historyDir, { recursive: true });
|
|
47134
47298
|
this.loadState();
|
|
47135
47299
|
}
|
|
@@ -47719,8 +47883,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
47719
47883
|
async gatherMemoryTopics() {
|
|
47720
47884
|
const topics = [];
|
|
47721
47885
|
const dirs = [
|
|
47722
|
-
|
|
47723
|
-
|
|
47886
|
+
join56(this.repoRoot, ".oa", "memory"),
|
|
47887
|
+
join56(this.repoRoot, ".open-agents", "memory")
|
|
47724
47888
|
];
|
|
47725
47889
|
for (const dir of dirs) {
|
|
47726
47890
|
if (!existsSync40(dir))
|
|
@@ -47739,7 +47903,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
47739
47903
|
}
|
|
47740
47904
|
// ── State persistence ─────────────────────────────────────────────────
|
|
47741
47905
|
loadState() {
|
|
47742
|
-
const path =
|
|
47906
|
+
const path = join56(this.stateDir, "state.json");
|
|
47743
47907
|
if (existsSync40(path)) {
|
|
47744
47908
|
try {
|
|
47745
47909
|
this.state = JSON.parse(readFileSync29(path, "utf-8"));
|
|
@@ -47749,19 +47913,19 @@ OUTPUT: Call task_complete with JSON:
|
|
|
47749
47913
|
}
|
|
47750
47914
|
saveState() {
|
|
47751
47915
|
try {
|
|
47752
|
-
writeFileSync17(
|
|
47916
|
+
writeFileSync17(join56(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
47753
47917
|
} catch {
|
|
47754
47918
|
}
|
|
47755
47919
|
}
|
|
47756
47920
|
saveCycleResult(result) {
|
|
47757
47921
|
try {
|
|
47758
47922
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
47759
|
-
writeFileSync17(
|
|
47923
|
+
writeFileSync17(join56(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
|
|
47760
47924
|
const files = readdirSync13(this.historyDir).filter((f) => f.startsWith("cycle-") && f.endsWith(".json")).sort();
|
|
47761
47925
|
if (files.length > 50) {
|
|
47762
47926
|
for (const old of files.slice(0, files.length - 50)) {
|
|
47763
47927
|
try {
|
|
47764
|
-
unlinkSync9(
|
|
47928
|
+
unlinkSync9(join56(this.historyDir, old));
|
|
47765
47929
|
} catch {
|
|
47766
47930
|
}
|
|
47767
47931
|
}
|
|
@@ -47775,7 +47939,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
47775
47939
|
|
|
47776
47940
|
// packages/cli/dist/tui/snr-engine.js
|
|
47777
47941
|
import { existsSync as existsSync41, readdirSync as readdirSync14, readFileSync as readFileSync30 } from "node:fs";
|
|
47778
|
-
import { join as
|
|
47942
|
+
import { join as join57, basename as basename14 } from "node:path";
|
|
47779
47943
|
function computeDPrime(signalScores, noiseScores) {
|
|
47780
47944
|
if (signalScores.length === 0 || noiseScores.length === 0)
|
|
47781
47945
|
return 0;
|
|
@@ -48015,8 +48179,8 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
48015
48179
|
loadMemoryEntries(topics) {
|
|
48016
48180
|
const entries = [];
|
|
48017
48181
|
const dirs = [
|
|
48018
|
-
|
|
48019
|
-
|
|
48182
|
+
join57(this.repoRoot, ".oa", "memory"),
|
|
48183
|
+
join57(this.repoRoot, ".open-agents", "memory")
|
|
48020
48184
|
];
|
|
48021
48185
|
for (const dir of dirs) {
|
|
48022
48186
|
if (!existsSync41(dir))
|
|
@@ -48028,7 +48192,7 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
48028
48192
|
if (topics.length > 0 && !topics.includes(topic))
|
|
48029
48193
|
continue;
|
|
48030
48194
|
try {
|
|
48031
|
-
const data = JSON.parse(readFileSync30(
|
|
48195
|
+
const data = JSON.parse(readFileSync30(join57(dir, f), "utf-8"));
|
|
48032
48196
|
for (const [key, val] of Object.entries(data)) {
|
|
48033
48197
|
const value = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
48034
48198
|
entries.push({ topic, key, value });
|
|
@@ -48596,7 +48760,7 @@ var init_tool_policy = __esm({
|
|
|
48596
48760
|
|
|
48597
48761
|
// packages/cli/dist/tui/telegram-bridge.js
|
|
48598
48762
|
import { mkdirSync as mkdirSync18, existsSync as existsSync42, unlinkSync as unlinkSync10, readdirSync as readdirSync15, statSync as statSync13 } from "node:fs";
|
|
48599
|
-
import { join as
|
|
48763
|
+
import { join as join58, resolve as resolve28 } from "node:path";
|
|
48600
48764
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
48601
48765
|
function convertMarkdownToTelegramHTML(md) {
|
|
48602
48766
|
let html = md;
|
|
@@ -49361,7 +49525,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
|
|
|
49361
49525
|
return null;
|
|
49362
49526
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
49363
49527
|
const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension}`;
|
|
49364
|
-
const localPath =
|
|
49528
|
+
const localPath = join58(this.mediaCacheDir, fileName);
|
|
49365
49529
|
await writeFileAsync(localPath, buffer);
|
|
49366
49530
|
return localPath;
|
|
49367
49531
|
} catch {
|
|
@@ -51822,7 +51986,7 @@ var init_status_bar = __esm({
|
|
|
51822
51986
|
import * as readline2 from "node:readline";
|
|
51823
51987
|
import { Writable } from "node:stream";
|
|
51824
51988
|
import { cwd } from "node:process";
|
|
51825
|
-
import { resolve as resolve29, join as
|
|
51989
|
+
import { resolve as resolve29, join as join59, dirname as dirname18, extname as extname10 } from "node:path";
|
|
51826
51990
|
import { createRequire as createRequire2 } from "node:module";
|
|
51827
51991
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
51828
51992
|
import { readFileSync as readFileSync32, writeFileSync as writeFileSync18, appendFileSync as appendFileSync4, rmSync as rmSync2, readdirSync as readdirSync16, mkdirSync as mkdirSync19 } from "node:fs";
|
|
@@ -51846,9 +52010,9 @@ function getVersion3() {
|
|
|
51846
52010
|
const require2 = createRequire2(import.meta.url);
|
|
51847
52011
|
const thisDir = dirname18(fileURLToPath12(import.meta.url));
|
|
51848
52012
|
const candidates = [
|
|
51849
|
-
|
|
51850
|
-
|
|
51851
|
-
|
|
52013
|
+
join59(thisDir, "..", "package.json"),
|
|
52014
|
+
join59(thisDir, "..", "..", "package.json"),
|
|
52015
|
+
join59(thisDir, "..", "..", "..", "package.json")
|
|
51852
52016
|
];
|
|
51853
52017
|
for (const pkgPath of candidates) {
|
|
51854
52018
|
if (existsSync43(pkgPath)) {
|
|
@@ -51951,6 +52115,8 @@ function buildTools(repoRoot, config, contextWindowSize) {
|
|
|
51951
52115
|
new ExplorationCultureTool(repoRoot),
|
|
51952
52116
|
// Embedding Store — COHERE Private Brain semantic retrieval
|
|
51953
52117
|
new EmbeddingStoreTool(repoRoot),
|
|
52118
|
+
// Image Generation — Ollama diffusion models
|
|
52119
|
+
new ImageGenerateTool(repoRoot, config.backendUrl),
|
|
51954
52120
|
// Structured file reading (CSV, JSON, Markdown, binary detection)
|
|
51955
52121
|
new StructuredReadTool(repoRoot),
|
|
51956
52122
|
// Vision tools (Moondream — desktop awareness + point-and-click)
|
|
@@ -52070,15 +52236,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
|
|
|
52070
52236
|
function gatherMemorySnippets(root) {
|
|
52071
52237
|
const snippets = [];
|
|
52072
52238
|
const dirs = [
|
|
52073
|
-
|
|
52074
|
-
|
|
52239
|
+
join59(root, ".oa", "memory"),
|
|
52240
|
+
join59(root, ".open-agents", "memory")
|
|
52075
52241
|
];
|
|
52076
52242
|
for (const dir of dirs) {
|
|
52077
52243
|
if (!existsSync43(dir))
|
|
52078
52244
|
continue;
|
|
52079
52245
|
try {
|
|
52080
52246
|
for (const f of readdirSync16(dir).filter((f2) => f2.endsWith(".json"))) {
|
|
52081
|
-
const data = JSON.parse(readFileSync32(
|
|
52247
|
+
const data = JSON.parse(readFileSync32(join59(dir, f), "utf-8"));
|
|
52082
52248
|
for (const val of Object.values(data)) {
|
|
52083
52249
|
const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
52084
52250
|
if (v.length > 10)
|
|
@@ -53186,7 +53352,7 @@ async function startInteractive(config, repoPath) {
|
|
|
53186
53352
|
let p2pGateway = null;
|
|
53187
53353
|
let peerMesh = null;
|
|
53188
53354
|
let inferenceRouter = null;
|
|
53189
|
-
const secretVault = new SecretVault(
|
|
53355
|
+
const secretVault = new SecretVault(join59(repoRoot, ".oa", "vault.enc"));
|
|
53190
53356
|
let adminSessionKey = null;
|
|
53191
53357
|
const callSubAgents = /* @__PURE__ */ new Map();
|
|
53192
53358
|
const streamRenderer = new StreamRenderer();
|
|
@@ -53395,8 +53561,8 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
53395
53561
|
const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
|
|
53396
53562
|
return [hits, line];
|
|
53397
53563
|
}
|
|
53398
|
-
const HISTORY_DIR =
|
|
53399
|
-
const HISTORY_FILE =
|
|
53564
|
+
const HISTORY_DIR = join59(homedir13(), ".open-agents");
|
|
53565
|
+
const HISTORY_FILE = join59(HISTORY_DIR, "repl-history");
|
|
53400
53566
|
const MAX_HISTORY_LINES = 500;
|
|
53401
53567
|
let savedHistory = [];
|
|
53402
53568
|
try {
|
|
@@ -53606,7 +53772,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
53606
53772
|
} catch {
|
|
53607
53773
|
}
|
|
53608
53774
|
try {
|
|
53609
|
-
const oaDir =
|
|
53775
|
+
const oaDir = join59(repoRoot, ".oa");
|
|
53610
53776
|
const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
|
|
53611
53777
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
53612
53778
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -53629,7 +53795,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
53629
53795
|
} catch {
|
|
53630
53796
|
}
|
|
53631
53797
|
try {
|
|
53632
|
-
const oaDir =
|
|
53798
|
+
const oaDir = join59(repoRoot, ".oa");
|
|
53633
53799
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
|
|
53634
53800
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
53635
53801
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -54463,7 +54629,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
54463
54629
|
kind,
|
|
54464
54630
|
targetUrl,
|
|
54465
54631
|
authKey,
|
|
54466
|
-
stateDir:
|
|
54632
|
+
stateDir: join59(repoRoot, ".oa"),
|
|
54467
54633
|
passthrough: passthrough ?? false,
|
|
54468
54634
|
loadbalance: loadbalance ?? false,
|
|
54469
54635
|
endpointAuth: passthrough ? currentConfig.apiKey : void 0,
|
|
@@ -54511,7 +54677,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
54511
54677
|
await tunnelGateway.stop();
|
|
54512
54678
|
tunnelGateway = null;
|
|
54513
54679
|
}
|
|
54514
|
-
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir:
|
|
54680
|
+
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join59(repoRoot, ".oa") });
|
|
54515
54681
|
newTunnel.on("stats", (stats) => {
|
|
54516
54682
|
statusBar.setExposeStatus({
|
|
54517
54683
|
status: stats.status,
|
|
@@ -54773,7 +54939,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
54773
54939
|
}
|
|
54774
54940
|
},
|
|
54775
54941
|
destroyProject() {
|
|
54776
|
-
const oaPath =
|
|
54942
|
+
const oaPath = join59(repoRoot, OA_DIR);
|
|
54777
54943
|
if (existsSync43(oaPath)) {
|
|
54778
54944
|
try {
|
|
54779
54945
|
rmSync2(oaPath, { recursive: true, force: true });
|
|
@@ -55709,7 +55875,7 @@ import { glob } from "glob";
|
|
|
55709
55875
|
import ignore from "ignore";
|
|
55710
55876
|
import { readFile as readFile22, stat as stat4 } from "node:fs/promises";
|
|
55711
55877
|
import { createHash as createHash4 } from "node:crypto";
|
|
55712
|
-
import { join as
|
|
55878
|
+
import { join as join60, relative as relative3, extname as extname11, basename as basename15 } from "node:path";
|
|
55713
55879
|
var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
|
|
55714
55880
|
var init_codebase_indexer = __esm({
|
|
55715
55881
|
"packages/indexer/dist/codebase-indexer.js"() {
|
|
@@ -55753,7 +55919,7 @@ var init_codebase_indexer = __esm({
|
|
|
55753
55919
|
const ig = ignore.default();
|
|
55754
55920
|
if (this.config.respectGitignore) {
|
|
55755
55921
|
try {
|
|
55756
|
-
const gitignoreContent = await readFile22(
|
|
55922
|
+
const gitignoreContent = await readFile22(join60(this.config.rootDir, ".gitignore"), "utf-8");
|
|
55757
55923
|
ig.add(gitignoreContent);
|
|
55758
55924
|
} catch {
|
|
55759
55925
|
}
|
|
@@ -55768,7 +55934,7 @@ var init_codebase_indexer = __esm({
|
|
|
55768
55934
|
for (const relativePath of files) {
|
|
55769
55935
|
if (ig.ignores(relativePath))
|
|
55770
55936
|
continue;
|
|
55771
|
-
const fullPath =
|
|
55937
|
+
const fullPath = join60(this.config.rootDir, relativePath);
|
|
55772
55938
|
try {
|
|
55773
55939
|
const fileStat = await stat4(fullPath);
|
|
55774
55940
|
if (fileStat.size > this.config.maxFileSize)
|
|
@@ -55814,7 +55980,7 @@ var init_codebase_indexer = __esm({
|
|
|
55814
55980
|
if (!child) {
|
|
55815
55981
|
child = {
|
|
55816
55982
|
name: part,
|
|
55817
|
-
path:
|
|
55983
|
+
path: join60(current.path, part),
|
|
55818
55984
|
type: "directory",
|
|
55819
55985
|
children: []
|
|
55820
55986
|
};
|
|
@@ -56155,7 +56321,7 @@ var config_exports = {};
|
|
|
56155
56321
|
__export(config_exports, {
|
|
56156
56322
|
configCommand: () => configCommand
|
|
56157
56323
|
});
|
|
56158
|
-
import { join as
|
|
56324
|
+
import { join as join61, resolve as resolve31 } from "node:path";
|
|
56159
56325
|
import { homedir as homedir14 } from "node:os";
|
|
56160
56326
|
import { cwd as cwd3 } from "node:process";
|
|
56161
56327
|
function redactIfSensitive(key, value) {
|
|
@@ -56238,7 +56404,7 @@ function handleShow(opts, config) {
|
|
|
56238
56404
|
}
|
|
56239
56405
|
}
|
|
56240
56406
|
printSection("Config File");
|
|
56241
|
-
printInfo(`~/.open-agents/config.json (${
|
|
56407
|
+
printInfo(`~/.open-agents/config.json (${join61(homedir14(), ".open-agents", "config.json")})`);
|
|
56242
56408
|
printSection("Priority Chain");
|
|
56243
56409
|
printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
|
|
56244
56410
|
printInfo(" 2. Project .oa/settings.json (--local)");
|
|
@@ -56277,7 +56443,7 @@ function handleSet(opts, _config) {
|
|
|
56277
56443
|
const coerced = coerceForSettings(key, value);
|
|
56278
56444
|
saveProjectSettings(repoRoot, { [key]: coerced });
|
|
56279
56445
|
printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value)}`);
|
|
56280
|
-
printInfo(`Saved to ${
|
|
56446
|
+
printInfo(`Saved to ${join61(repoRoot, ".oa", "settings.json")}`);
|
|
56281
56447
|
printInfo("This override applies only when running in this workspace.");
|
|
56282
56448
|
} catch (err) {
|
|
56283
56449
|
printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -56536,7 +56702,7 @@ __export(eval_exports, {
|
|
|
56536
56702
|
});
|
|
56537
56703
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
56538
56704
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync19 } from "node:fs";
|
|
56539
|
-
import { join as
|
|
56705
|
+
import { join as join62 } from "node:path";
|
|
56540
56706
|
async function evalCommand(opts, config) {
|
|
56541
56707
|
const suiteName = opts.suite ?? "basic";
|
|
56542
56708
|
const suite = SUITES[suiteName];
|
|
@@ -56661,9 +56827,9 @@ async function evalCommand(opts, config) {
|
|
|
56661
56827
|
process.exit(failed > 0 ? 1 : 0);
|
|
56662
56828
|
}
|
|
56663
56829
|
function createTempEvalRepo() {
|
|
56664
|
-
const dir =
|
|
56830
|
+
const dir = join62(tmpdir10(), `open-agents-eval-${Date.now()}`);
|
|
56665
56831
|
mkdirSync20(dir, { recursive: true });
|
|
56666
|
-
writeFileSync19(
|
|
56832
|
+
writeFileSync19(join62(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
|
|
56667
56833
|
return dir;
|
|
56668
56834
|
}
|
|
56669
56835
|
var BASIC_SUITE, FULL_SUITE, SUITES;
|
|
@@ -56723,7 +56889,7 @@ init_updater();
|
|
|
56723
56889
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
56724
56890
|
import { createRequire as createRequire3 } from "node:module";
|
|
56725
56891
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
56726
|
-
import { dirname as dirname19, join as
|
|
56892
|
+
import { dirname as dirname19, join as join63 } from "node:path";
|
|
56727
56893
|
|
|
56728
56894
|
// packages/cli/dist/cli.js
|
|
56729
56895
|
import { createInterface } from "node:readline";
|
|
@@ -56830,7 +56996,7 @@ init_output();
|
|
|
56830
56996
|
function getVersion4() {
|
|
56831
56997
|
try {
|
|
56832
56998
|
const require2 = createRequire3(import.meta.url);
|
|
56833
|
-
const pkgPath =
|
|
56999
|
+
const pkgPath = join63(dirname19(fileURLToPath13(import.meta.url)), "..", "package.json");
|
|
56834
57000
|
const pkg = require2(pkgPath);
|
|
56835
57001
|
return pkg.version;
|
|
56836
57002
|
} catch {
|