open-agents-ai 0.140.4 → 0.141.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 +900 -542
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12657,11 +12657,11 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
12657
12657
|
* what was previously computed. */
|
|
12658
12658
|
async loadSessionInfo() {
|
|
12659
12659
|
try {
|
|
12660
|
-
const { readFileSync:
|
|
12660
|
+
const { readFileSync: readFileSync35, existsSync: existsSync47 } = await import("node:fs");
|
|
12661
12661
|
const sessionPath = join20(this.cwd, ".oa", "rlm", "session.json");
|
|
12662
|
-
if (!
|
|
12662
|
+
if (!existsSync47(sessionPath))
|
|
12663
12663
|
return null;
|
|
12664
|
-
return JSON.parse(
|
|
12664
|
+
return JSON.parse(readFileSync35(sessionPath, "utf8"));
|
|
12665
12665
|
} catch {
|
|
12666
12666
|
return null;
|
|
12667
12667
|
}
|
|
@@ -12838,10 +12838,10 @@ var init_memory_metabolism = __esm({
|
|
|
12838
12838
|
const trajDir = join21(this.cwd, ".oa", "rlm-trajectories");
|
|
12839
12839
|
let lessons = [];
|
|
12840
12840
|
try {
|
|
12841
|
-
const { readdirSync: readdirSync18, readFileSync:
|
|
12841
|
+
const { readdirSync: readdirSync18, readFileSync: readFileSync35 } = await import("node:fs");
|
|
12842
12842
|
const files = readdirSync18(trajDir).filter((f) => f.endsWith(".jsonl")).sort().reverse().slice(0, 3);
|
|
12843
12843
|
for (const file of files) {
|
|
12844
|
-
const lines =
|
|
12844
|
+
const lines = readFileSync35(join21(trajDir, file), "utf8").split("\n").filter((l) => l.trim());
|
|
12845
12845
|
for (const line of lines) {
|
|
12846
12846
|
try {
|
|
12847
12847
|
const entry = JSON.parse(line);
|
|
@@ -13225,14 +13225,14 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
|
|
|
13225
13225
|
* Optionally filter by task type for phase-aware context (FSM paper insight).
|
|
13226
13226
|
*/
|
|
13227
13227
|
getTopMemoriesSync(k = 5, taskType) {
|
|
13228
|
-
const { readFileSync:
|
|
13228
|
+
const { readFileSync: readFileSync35, existsSync: existsSync47 } = __require("node:fs");
|
|
13229
13229
|
const metaDir = join21(this.cwd, ".oa", "memory", "metabolism");
|
|
13230
13230
|
const storeFile = join21(metaDir, "store.json");
|
|
13231
|
-
if (!
|
|
13231
|
+
if (!existsSync47(storeFile))
|
|
13232
13232
|
return "";
|
|
13233
13233
|
let store = [];
|
|
13234
13234
|
try {
|
|
13235
|
-
store = JSON.parse(
|
|
13235
|
+
store = JSON.parse(readFileSync35(storeFile, "utf8"));
|
|
13236
13236
|
} catch {
|
|
13237
13237
|
return "";
|
|
13238
13238
|
}
|
|
@@ -13254,14 +13254,14 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
|
|
|
13254
13254
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
13255
13255
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
13256
13256
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
13257
|
-
const { readFileSync:
|
|
13257
|
+
const { readFileSync: readFileSync35, writeFileSync: writeFileSync21, existsSync: existsSync47, mkdirSync: mkdirSync22 } = __require("node:fs");
|
|
13258
13258
|
const metaDir = join21(this.cwd, ".oa", "memory", "metabolism");
|
|
13259
13259
|
const storeFile = join21(metaDir, "store.json");
|
|
13260
|
-
if (!
|
|
13260
|
+
if (!existsSync47(storeFile))
|
|
13261
13261
|
return;
|
|
13262
13262
|
let store = [];
|
|
13263
13263
|
try {
|
|
13264
|
-
store = JSON.parse(
|
|
13264
|
+
store = JSON.parse(readFileSync35(storeFile, "utf8"));
|
|
13265
13265
|
} catch {
|
|
13266
13266
|
return;
|
|
13267
13267
|
}
|
|
@@ -13708,13 +13708,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
13708
13708
|
// Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
|
|
13709
13709
|
/** Retrieve top-K strategies for context injection. Returns "" if none. */
|
|
13710
13710
|
getRelevantStrategiesSync(k = 3, taskType) {
|
|
13711
|
-
const { readFileSync:
|
|
13711
|
+
const { readFileSync: readFileSync35, existsSync: existsSync47 } = __require("node:fs");
|
|
13712
13712
|
const archiveFile = join23(this.cwd, ".oa", "arche", "variants.json");
|
|
13713
|
-
if (!
|
|
13713
|
+
if (!existsSync47(archiveFile))
|
|
13714
13714
|
return "";
|
|
13715
13715
|
let variants = [];
|
|
13716
13716
|
try {
|
|
13717
|
-
variants = JSON.parse(
|
|
13717
|
+
variants = JSON.parse(readFileSync35(archiveFile, "utf8"));
|
|
13718
13718
|
} catch {
|
|
13719
13719
|
return "";
|
|
13720
13720
|
}
|
|
@@ -13732,13 +13732,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
13732
13732
|
}
|
|
13733
13733
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
13734
13734
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
13735
|
-
const { readFileSync:
|
|
13735
|
+
const { readFileSync: readFileSync35, writeFileSync: writeFileSync21, existsSync: existsSync47, mkdirSync: mkdirSync22 } = __require("node:fs");
|
|
13736
13736
|
const dir = join23(this.cwd, ".oa", "arche");
|
|
13737
13737
|
const archiveFile = join23(dir, "variants.json");
|
|
13738
13738
|
let variants = [];
|
|
13739
13739
|
try {
|
|
13740
|
-
if (
|
|
13741
|
-
variants = JSON.parse(
|
|
13740
|
+
if (existsSync47(archiveFile))
|
|
13741
|
+
variants = JSON.parse(readFileSync35(archiveFile, "utf8"));
|
|
13742
13742
|
} catch {
|
|
13743
13743
|
}
|
|
13744
13744
|
variants.push({
|
|
@@ -18804,6 +18804,157 @@ ${truncated}`, durationMs: performance.now() - start };
|
|
|
18804
18804
|
}
|
|
18805
18805
|
});
|
|
18806
18806
|
|
|
18807
|
+
// packages/execution/dist/tools/fortemi-bridge.js
|
|
18808
|
+
import { existsSync as existsSync24, readFileSync as readFileSync17 } from "node:fs";
|
|
18809
|
+
import { join as join38 } from "node:path";
|
|
18810
|
+
function loadBridgeState(repoRoot) {
|
|
18811
|
+
const bridgeFile = join38(repoRoot, ".oa", "fortemi-bridge.json");
|
|
18812
|
+
if (!existsSync24(bridgeFile))
|
|
18813
|
+
return null;
|
|
18814
|
+
try {
|
|
18815
|
+
return JSON.parse(readFileSync17(bridgeFile, "utf8"));
|
|
18816
|
+
} catch {
|
|
18817
|
+
return null;
|
|
18818
|
+
}
|
|
18819
|
+
}
|
|
18820
|
+
function createFortemiBridgeTool(def, bridgeUrl) {
|
|
18821
|
+
return {
|
|
18822
|
+
name: def.name,
|
|
18823
|
+
description: def.description,
|
|
18824
|
+
parameters: def.parameters,
|
|
18825
|
+
async execute(args) {
|
|
18826
|
+
const start = performance.now();
|
|
18827
|
+
try {
|
|
18828
|
+
const body = def.buildBody(args);
|
|
18829
|
+
const resp = await fetch(`${bridgeUrl}${def.endpoint}`, {
|
|
18830
|
+
method: "POST",
|
|
18831
|
+
headers: { "Content-Type": "application/json" },
|
|
18832
|
+
body: JSON.stringify(body),
|
|
18833
|
+
signal: AbortSignal.timeout(3e4)
|
|
18834
|
+
});
|
|
18835
|
+
if (!resp.ok) {
|
|
18836
|
+
const errText = await resp.text().catch(() => "");
|
|
18837
|
+
return {
|
|
18838
|
+
success: false,
|
|
18839
|
+
output: `Fortemi error: HTTP ${resp.status} \u2014 ${errText.slice(0, 200)}`,
|
|
18840
|
+
durationMs: performance.now() - start
|
|
18841
|
+
};
|
|
18842
|
+
}
|
|
18843
|
+
const data = await resp.json();
|
|
18844
|
+
return {
|
|
18845
|
+
success: true,
|
|
18846
|
+
output: JSON.stringify(data, null, 2).slice(0, 3e3),
|
|
18847
|
+
durationMs: performance.now() - start
|
|
18848
|
+
};
|
|
18849
|
+
} catch (err) {
|
|
18850
|
+
return {
|
|
18851
|
+
success: false,
|
|
18852
|
+
output: `Fortemi bridge error: ${err instanceof Error ? err.message : String(err)}`,
|
|
18853
|
+
durationMs: performance.now() - start
|
|
18854
|
+
};
|
|
18855
|
+
}
|
|
18856
|
+
}
|
|
18857
|
+
};
|
|
18858
|
+
}
|
|
18859
|
+
function createFortemiBridgeTools(repoRoot) {
|
|
18860
|
+
const state = loadBridgeState(repoRoot);
|
|
18861
|
+
if (!state)
|
|
18862
|
+
return [];
|
|
18863
|
+
try {
|
|
18864
|
+
process.kill(state.pid, 0);
|
|
18865
|
+
} catch {
|
|
18866
|
+
return [];
|
|
18867
|
+
}
|
|
18868
|
+
return FORTEMI_TOOLS.map((def) => createFortemiBridgeTool(def, state.url));
|
|
18869
|
+
}
|
|
18870
|
+
async function isFortemiAvailable(repoRoot) {
|
|
18871
|
+
const state = loadBridgeState(repoRoot);
|
|
18872
|
+
if (!state)
|
|
18873
|
+
return false;
|
|
18874
|
+
try {
|
|
18875
|
+
const resp = await fetch(`${state.url}/api/v1/tools/list_notes`, {
|
|
18876
|
+
signal: AbortSignal.timeout(3e3)
|
|
18877
|
+
});
|
|
18878
|
+
return resp.ok;
|
|
18879
|
+
} catch {
|
|
18880
|
+
return false;
|
|
18881
|
+
}
|
|
18882
|
+
}
|
|
18883
|
+
var FORTEMI_TOOLS;
|
|
18884
|
+
var init_fortemi_bridge = __esm({
|
|
18885
|
+
"packages/execution/dist/tools/fortemi-bridge.js"() {
|
|
18886
|
+
"use strict";
|
|
18887
|
+
FORTEMI_TOOLS = [
|
|
18888
|
+
{
|
|
18889
|
+
name: "fortemi_capture",
|
|
18890
|
+
description: "Capture knowledge into fortemi-react \u2014 creates a note with optional tags. Content is auto-processed (embeddings, linking, AI revision).",
|
|
18891
|
+
parameters: {
|
|
18892
|
+
type: "object",
|
|
18893
|
+
properties: {
|
|
18894
|
+
content: { type: "string", description: "The text content to capture" },
|
|
18895
|
+
title: { type: "string", description: "Optional title" },
|
|
18896
|
+
tags: { type: "array", items: { type: "string" }, description: "Optional tags" }
|
|
18897
|
+
},
|
|
18898
|
+
required: ["content"]
|
|
18899
|
+
},
|
|
18900
|
+
endpoint: "/api/v1/tools/capture_knowledge",
|
|
18901
|
+
buildBody: (args) => ({
|
|
18902
|
+
action: "create",
|
|
18903
|
+
content: String(args.content ?? ""),
|
|
18904
|
+
title: args.title ? String(args.title) : void 0,
|
|
18905
|
+
tags: Array.isArray(args.tags) ? args.tags : void 0
|
|
18906
|
+
})
|
|
18907
|
+
},
|
|
18908
|
+
{
|
|
18909
|
+
name: "fortemi_search",
|
|
18910
|
+
description: "Search fortemi-react notes with full-text or semantic search. Returns matching notes with relevance scores.",
|
|
18911
|
+
parameters: {
|
|
18912
|
+
type: "object",
|
|
18913
|
+
properties: {
|
|
18914
|
+
query: { type: "string", description: "Search query" },
|
|
18915
|
+
limit: { type: "number", description: "Max results (default 10)" }
|
|
18916
|
+
},
|
|
18917
|
+
required: ["query"]
|
|
18918
|
+
},
|
|
18919
|
+
endpoint: "/api/v1/tools/search",
|
|
18920
|
+
buildBody: (args) => ({
|
|
18921
|
+
query: String(args.query ?? ""),
|
|
18922
|
+
limit: Number(args.limit ?? 10)
|
|
18923
|
+
})
|
|
18924
|
+
},
|
|
18925
|
+
{
|
|
18926
|
+
name: "fortemi_list",
|
|
18927
|
+
description: "List recent notes from fortemi-react with pagination.",
|
|
18928
|
+
parameters: {
|
|
18929
|
+
type: "object",
|
|
18930
|
+
properties: {
|
|
18931
|
+
limit: { type: "number", description: "Max results (default 20)" },
|
|
18932
|
+
offset: { type: "number", description: "Pagination offset" }
|
|
18933
|
+
}
|
|
18934
|
+
},
|
|
18935
|
+
endpoint: "/api/v1/tools/list_notes",
|
|
18936
|
+
buildBody: (args) => ({
|
|
18937
|
+
limit: Number(args.limit ?? 20),
|
|
18938
|
+
offset: Number(args.offset ?? 0)
|
|
18939
|
+
})
|
|
18940
|
+
},
|
|
18941
|
+
{
|
|
18942
|
+
name: "fortemi_get",
|
|
18943
|
+
description: "Get a specific note by ID from fortemi-react.",
|
|
18944
|
+
parameters: {
|
|
18945
|
+
type: "object",
|
|
18946
|
+
properties: {
|
|
18947
|
+
id: { type: "string", description: "Note ID" }
|
|
18948
|
+
},
|
|
18949
|
+
required: ["id"]
|
|
18950
|
+
},
|
|
18951
|
+
endpoint: "/api/v1/tools/get_note",
|
|
18952
|
+
buildBody: (args) => ({ id: String(args.id ?? "") })
|
|
18953
|
+
}
|
|
18954
|
+
];
|
|
18955
|
+
}
|
|
18956
|
+
});
|
|
18957
|
+
|
|
18807
18958
|
// packages/execution/dist/shellRunner.js
|
|
18808
18959
|
import { spawn as spawn13 } from "node:child_process";
|
|
18809
18960
|
async function runShell(options) {
|
|
@@ -18909,7 +19060,7 @@ var init_gitWorktree = __esm({
|
|
|
18909
19060
|
});
|
|
18910
19061
|
|
|
18911
19062
|
// packages/execution/dist/patchApplier.js
|
|
18912
|
-
import { readFileSync as
|
|
19063
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync7, existsSync as existsSync25, mkdirSync as mkdirSync7 } from "node:fs";
|
|
18913
19064
|
import { dirname as dirname11 } from "node:path";
|
|
18914
19065
|
import { spawn as spawn14 } from "node:child_process";
|
|
18915
19066
|
async function applyPatch(patch) {
|
|
@@ -18925,7 +19076,7 @@ async function applyPatch(patch) {
|
|
|
18925
19076
|
}
|
|
18926
19077
|
}
|
|
18927
19078
|
function applyBlockReplace(patch) {
|
|
18928
|
-
const original =
|
|
19079
|
+
const original = readFileSync18(patch.filePath, "utf-8");
|
|
18929
19080
|
if (!original.includes(patch.oldContent)) {
|
|
18930
19081
|
throw new Error(`Block not found in "${patch.filePath}": the oldContent string was not found in the file.`);
|
|
18931
19082
|
}
|
|
@@ -18936,7 +19087,7 @@ function applyRewrite(patch) {
|
|
|
18936
19087
|
writeFileSync7(patch.filePath, patch.newContent, "utf-8");
|
|
18937
19088
|
}
|
|
18938
19089
|
function applyNewFile(patch) {
|
|
18939
|
-
if (
|
|
19090
|
+
if (existsSync25(patch.filePath)) {
|
|
18940
19091
|
throw new Error(`Cannot create new file: "${patch.filePath}" already exists.`);
|
|
18941
19092
|
}
|
|
18942
19093
|
mkdirSync7(dirname11(patch.filePath), { recursive: true });
|
|
@@ -19474,6 +19625,7 @@ __export(dist_exports, {
|
|
|
19474
19625
|
buildCustomTools: () => buildCustomTools,
|
|
19475
19626
|
buildSkillsSummary: () => buildSkillsSummary,
|
|
19476
19627
|
checkDesktopDeps: () => checkDesktopDeps,
|
|
19628
|
+
createFortemiBridgeTools: () => createFortemiBridgeTools,
|
|
19477
19629
|
createWorktree: () => createWorktree,
|
|
19478
19630
|
detectSearchProvider: () => detectSearchProvider,
|
|
19479
19631
|
discoverSkills: () => discoverSkills,
|
|
@@ -19482,6 +19634,7 @@ __export(dist_exports, {
|
|
|
19482
19634
|
ensureDepsForGroup: () => ensureDepsForGroup,
|
|
19483
19635
|
getActiveAttentionItems: () => getActiveAttentionItems,
|
|
19484
19636
|
getDueReminders: () => getDueReminders,
|
|
19637
|
+
isFortemiAvailable: () => isFortemiAvailable,
|
|
19485
19638
|
isImagePath: () => isImagePath,
|
|
19486
19639
|
listCustomToolFiles: () => listCustomToolFiles,
|
|
19487
19640
|
loadCustomTools: () => loadCustomTools,
|
|
@@ -19558,6 +19711,7 @@ var init_dist2 = __esm({
|
|
|
19558
19711
|
init_factory();
|
|
19559
19712
|
init_cron_agent();
|
|
19560
19713
|
init_nexus();
|
|
19714
|
+
init_fortemi_bridge();
|
|
19561
19715
|
init_system_deps();
|
|
19562
19716
|
init_shellRunner();
|
|
19563
19717
|
init_gitWorktree();
|
|
@@ -20242,17 +20396,17 @@ var init_dist3 = __esm({
|
|
|
20242
20396
|
});
|
|
20243
20397
|
|
|
20244
20398
|
// packages/orchestrator/dist/promptLoader.js
|
|
20245
|
-
import { readFileSync as
|
|
20246
|
-
import { join as
|
|
20399
|
+
import { readFileSync as readFileSync19, existsSync as existsSync26 } from "node:fs";
|
|
20400
|
+
import { join as join39, dirname as dirname12 } from "node:path";
|
|
20247
20401
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
20248
20402
|
function loadPrompt(promptPath, vars) {
|
|
20249
20403
|
let content = cache.get(promptPath);
|
|
20250
20404
|
if (content === void 0) {
|
|
20251
|
-
const fullPath =
|
|
20252
|
-
if (!
|
|
20405
|
+
const fullPath = join39(PROMPTS_DIR, promptPath);
|
|
20406
|
+
if (!existsSync26(fullPath)) {
|
|
20253
20407
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
20254
20408
|
}
|
|
20255
|
-
content =
|
|
20409
|
+
content = readFileSync19(fullPath, "utf-8");
|
|
20256
20410
|
cache.set(promptPath, content);
|
|
20257
20411
|
}
|
|
20258
20412
|
if (!vars)
|
|
@@ -20265,7 +20419,7 @@ var init_promptLoader = __esm({
|
|
|
20265
20419
|
"use strict";
|
|
20266
20420
|
__filename = fileURLToPath7(import.meta.url);
|
|
20267
20421
|
__dirname4 = dirname12(__filename);
|
|
20268
|
-
PROMPTS_DIR =
|
|
20422
|
+
PROMPTS_DIR = join39(__dirname4, "..", "prompts");
|
|
20269
20423
|
cache = /* @__PURE__ */ new Map();
|
|
20270
20424
|
}
|
|
20271
20425
|
});
|
|
@@ -20645,7 +20799,7 @@ var init_code_retriever = __esm({
|
|
|
20645
20799
|
import { execFile as execFile5 } from "node:child_process";
|
|
20646
20800
|
import { promisify as promisify4 } from "node:util";
|
|
20647
20801
|
import { readFile as readFile19, readdir as readdir5, stat as stat3 } from "node:fs/promises";
|
|
20648
|
-
import { join as
|
|
20802
|
+
import { join as join40, extname as extname7 } from "node:path";
|
|
20649
20803
|
async function searchByPath(pathPattern, options) {
|
|
20650
20804
|
const allFiles = await collectFiles(options.rootDir, options.includeGlobs ?? DEFAULT_INCLUDE_GLOBS, options.excludeGlobs ?? DEFAULT_EXCLUDE_GLOBS);
|
|
20651
20805
|
const pattern = options.caseInsensitive ? pathPattern.toLowerCase() : pathPattern;
|
|
@@ -20787,7 +20941,7 @@ async function walkForFiles(rootDir, dir, excludeGlobs, results) {
|
|
|
20787
20941
|
continue;
|
|
20788
20942
|
if (excludeGlobs.some((g) => entry.name === g || matchesGlob(entry.name, g)))
|
|
20789
20943
|
continue;
|
|
20790
|
-
const absPath =
|
|
20944
|
+
const absPath = join40(dir, entry.name);
|
|
20791
20945
|
if (entry.isDirectory()) {
|
|
20792
20946
|
await walkForFiles(rootDir, absPath, excludeGlobs, results);
|
|
20793
20947
|
} else if (entry.isFile()) {
|
|
@@ -21094,7 +21248,7 @@ var init_graphExpand = __esm({
|
|
|
21094
21248
|
|
|
21095
21249
|
// packages/retrieval/dist/snippetPacker.js
|
|
21096
21250
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
21097
|
-
import { join as
|
|
21251
|
+
import { join as join41 } from "node:path";
|
|
21098
21252
|
async function packSnippets(requests, opts = {}) {
|
|
21099
21253
|
const maxTokens = opts.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
21100
21254
|
const contextLines = opts.contextLines ?? DEFAULT_CONTEXT_LINES;
|
|
@@ -21120,7 +21274,7 @@ async function packSnippets(requests, opts = {}) {
|
|
|
21120
21274
|
return { packed, dropped, totalTokens };
|
|
21121
21275
|
}
|
|
21122
21276
|
async function extractSnippet(req, repoRoot, contextLines = DEFAULT_CONTEXT_LINES) {
|
|
21123
|
-
const absPath = req.filePath.startsWith("/") ? req.filePath :
|
|
21277
|
+
const absPath = req.filePath.startsWith("/") ? req.filePath : join41(repoRoot, req.filePath);
|
|
21124
21278
|
let content;
|
|
21125
21279
|
try {
|
|
21126
21280
|
content = await readFile20(absPath, "utf-8");
|
|
@@ -23844,8 +23998,8 @@ ${marker}` : marker);
|
|
|
23844
23998
|
return;
|
|
23845
23999
|
try {
|
|
23846
24000
|
const { mkdirSync: mkdirSync22, writeFileSync: writeFileSync21 } = __require("node:fs");
|
|
23847
|
-
const { join:
|
|
23848
|
-
const sessionDir =
|
|
24001
|
+
const { join: join66 } = __require("node:path");
|
|
24002
|
+
const sessionDir = join66(this._workingDirectory, ".oa", "session", this._sessionId);
|
|
23849
24003
|
mkdirSync22(sessionDir, { recursive: true });
|
|
23850
24004
|
const checkpoint = {
|
|
23851
24005
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -23858,7 +24012,7 @@ ${marker}` : marker);
|
|
|
23858
24012
|
memexEntryCount: this._memexArchive.size,
|
|
23859
24013
|
fileRegistrySize: this._fileRegistry.size
|
|
23860
24014
|
};
|
|
23861
|
-
writeFileSync21(
|
|
24015
|
+
writeFileSync21(join66(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
23862
24016
|
} catch {
|
|
23863
24017
|
}
|
|
23864
24018
|
}
|
|
@@ -25165,9 +25319,9 @@ ${transcript}`
|
|
|
25165
25319
|
});
|
|
25166
25320
|
|
|
25167
25321
|
// packages/orchestrator/dist/nexusBackend.js
|
|
25168
|
-
import { existsSync as
|
|
25322
|
+
import { existsSync as existsSync27, statSync as statSync9, openSync, readSync, closeSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "node:fs";
|
|
25169
25323
|
import { watch as fsWatch } from "node:fs";
|
|
25170
|
-
import { join as
|
|
25324
|
+
import { join as join42 } from "node:path";
|
|
25171
25325
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
25172
25326
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
25173
25327
|
var NexusAgenticBackend;
|
|
@@ -25317,7 +25471,7 @@ var init_nexusBackend = __esm({
|
|
|
25317
25471
|
* Falls back to unary + word-split if streaming setup fails.
|
|
25318
25472
|
*/
|
|
25319
25473
|
async *chatCompletionStream(request) {
|
|
25320
|
-
const streamFile =
|
|
25474
|
+
const streamFile = join42(tmpdir7(), `nexus-stream-${randomBytes8(6).toString("hex")}.jsonl`);
|
|
25321
25475
|
writeFileSync8(streamFile, "", "utf8");
|
|
25322
25476
|
const daemonArgs = {
|
|
25323
25477
|
model: this.model,
|
|
@@ -26353,8 +26507,8 @@ __export(listen_exports, {
|
|
|
26353
26507
|
waitForTranscribeCli: () => waitForTranscribeCli
|
|
26354
26508
|
});
|
|
26355
26509
|
import { spawn as spawn15, execSync as execSync22 } from "node:child_process";
|
|
26356
|
-
import { existsSync as
|
|
26357
|
-
import { join as
|
|
26510
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readdirSync as readdirSync6 } from "node:fs";
|
|
26511
|
+
import { join as join43, dirname as dirname13 } from "node:path";
|
|
26358
26512
|
import { homedir as homedir8 } from "node:os";
|
|
26359
26513
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
26360
26514
|
import { EventEmitter } from "node:events";
|
|
@@ -26440,15 +26594,15 @@ function findMicCaptureCommand() {
|
|
|
26440
26594
|
function findLiveWhisperScript() {
|
|
26441
26595
|
const thisDir = dirname13(fileURLToPath8(import.meta.url));
|
|
26442
26596
|
const candidates = [
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26597
|
+
join43(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
|
|
26598
|
+
join43(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
|
|
26599
|
+
join43(thisDir, "../../execution/scripts/live-whisper.py"),
|
|
26446
26600
|
// npm install layout — scripts bundled alongside dist
|
|
26447
|
-
|
|
26448
|
-
|
|
26601
|
+
join43(thisDir, "../scripts/live-whisper.py"),
|
|
26602
|
+
join43(thisDir, "../../scripts/live-whisper.py")
|
|
26449
26603
|
];
|
|
26450
26604
|
for (const p of candidates) {
|
|
26451
|
-
if (
|
|
26605
|
+
if (existsSync28(p))
|
|
26452
26606
|
return p;
|
|
26453
26607
|
}
|
|
26454
26608
|
try {
|
|
@@ -26458,21 +26612,21 @@ function findLiveWhisperScript() {
|
|
|
26458
26612
|
stdio: ["pipe", "pipe", "pipe"]
|
|
26459
26613
|
}).trim();
|
|
26460
26614
|
const candidates2 = [
|
|
26461
|
-
|
|
26462
|
-
|
|
26615
|
+
join43(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
|
|
26616
|
+
join43(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
|
|
26463
26617
|
];
|
|
26464
26618
|
for (const p of candidates2) {
|
|
26465
|
-
if (
|
|
26619
|
+
if (existsSync28(p))
|
|
26466
26620
|
return p;
|
|
26467
26621
|
}
|
|
26468
26622
|
} catch {
|
|
26469
26623
|
}
|
|
26470
|
-
const nvmBase =
|
|
26471
|
-
if (
|
|
26624
|
+
const nvmBase = join43(homedir8(), ".nvm", "versions", "node");
|
|
26625
|
+
if (existsSync28(nvmBase)) {
|
|
26472
26626
|
try {
|
|
26473
26627
|
for (const ver of readdirSync6(nvmBase)) {
|
|
26474
|
-
const p =
|
|
26475
|
-
if (
|
|
26628
|
+
const p = join43(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
|
|
26629
|
+
if (existsSync28(p))
|
|
26476
26630
|
return p;
|
|
26477
26631
|
}
|
|
26478
26632
|
} catch {
|
|
@@ -26490,7 +26644,7 @@ function ensureTranscribeCliBackground() {
|
|
|
26490
26644
|
timeout: 5e3,
|
|
26491
26645
|
stdio: ["pipe", "pipe", "pipe"]
|
|
26492
26646
|
}).trim();
|
|
26493
|
-
if (
|
|
26647
|
+
if (existsSync28(join43(globalRoot, "transcribe-cli", "dist", "index.js"))) {
|
|
26494
26648
|
return true;
|
|
26495
26649
|
}
|
|
26496
26650
|
} catch {
|
|
@@ -26713,24 +26867,24 @@ var init_listen = __esm({
|
|
|
26713
26867
|
timeout: 5e3,
|
|
26714
26868
|
stdio: ["pipe", "pipe", "pipe"]
|
|
26715
26869
|
}).trim();
|
|
26716
|
-
const tcPath =
|
|
26717
|
-
if (
|
|
26870
|
+
const tcPath = join43(globalRoot, "transcribe-cli");
|
|
26871
|
+
if (existsSync28(join43(tcPath, "dist", "index.js"))) {
|
|
26718
26872
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
26719
26873
|
const req = createRequire4(import.meta.url);
|
|
26720
|
-
return req(
|
|
26874
|
+
return req(join43(tcPath, "dist", "index.js"));
|
|
26721
26875
|
}
|
|
26722
26876
|
} catch {
|
|
26723
26877
|
}
|
|
26724
|
-
const nvmBase =
|
|
26725
|
-
if (
|
|
26878
|
+
const nvmBase = join43(homedir8(), ".nvm", "versions", "node");
|
|
26879
|
+
if (existsSync28(nvmBase)) {
|
|
26726
26880
|
try {
|
|
26727
26881
|
const { readdirSync: readdirSync18 } = await import("node:fs");
|
|
26728
26882
|
for (const ver of readdirSync18(nvmBase)) {
|
|
26729
|
-
const tcPath =
|
|
26730
|
-
if (
|
|
26883
|
+
const tcPath = join43(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
|
|
26884
|
+
if (existsSync28(join43(tcPath, "dist", "index.js"))) {
|
|
26731
26885
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
26732
26886
|
const req = createRequire4(import.meta.url);
|
|
26733
|
-
return req(
|
|
26887
|
+
return req(join43(tcPath, "dist", "index.js"));
|
|
26734
26888
|
}
|
|
26735
26889
|
}
|
|
26736
26890
|
} catch {
|
|
@@ -27012,9 +27166,9 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
27012
27166
|
});
|
|
27013
27167
|
if (outputDir) {
|
|
27014
27168
|
const { basename: basename16 } = await import("node:path");
|
|
27015
|
-
const transcriptDir =
|
|
27169
|
+
const transcriptDir = join43(outputDir, ".oa", "transcripts");
|
|
27016
27170
|
mkdirSync8(transcriptDir, { recursive: true });
|
|
27017
|
-
const outFile =
|
|
27171
|
+
const outFile = join43(transcriptDir, `${basename16(filePath)}.txt`);
|
|
27018
27172
|
writeFileSync9(outFile, result.text, "utf-8");
|
|
27019
27173
|
}
|
|
27020
27174
|
return {
|
|
@@ -32251,8 +32405,8 @@ import { EventEmitter as EventEmitter3 } from "node:events";
|
|
|
32251
32405
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
32252
32406
|
import { URL as URL2 } from "node:url";
|
|
32253
32407
|
import { loadavg, cpus, totalmem, freemem } from "node:os";
|
|
32254
|
-
import { existsSync as
|
|
32255
|
-
import { join as
|
|
32408
|
+
import { existsSync as existsSync29, readFileSync as readFileSync20, writeFileSync as writeFileSync10, unlinkSync as unlinkSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync7, statSync as statSync10 } from "node:fs";
|
|
32409
|
+
import { join as join44 } from "node:path";
|
|
32256
32410
|
function cleanForwardHeaders(raw, targetHost) {
|
|
32257
32411
|
const out = {};
|
|
32258
32412
|
for (const [key, value] of Object.entries(raw)) {
|
|
@@ -32280,10 +32434,10 @@ function fmtTokens(n) {
|
|
|
32280
32434
|
}
|
|
32281
32435
|
function readExposeState(stateDir) {
|
|
32282
32436
|
try {
|
|
32283
|
-
const path =
|
|
32284
|
-
if (!
|
|
32437
|
+
const path = join44(stateDir, STATE_FILE_NAME);
|
|
32438
|
+
if (!existsSync29(path))
|
|
32285
32439
|
return null;
|
|
32286
|
-
const raw =
|
|
32440
|
+
const raw = readFileSync20(path, "utf8");
|
|
32287
32441
|
const data = JSON.parse(raw);
|
|
32288
32442
|
if (!data.pid || !data.tunnelUrl || !data.authKey || !data.proxyPort)
|
|
32289
32443
|
return null;
|
|
@@ -32295,13 +32449,13 @@ function readExposeState(stateDir) {
|
|
|
32295
32449
|
function writeExposeState(stateDir, state) {
|
|
32296
32450
|
try {
|
|
32297
32451
|
mkdirSync9(stateDir, { recursive: true });
|
|
32298
|
-
writeFileSync10(
|
|
32452
|
+
writeFileSync10(join44(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
32299
32453
|
} catch {
|
|
32300
32454
|
}
|
|
32301
32455
|
}
|
|
32302
32456
|
function removeExposeState(stateDir) {
|
|
32303
32457
|
try {
|
|
32304
|
-
unlinkSync5(
|
|
32458
|
+
unlinkSync5(join44(stateDir, STATE_FILE_NAME));
|
|
32305
32459
|
} catch {
|
|
32306
32460
|
}
|
|
32307
32461
|
}
|
|
@@ -32390,10 +32544,10 @@ async function collectSystemMetricsAsync() {
|
|
|
32390
32544
|
}
|
|
32391
32545
|
function readP2PExposeState(stateDir) {
|
|
32392
32546
|
try {
|
|
32393
|
-
const path =
|
|
32394
|
-
if (!
|
|
32547
|
+
const path = join44(stateDir, P2P_STATE_FILE_NAME);
|
|
32548
|
+
if (!existsSync29(path))
|
|
32395
32549
|
return null;
|
|
32396
|
-
const raw =
|
|
32550
|
+
const raw = readFileSync20(path, "utf8");
|
|
32397
32551
|
const data = JSON.parse(raw);
|
|
32398
32552
|
if (!data.peerId || !data.authKey)
|
|
32399
32553
|
return null;
|
|
@@ -32405,13 +32559,13 @@ function readP2PExposeState(stateDir) {
|
|
|
32405
32559
|
function writeP2PExposeState(stateDir, state) {
|
|
32406
32560
|
try {
|
|
32407
32561
|
mkdirSync9(stateDir, { recursive: true });
|
|
32408
|
-
writeFileSync10(
|
|
32562
|
+
writeFileSync10(join44(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
32409
32563
|
} catch {
|
|
32410
32564
|
}
|
|
32411
32565
|
}
|
|
32412
32566
|
function removeP2PExposeState(stateDir) {
|
|
32413
32567
|
try {
|
|
32414
|
-
unlinkSync5(
|
|
32568
|
+
unlinkSync5(join44(stateDir, P2P_STATE_FILE_NAME));
|
|
32415
32569
|
} catch {
|
|
32416
32570
|
}
|
|
32417
32571
|
}
|
|
@@ -33259,10 +33413,10 @@ ${this.formatConnectionInfo()}`);
|
|
|
33259
33413
|
throw new Error(`Expose failed: ${exposeResult.error}`);
|
|
33260
33414
|
}
|
|
33261
33415
|
const nexusDir = this._nexusTool.getNexusDir();
|
|
33262
|
-
const statusPath =
|
|
33416
|
+
const statusPath = join44(nexusDir, "status.json");
|
|
33263
33417
|
for (let i = 0; i < 80; i++) {
|
|
33264
33418
|
try {
|
|
33265
|
-
const raw =
|
|
33419
|
+
const raw = readFileSync20(statusPath, "utf8");
|
|
33266
33420
|
if (raw.length > 10) {
|
|
33267
33421
|
const status = JSON.parse(raw);
|
|
33268
33422
|
if (status.connected && status.peerId) {
|
|
@@ -33293,8 +33447,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
33293
33447
|
});
|
|
33294
33448
|
}
|
|
33295
33449
|
try {
|
|
33296
|
-
const invocDir =
|
|
33297
|
-
if (
|
|
33450
|
+
const invocDir = join44(nexusDir, "invocations");
|
|
33451
|
+
if (existsSync29(invocDir)) {
|
|
33298
33452
|
this._prevInvocCount = readdirSync7(invocDir).filter((f) => f.endsWith(".json")).length;
|
|
33299
33453
|
this._stats.totalRequests = this._prevInvocCount;
|
|
33300
33454
|
}
|
|
@@ -33323,13 +33477,13 @@ ${this.formatConnectionInfo()}`);
|
|
|
33323
33477
|
if (!state)
|
|
33324
33478
|
return null;
|
|
33325
33479
|
const nexusDir = nexusTool.getNexusDir();
|
|
33326
|
-
const statusPath =
|
|
33480
|
+
const statusPath = join44(nexusDir, "status.json");
|
|
33327
33481
|
try {
|
|
33328
|
-
if (!
|
|
33482
|
+
if (!existsSync29(statusPath)) {
|
|
33329
33483
|
removeP2PExposeState(stateDir);
|
|
33330
33484
|
return null;
|
|
33331
33485
|
}
|
|
33332
|
-
const status = JSON.parse(
|
|
33486
|
+
const status = JSON.parse(readFileSync20(statusPath, "utf8"));
|
|
33333
33487
|
if (!status.connected || !status.peerId) {
|
|
33334
33488
|
removeP2PExposeState(stateDir);
|
|
33335
33489
|
return null;
|
|
@@ -33382,8 +33536,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
33382
33536
|
let lastMeteringLineCount = 0;
|
|
33383
33537
|
this._activityPollTimer = setInterval(() => {
|
|
33384
33538
|
try {
|
|
33385
|
-
const invocDir =
|
|
33386
|
-
if (!
|
|
33539
|
+
const invocDir = join44(nexusDir, "invocations");
|
|
33540
|
+
if (!existsSync29(invocDir))
|
|
33387
33541
|
return;
|
|
33388
33542
|
const files = readdirSync7(invocDir).filter((f) => f.endsWith(".json"));
|
|
33389
33543
|
const invocCount = files.length;
|
|
@@ -33398,17 +33552,17 @@ ${this.formatConnectionInfo()}`);
|
|
|
33398
33552
|
let recentActive = 0;
|
|
33399
33553
|
for (const f of files.slice(-10)) {
|
|
33400
33554
|
try {
|
|
33401
|
-
const st = statSync10(
|
|
33555
|
+
const st = statSync10(join44(invocDir, f));
|
|
33402
33556
|
if (now - st.mtimeMs < 1e4)
|
|
33403
33557
|
recentActive++;
|
|
33404
33558
|
} catch {
|
|
33405
33559
|
}
|
|
33406
33560
|
}
|
|
33407
|
-
const meteringFile =
|
|
33561
|
+
const meteringFile = join44(nexusDir, "metering.jsonl");
|
|
33408
33562
|
let meteringLines = lastMeteringLineCount;
|
|
33409
33563
|
try {
|
|
33410
|
-
if (
|
|
33411
|
-
const content =
|
|
33564
|
+
if (existsSync29(meteringFile)) {
|
|
33565
|
+
const content = readFileSync20(meteringFile, "utf8");
|
|
33412
33566
|
meteringLines = content.split("\n").filter((l) => l.trim()).length;
|
|
33413
33567
|
}
|
|
33414
33568
|
} catch {
|
|
@@ -33434,9 +33588,9 @@ ${this.formatConnectionInfo()}`);
|
|
|
33434
33588
|
this._activityPollTimer.unref();
|
|
33435
33589
|
this._pollTimer = setInterval(() => {
|
|
33436
33590
|
try {
|
|
33437
|
-
const statusPath =
|
|
33438
|
-
if (
|
|
33439
|
-
const status = JSON.parse(
|
|
33591
|
+
const statusPath = join44(nexusDir, "status.json");
|
|
33592
|
+
if (existsSync29(statusPath)) {
|
|
33593
|
+
const status = JSON.parse(readFileSync20(statusPath, "utf8"));
|
|
33440
33594
|
if (status.peerId && !this._peerId) {
|
|
33441
33595
|
this._peerId = status.peerId;
|
|
33442
33596
|
}
|
|
@@ -33445,8 +33599,8 @@ ${this.formatConnectionInfo()}`);
|
|
|
33445
33599
|
} catch {
|
|
33446
33600
|
}
|
|
33447
33601
|
try {
|
|
33448
|
-
const invocDir =
|
|
33449
|
-
if (
|
|
33602
|
+
const invocDir = join44(nexusDir, "invocations");
|
|
33603
|
+
if (existsSync29(invocDir)) {
|
|
33450
33604
|
const files = readdirSync7(invocDir);
|
|
33451
33605
|
const invocCount = files.filter((f) => f.endsWith(".json")).length;
|
|
33452
33606
|
if (invocCount > this._stats.totalRequests) {
|
|
@@ -33457,9 +33611,9 @@ ${this.formatConnectionInfo()}`);
|
|
|
33457
33611
|
} catch {
|
|
33458
33612
|
}
|
|
33459
33613
|
try {
|
|
33460
|
-
const meteringFile =
|
|
33461
|
-
if (
|
|
33462
|
-
const content =
|
|
33614
|
+
const meteringFile = join44(nexusDir, "metering.jsonl");
|
|
33615
|
+
if (existsSync29(meteringFile)) {
|
|
33616
|
+
const content = readFileSync20(meteringFile, "utf8");
|
|
33463
33617
|
if (content.length > lastMeteringSize) {
|
|
33464
33618
|
const newContent = content.slice(lastMeteringSize);
|
|
33465
33619
|
lastMeteringSize = content.length;
|
|
@@ -33668,8 +33822,8 @@ var init_types = __esm({
|
|
|
33668
33822
|
|
|
33669
33823
|
// packages/cli/dist/tui/p2p/secret-vault.js
|
|
33670
33824
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes10, scryptSync as scryptSync2, createHash as createHash2 } from "node:crypto";
|
|
33671
|
-
import { readFileSync as
|
|
33672
|
-
import { join as
|
|
33825
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync11, existsSync as existsSync30, mkdirSync as mkdirSync10 } from "node:fs";
|
|
33826
|
+
import { join as join45, dirname as dirname14 } from "node:path";
|
|
33673
33827
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
33674
33828
|
var init_secret_vault = __esm({
|
|
33675
33829
|
"packages/cli/dist/tui/p2p/secret-vault.js"() {
|
|
@@ -33881,7 +34035,7 @@ var init_secret_vault = __esm({
|
|
|
33881
34035
|
const tag = cipher.getAuthTag();
|
|
33882
34036
|
const blob = Buffer.concat([salt, iv, tag, encrypted]);
|
|
33883
34037
|
const dir = dirname14(this.storePath);
|
|
33884
|
-
if (!
|
|
34038
|
+
if (!existsSync30(dir))
|
|
33885
34039
|
mkdirSync10(dir, { recursive: true });
|
|
33886
34040
|
writeFileSync11(this.storePath, blob, { mode: 384 });
|
|
33887
34041
|
}
|
|
@@ -33890,9 +34044,9 @@ var init_secret_vault = __esm({
|
|
|
33890
34044
|
* Returns the number of secrets loaded.
|
|
33891
34045
|
*/
|
|
33892
34046
|
load(passphrase) {
|
|
33893
|
-
if (!this.storePath || !
|
|
34047
|
+
if (!this.storePath || !existsSync30(this.storePath))
|
|
33894
34048
|
return 0;
|
|
33895
|
-
const blob =
|
|
34049
|
+
const blob = readFileSync21(this.storePath);
|
|
33896
34050
|
if (blob.length < SALT_LEN + IV_LEN + 16) {
|
|
33897
34051
|
throw new Error("Vault file is corrupted (too small)");
|
|
33898
34052
|
}
|
|
@@ -35013,26 +35167,26 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
|
|
|
35013
35167
|
async function fetchPeerModels(peerId, authKey) {
|
|
35014
35168
|
try {
|
|
35015
35169
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
35016
|
-
const { existsSync:
|
|
35017
|
-
const { join:
|
|
35170
|
+
const { existsSync: existsSync47, readFileSync: readFileSync35 } = await import("node:fs");
|
|
35171
|
+
const { join: join66 } = await import("node:path");
|
|
35018
35172
|
const cwd4 = process.cwd();
|
|
35019
35173
|
const nexusTool = new NexusTool2(cwd4);
|
|
35020
35174
|
const nexusDir = nexusTool.getNexusDir();
|
|
35021
35175
|
let isLocalPeer = false;
|
|
35022
35176
|
try {
|
|
35023
|
-
const statusPath =
|
|
35024
|
-
if (
|
|
35025
|
-
const status = JSON.parse(
|
|
35177
|
+
const statusPath = join66(nexusDir, "status.json");
|
|
35178
|
+
if (existsSync47(statusPath)) {
|
|
35179
|
+
const status = JSON.parse(readFileSync35(statusPath, "utf8"));
|
|
35026
35180
|
if (status.peerId === peerId)
|
|
35027
35181
|
isLocalPeer = true;
|
|
35028
35182
|
}
|
|
35029
35183
|
} catch {
|
|
35030
35184
|
}
|
|
35031
35185
|
if (isLocalPeer) {
|
|
35032
|
-
const pricingPath =
|
|
35033
|
-
if (
|
|
35186
|
+
const pricingPath = join66(nexusDir, "pricing.json");
|
|
35187
|
+
if (existsSync47(pricingPath)) {
|
|
35034
35188
|
try {
|
|
35035
|
-
const pricing = JSON.parse(
|
|
35189
|
+
const pricing = JSON.parse(readFileSync35(pricingPath, "utf8"));
|
|
35036
35190
|
const localModels = (pricing.models || []).map((m) => ({
|
|
35037
35191
|
name: m.model || "unknown",
|
|
35038
35192
|
size: m.parameterSize || "",
|
|
@@ -35046,10 +35200,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
35046
35200
|
}
|
|
35047
35201
|
}
|
|
35048
35202
|
}
|
|
35049
|
-
const cachePath =
|
|
35050
|
-
if (
|
|
35203
|
+
const cachePath = join66(nexusDir, "peer-models-cache.json");
|
|
35204
|
+
if (existsSync47(cachePath)) {
|
|
35051
35205
|
try {
|
|
35052
|
-
const cache4 = JSON.parse(
|
|
35206
|
+
const cache4 = JSON.parse(readFileSync35(cachePath, "utf8"));
|
|
35053
35207
|
if (cache4.peerId === peerId && cache4.models?.length > 0) {
|
|
35054
35208
|
const age = Date.now() - new Date(cache4.cachedAt).getTime();
|
|
35055
35209
|
if (age < 5 * 60 * 1e3) {
|
|
@@ -35164,10 +35318,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
35164
35318
|
} catch {
|
|
35165
35319
|
}
|
|
35166
35320
|
if (isLocalPeer) {
|
|
35167
|
-
const pricingPath =
|
|
35168
|
-
if (
|
|
35321
|
+
const pricingPath = join66(nexusDir, "pricing.json");
|
|
35322
|
+
if (existsSync47(pricingPath)) {
|
|
35169
35323
|
try {
|
|
35170
|
-
const pricing = JSON.parse(
|
|
35324
|
+
const pricing = JSON.parse(readFileSync35(pricingPath, "utf8"));
|
|
35171
35325
|
return (pricing.models || []).map((m) => ({
|
|
35172
35326
|
name: m.model || "unknown",
|
|
35173
35327
|
size: m.parameterSize || "",
|
|
@@ -35447,17 +35601,17 @@ var init_render2 = __esm({
|
|
|
35447
35601
|
});
|
|
35448
35602
|
|
|
35449
35603
|
// packages/prompts/dist/promptLoader.js
|
|
35450
|
-
import { readFileSync as
|
|
35451
|
-
import { join as
|
|
35604
|
+
import { readFileSync as readFileSync22, existsSync as existsSync31 } from "node:fs";
|
|
35605
|
+
import { join as join46, dirname as dirname15 } from "node:path";
|
|
35452
35606
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
35453
35607
|
function loadPrompt2(promptPath, vars) {
|
|
35454
35608
|
let content = cache2.get(promptPath);
|
|
35455
35609
|
if (content === void 0) {
|
|
35456
|
-
const fullPath =
|
|
35457
|
-
if (!
|
|
35610
|
+
const fullPath = join46(PROMPTS_DIR2, promptPath);
|
|
35611
|
+
if (!existsSync31(fullPath)) {
|
|
35458
35612
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
35459
35613
|
}
|
|
35460
|
-
content =
|
|
35614
|
+
content = readFileSync22(fullPath, "utf-8");
|
|
35461
35615
|
cache2.set(promptPath, content);
|
|
35462
35616
|
}
|
|
35463
35617
|
if (!vars)
|
|
@@ -35470,9 +35624,9 @@ var init_promptLoader2 = __esm({
|
|
|
35470
35624
|
"use strict";
|
|
35471
35625
|
__filename2 = fileURLToPath9(import.meta.url);
|
|
35472
35626
|
__dirname5 = dirname15(__filename2);
|
|
35473
|
-
devPath =
|
|
35474
|
-
publishedPath =
|
|
35475
|
-
PROMPTS_DIR2 =
|
|
35627
|
+
devPath = join46(__dirname5, "..", "templates");
|
|
35628
|
+
publishedPath = join46(__dirname5, "..", "prompts", "templates");
|
|
35629
|
+
PROMPTS_DIR2 = existsSync31(devPath) ? devPath : publishedPath;
|
|
35476
35630
|
cache2 = /* @__PURE__ */ new Map();
|
|
35477
35631
|
}
|
|
35478
35632
|
});
|
|
@@ -35583,7 +35737,7 @@ var init_task_templates = __esm({
|
|
|
35583
35737
|
});
|
|
35584
35738
|
|
|
35585
35739
|
// packages/prompts/dist/index.js
|
|
35586
|
-
import { join as
|
|
35740
|
+
import { join as join47, dirname as dirname16 } from "node:path";
|
|
35587
35741
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
35588
35742
|
var _dir, _packageRoot;
|
|
35589
35743
|
var init_dist6 = __esm({
|
|
@@ -35594,7 +35748,7 @@ var init_dist6 = __esm({
|
|
|
35594
35748
|
init_task_templates();
|
|
35595
35749
|
init_render2();
|
|
35596
35750
|
_dir = dirname16(fileURLToPath10(import.meta.url));
|
|
35597
|
-
_packageRoot =
|
|
35751
|
+
_packageRoot = join47(_dir, "..");
|
|
35598
35752
|
}
|
|
35599
35753
|
});
|
|
35600
35754
|
|
|
@@ -35627,19 +35781,19 @@ __export(oa_directory_exports, {
|
|
|
35627
35781
|
writeIndexData: () => writeIndexData,
|
|
35628
35782
|
writeIndexMeta: () => writeIndexMeta
|
|
35629
35783
|
});
|
|
35630
|
-
import { existsSync as
|
|
35631
|
-
import { join as
|
|
35784
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync11, readFileSync as readFileSync23, writeFileSync as writeFileSync12, readdirSync as readdirSync8, statSync as statSync11, unlinkSync as unlinkSync6 } from "node:fs";
|
|
35785
|
+
import { join as join48, relative as relative2, basename as basename9, extname as extname8 } from "node:path";
|
|
35632
35786
|
import { homedir as homedir9 } from "node:os";
|
|
35633
35787
|
function initOaDirectory(repoRoot) {
|
|
35634
|
-
const oaPath =
|
|
35788
|
+
const oaPath = join48(repoRoot, OA_DIR);
|
|
35635
35789
|
for (const sub of SUBDIRS) {
|
|
35636
|
-
mkdirSync11(
|
|
35790
|
+
mkdirSync11(join48(oaPath, sub), { recursive: true });
|
|
35637
35791
|
}
|
|
35638
35792
|
try {
|
|
35639
|
-
const gitignorePath =
|
|
35793
|
+
const gitignorePath = join48(repoRoot, ".gitignore");
|
|
35640
35794
|
const settingsPattern = ".oa/settings.json";
|
|
35641
|
-
if (
|
|
35642
|
-
const content =
|
|
35795
|
+
if (existsSync32(gitignorePath)) {
|
|
35796
|
+
const content = readFileSync23(gitignorePath, "utf-8");
|
|
35643
35797
|
if (!content.includes(settingsPattern)) {
|
|
35644
35798
|
writeFileSync12(gitignorePath, content.trimEnd() + "\n" + settingsPattern + "\n", "utf-8");
|
|
35645
35799
|
}
|
|
@@ -35649,41 +35803,41 @@ function initOaDirectory(repoRoot) {
|
|
|
35649
35803
|
return oaPath;
|
|
35650
35804
|
}
|
|
35651
35805
|
function hasOaDirectory(repoRoot) {
|
|
35652
|
-
return
|
|
35806
|
+
return existsSync32(join48(repoRoot, OA_DIR, "index"));
|
|
35653
35807
|
}
|
|
35654
35808
|
function loadProjectSettings(repoRoot) {
|
|
35655
|
-
const settingsPath =
|
|
35809
|
+
const settingsPath = join48(repoRoot, OA_DIR, "settings.json");
|
|
35656
35810
|
try {
|
|
35657
|
-
if (
|
|
35658
|
-
return JSON.parse(
|
|
35811
|
+
if (existsSync32(settingsPath)) {
|
|
35812
|
+
return JSON.parse(readFileSync23(settingsPath, "utf-8"));
|
|
35659
35813
|
}
|
|
35660
35814
|
} catch {
|
|
35661
35815
|
}
|
|
35662
35816
|
return {};
|
|
35663
35817
|
}
|
|
35664
35818
|
function saveProjectSettings(repoRoot, settings) {
|
|
35665
|
-
const oaPath =
|
|
35819
|
+
const oaPath = join48(repoRoot, OA_DIR);
|
|
35666
35820
|
mkdirSync11(oaPath, { recursive: true });
|
|
35667
35821
|
const existing = loadProjectSettings(repoRoot);
|
|
35668
35822
|
const merged = { ...existing, ...settings };
|
|
35669
|
-
writeFileSync12(
|
|
35823
|
+
writeFileSync12(join48(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
35670
35824
|
}
|
|
35671
35825
|
function loadGlobalSettings() {
|
|
35672
|
-
const settingsPath =
|
|
35826
|
+
const settingsPath = join48(homedir9(), ".open-agents", "settings.json");
|
|
35673
35827
|
try {
|
|
35674
|
-
if (
|
|
35675
|
-
return JSON.parse(
|
|
35828
|
+
if (existsSync32(settingsPath)) {
|
|
35829
|
+
return JSON.parse(readFileSync23(settingsPath, "utf-8"));
|
|
35676
35830
|
}
|
|
35677
35831
|
} catch {
|
|
35678
35832
|
}
|
|
35679
35833
|
return {};
|
|
35680
35834
|
}
|
|
35681
35835
|
function saveGlobalSettings(settings) {
|
|
35682
|
-
const dir =
|
|
35836
|
+
const dir = join48(homedir9(), ".open-agents");
|
|
35683
35837
|
mkdirSync11(dir, { recursive: true });
|
|
35684
35838
|
const existing = loadGlobalSettings();
|
|
35685
35839
|
const merged = { ...existing, ...settings };
|
|
35686
|
-
writeFileSync12(
|
|
35840
|
+
writeFileSync12(join48(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
35687
35841
|
}
|
|
35688
35842
|
function resolveSettings(repoRoot) {
|
|
35689
35843
|
const global = loadGlobalSettings();
|
|
@@ -35698,12 +35852,12 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
35698
35852
|
while (dir && !visited.has(dir)) {
|
|
35699
35853
|
visited.add(dir);
|
|
35700
35854
|
for (const name of CONTEXT_FILES) {
|
|
35701
|
-
const filePath =
|
|
35855
|
+
const filePath = join48(dir, name);
|
|
35702
35856
|
const normalizedName = name.toLowerCase();
|
|
35703
|
-
if (
|
|
35857
|
+
if (existsSync32(filePath) && !seen.has(filePath)) {
|
|
35704
35858
|
seen.add(filePath);
|
|
35705
35859
|
try {
|
|
35706
|
-
let content =
|
|
35860
|
+
let content = readFileSync23(filePath, "utf-8");
|
|
35707
35861
|
if (content.length > maxContentLen) {
|
|
35708
35862
|
content = content.slice(0, maxContentLen) + "\n\n...(truncated)";
|
|
35709
35863
|
}
|
|
@@ -35717,11 +35871,11 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
35717
35871
|
}
|
|
35718
35872
|
}
|
|
35719
35873
|
}
|
|
35720
|
-
const projectMap =
|
|
35721
|
-
if (
|
|
35874
|
+
const projectMap = join48(dir, OA_DIR, "context", "project-map.md");
|
|
35875
|
+
if (existsSync32(projectMap) && !seen.has(projectMap)) {
|
|
35722
35876
|
seen.add(projectMap);
|
|
35723
35877
|
try {
|
|
35724
|
-
let content =
|
|
35878
|
+
let content = readFileSync23(projectMap, "utf-8");
|
|
35725
35879
|
if (content.length > maxContentLen) {
|
|
35726
35880
|
content = content.slice(0, maxContentLen) + "\n\n...(truncated)";
|
|
35727
35881
|
}
|
|
@@ -35733,7 +35887,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
35733
35887
|
} catch {
|
|
35734
35888
|
}
|
|
35735
35889
|
}
|
|
35736
|
-
const parent =
|
|
35890
|
+
const parent = join48(dir, "..");
|
|
35737
35891
|
if (parent === dir)
|
|
35738
35892
|
break;
|
|
35739
35893
|
dir = parent;
|
|
@@ -35751,29 +35905,29 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
35751
35905
|
return found;
|
|
35752
35906
|
}
|
|
35753
35907
|
function readIndexMeta(repoRoot) {
|
|
35754
|
-
const metaPath =
|
|
35908
|
+
const metaPath = join48(repoRoot, OA_DIR, "index", "meta.json");
|
|
35755
35909
|
try {
|
|
35756
|
-
return JSON.parse(
|
|
35910
|
+
return JSON.parse(readFileSync23(metaPath, "utf-8"));
|
|
35757
35911
|
} catch {
|
|
35758
35912
|
return null;
|
|
35759
35913
|
}
|
|
35760
35914
|
}
|
|
35761
35915
|
function writeIndexMeta(repoRoot, meta) {
|
|
35762
|
-
const metaPath =
|
|
35763
|
-
mkdirSync11(
|
|
35916
|
+
const metaPath = join48(repoRoot, OA_DIR, "index", "meta.json");
|
|
35917
|
+
mkdirSync11(join48(repoRoot, OA_DIR, "index"), { recursive: true });
|
|
35764
35918
|
writeFileSync12(metaPath, JSON.stringify(meta, null, 2), "utf-8");
|
|
35765
35919
|
}
|
|
35766
35920
|
function readIndexData(repoRoot, filename) {
|
|
35767
|
-
const filePath =
|
|
35921
|
+
const filePath = join48(repoRoot, OA_DIR, "index", filename);
|
|
35768
35922
|
try {
|
|
35769
|
-
return JSON.parse(
|
|
35923
|
+
return JSON.parse(readFileSync23(filePath, "utf-8"));
|
|
35770
35924
|
} catch {
|
|
35771
35925
|
return null;
|
|
35772
35926
|
}
|
|
35773
35927
|
}
|
|
35774
35928
|
function writeIndexData(repoRoot, filename, data) {
|
|
35775
|
-
const filePath =
|
|
35776
|
-
mkdirSync11(
|
|
35929
|
+
const filePath = join48(repoRoot, OA_DIR, "index", filename);
|
|
35930
|
+
mkdirSync11(join48(repoRoot, OA_DIR, "index"), { recursive: true });
|
|
35777
35931
|
writeFileSync12(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
35778
35932
|
}
|
|
35779
35933
|
function generateProjectMap(repoRoot) {
|
|
@@ -35822,28 +35976,28 @@ ${tree}\`\`\`
|
|
|
35822
35976
|
sections.push("");
|
|
35823
35977
|
}
|
|
35824
35978
|
const content = sections.join("\n");
|
|
35825
|
-
const contextDir =
|
|
35979
|
+
const contextDir = join48(repoRoot, OA_DIR, "context");
|
|
35826
35980
|
mkdirSync11(contextDir, { recursive: true });
|
|
35827
|
-
writeFileSync12(
|
|
35981
|
+
writeFileSync12(join48(contextDir, "project-map.md"), content, "utf-8");
|
|
35828
35982
|
return content;
|
|
35829
35983
|
}
|
|
35830
35984
|
function saveSession(repoRoot, session) {
|
|
35831
|
-
const historyDir =
|
|
35985
|
+
const historyDir = join48(repoRoot, OA_DIR, "history");
|
|
35832
35986
|
mkdirSync11(historyDir, { recursive: true });
|
|
35833
|
-
writeFileSync12(
|
|
35987
|
+
writeFileSync12(join48(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
|
|
35834
35988
|
}
|
|
35835
35989
|
function loadRecentSessions(repoRoot, limit = 5) {
|
|
35836
|
-
const historyDir =
|
|
35837
|
-
if (!
|
|
35990
|
+
const historyDir = join48(repoRoot, OA_DIR, "history");
|
|
35991
|
+
if (!existsSync32(historyDir))
|
|
35838
35992
|
return [];
|
|
35839
35993
|
try {
|
|
35840
35994
|
const files = readdirSync8(historyDir).filter((f) => f.endsWith(".json") && f !== "pending-task.json").map((f) => {
|
|
35841
|
-
const stat5 = statSync11(
|
|
35995
|
+
const stat5 = statSync11(join48(historyDir, f));
|
|
35842
35996
|
return { file: f, mtime: stat5.mtimeMs };
|
|
35843
35997
|
}).sort((a, b) => b.mtime - a.mtime).slice(0, limit);
|
|
35844
35998
|
return files.map((f) => {
|
|
35845
35999
|
try {
|
|
35846
|
-
return JSON.parse(
|
|
36000
|
+
return JSON.parse(readFileSync23(join48(historyDir, f.file), "utf-8"));
|
|
35847
36001
|
} catch {
|
|
35848
36002
|
return null;
|
|
35849
36003
|
}
|
|
@@ -35853,16 +36007,16 @@ function loadRecentSessions(repoRoot, limit = 5) {
|
|
|
35853
36007
|
}
|
|
35854
36008
|
}
|
|
35855
36009
|
function savePendingTask(repoRoot, task) {
|
|
35856
|
-
const historyDir =
|
|
36010
|
+
const historyDir = join48(repoRoot, OA_DIR, "history");
|
|
35857
36011
|
mkdirSync11(historyDir, { recursive: true });
|
|
35858
|
-
writeFileSync12(
|
|
36012
|
+
writeFileSync12(join48(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
|
|
35859
36013
|
}
|
|
35860
36014
|
function loadPendingTask(repoRoot) {
|
|
35861
|
-
const filePath =
|
|
36015
|
+
const filePath = join48(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
|
|
35862
36016
|
try {
|
|
35863
|
-
if (!
|
|
36017
|
+
if (!existsSync32(filePath))
|
|
35864
36018
|
return null;
|
|
35865
|
-
const data = JSON.parse(
|
|
36019
|
+
const data = JSON.parse(readFileSync23(filePath, "utf-8"));
|
|
35866
36020
|
try {
|
|
35867
36021
|
unlinkSync6(filePath);
|
|
35868
36022
|
} catch {
|
|
@@ -35873,13 +36027,13 @@ function loadPendingTask(repoRoot) {
|
|
|
35873
36027
|
}
|
|
35874
36028
|
}
|
|
35875
36029
|
function saveSessionContext(repoRoot, entry) {
|
|
35876
|
-
const contextDir =
|
|
36030
|
+
const contextDir = join48(repoRoot, OA_DIR, "context");
|
|
35877
36031
|
mkdirSync11(contextDir, { recursive: true });
|
|
35878
|
-
const filePath =
|
|
36032
|
+
const filePath = join48(contextDir, CONTEXT_SAVE_FILE);
|
|
35879
36033
|
let ctx;
|
|
35880
36034
|
try {
|
|
35881
|
-
if (
|
|
35882
|
-
ctx = JSON.parse(
|
|
36035
|
+
if (existsSync32(filePath)) {
|
|
36036
|
+
ctx = JSON.parse(readFileSync23(filePath, "utf-8"));
|
|
35883
36037
|
} else {
|
|
35884
36038
|
ctx = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
|
|
35885
36039
|
}
|
|
@@ -35894,11 +36048,11 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
35894
36048
|
writeFileSync12(filePath, JSON.stringify(ctx, null, 2) + "\n", "utf-8");
|
|
35895
36049
|
}
|
|
35896
36050
|
function loadSessionContext(repoRoot) {
|
|
35897
|
-
const filePath =
|
|
36051
|
+
const filePath = join48(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
|
|
35898
36052
|
try {
|
|
35899
|
-
if (!
|
|
36053
|
+
if (!existsSync32(filePath))
|
|
35900
36054
|
return null;
|
|
35901
|
-
return JSON.parse(
|
|
36055
|
+
return JSON.parse(readFileSync23(filePath, "utf-8"));
|
|
35902
36056
|
} catch {
|
|
35903
36057
|
return null;
|
|
35904
36058
|
}
|
|
@@ -35944,12 +36098,12 @@ function detectManifests(repoRoot) {
|
|
|
35944
36098
|
{ file: "docker-compose.yaml", type: "Docker Compose" }
|
|
35945
36099
|
];
|
|
35946
36100
|
for (const check of checks) {
|
|
35947
|
-
const filePath =
|
|
35948
|
-
if (
|
|
36101
|
+
const filePath = join48(repoRoot, check.file);
|
|
36102
|
+
if (existsSync32(filePath)) {
|
|
35949
36103
|
let name;
|
|
35950
36104
|
if (check.nameField) {
|
|
35951
36105
|
try {
|
|
35952
|
-
const data = JSON.parse(
|
|
36106
|
+
const data = JSON.parse(readFileSync23(filePath, "utf-8"));
|
|
35953
36107
|
name = data[check.nameField];
|
|
35954
36108
|
} catch {
|
|
35955
36109
|
}
|
|
@@ -35978,7 +36132,7 @@ function findKeyFiles(repoRoot) {
|
|
|
35978
36132
|
{ pattern: "CLAUDE.md", description: "Claude Code context" }
|
|
35979
36133
|
];
|
|
35980
36134
|
for (const check of checks) {
|
|
35981
|
-
if (
|
|
36135
|
+
if (existsSync32(join48(repoRoot, check.pattern))) {
|
|
35982
36136
|
keyFiles.push({ path: check.pattern, description: check.description });
|
|
35983
36137
|
}
|
|
35984
36138
|
}
|
|
@@ -36004,12 +36158,12 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
36004
36158
|
if (entry.isDirectory()) {
|
|
36005
36159
|
let fileCount = 0;
|
|
36006
36160
|
try {
|
|
36007
|
-
fileCount = readdirSync8(
|
|
36161
|
+
fileCount = readdirSync8(join48(root, entry.name)).filter((f) => !f.startsWith(".")).length;
|
|
36008
36162
|
} catch {
|
|
36009
36163
|
}
|
|
36010
36164
|
result += `${prefix}${connector}${entry.name}/ (${fileCount})
|
|
36011
36165
|
`;
|
|
36012
|
-
result += buildDirTree(
|
|
36166
|
+
result += buildDirTree(join48(root, entry.name), maxDepth, childPrefix, depth + 1);
|
|
36013
36167
|
} else if (depth < maxDepth) {
|
|
36014
36168
|
result += `${prefix}${connector}${entry.name}
|
|
36015
36169
|
`;
|
|
@@ -36021,15 +36175,15 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
36021
36175
|
}
|
|
36022
36176
|
function loadUsageFile(filePath) {
|
|
36023
36177
|
try {
|
|
36024
|
-
if (
|
|
36025
|
-
return JSON.parse(
|
|
36178
|
+
if (existsSync32(filePath)) {
|
|
36179
|
+
return JSON.parse(readFileSync23(filePath, "utf-8"));
|
|
36026
36180
|
}
|
|
36027
36181
|
} catch {
|
|
36028
36182
|
}
|
|
36029
36183
|
return { records: [] };
|
|
36030
36184
|
}
|
|
36031
36185
|
function saveUsageFile(filePath, data) {
|
|
36032
|
-
const dir =
|
|
36186
|
+
const dir = join48(filePath, "..");
|
|
36033
36187
|
mkdirSync11(dir, { recursive: true });
|
|
36034
36188
|
writeFileSync12(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
36035
36189
|
}
|
|
@@ -36059,15 +36213,15 @@ function recordUsage(kind, value, opts) {
|
|
|
36059
36213
|
}
|
|
36060
36214
|
saveUsageFile(filePath, data);
|
|
36061
36215
|
};
|
|
36062
|
-
update(
|
|
36216
|
+
update(join48(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
|
|
36063
36217
|
if (opts?.repoRoot) {
|
|
36064
|
-
update(
|
|
36218
|
+
update(join48(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
36065
36219
|
}
|
|
36066
36220
|
}
|
|
36067
36221
|
function loadUsageHistory(kind, repoRoot) {
|
|
36068
|
-
const globalPath =
|
|
36222
|
+
const globalPath = join48(homedir9(), ".open-agents", USAGE_HISTORY_FILE);
|
|
36069
36223
|
const globalData = loadUsageFile(globalPath);
|
|
36070
|
-
const localData = repoRoot ? loadUsageFile(
|
|
36224
|
+
const localData = repoRoot ? loadUsageFile(join48(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
|
|
36071
36225
|
const map = /* @__PURE__ */ new Map();
|
|
36072
36226
|
for (const r of globalData.records) {
|
|
36073
36227
|
if (r.kind !== kind)
|
|
@@ -36098,9 +36252,9 @@ function deleteUsageRecord(kind, value, repoRoot) {
|
|
|
36098
36252
|
saveUsageFile(filePath, data);
|
|
36099
36253
|
}
|
|
36100
36254
|
};
|
|
36101
|
-
remove(
|
|
36255
|
+
remove(join48(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
|
|
36102
36256
|
if (repoRoot) {
|
|
36103
|
-
remove(
|
|
36257
|
+
remove(join48(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
36104
36258
|
}
|
|
36105
36259
|
}
|
|
36106
36260
|
var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
@@ -36150,8 +36304,8 @@ var init_oa_directory = __esm({
|
|
|
36150
36304
|
import * as readline from "node:readline";
|
|
36151
36305
|
import { execSync as execSync24, spawn as spawn18, exec as exec2 } from "node:child_process";
|
|
36152
36306
|
import { promisify as promisify5 } from "node:util";
|
|
36153
|
-
import { existsSync as
|
|
36154
|
-
import { join as
|
|
36307
|
+
import { existsSync as existsSync33, writeFileSync as writeFileSync13, readFileSync as readFileSync24, appendFileSync as appendFileSync2, mkdirSync as mkdirSync12 } from "node:fs";
|
|
36308
|
+
import { join as join49 } from "node:path";
|
|
36155
36309
|
import { homedir as homedir10, platform } from "node:os";
|
|
36156
36310
|
function detectSystemSpecs() {
|
|
36157
36311
|
let totalRamGB = 0;
|
|
@@ -36438,7 +36592,7 @@ async function installOllamaMac(_rl) {
|
|
|
36438
36592
|
execSync24('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"', { stdio: "inherit", timeout: 6e5 });
|
|
36439
36593
|
if (!hasCmd("brew")) {
|
|
36440
36594
|
try {
|
|
36441
|
-
const brewPrefix =
|
|
36595
|
+
const brewPrefix = existsSync33("/opt/homebrew/bin/brew") ? "/opt/homebrew" : "/usr/local";
|
|
36442
36596
|
process.env["PATH"] = `${brewPrefix}/bin:${process.env["PATH"]}`;
|
|
36443
36597
|
} catch {
|
|
36444
36598
|
}
|
|
@@ -37192,9 +37346,9 @@ async function doSetup(config, rl) {
|
|
|
37192
37346
|
`PARAMETER num_predict ${numPredict}`,
|
|
37193
37347
|
`PARAMETER stop "<|endoftext|>"`
|
|
37194
37348
|
].join("\n");
|
|
37195
|
-
const modelDir2 =
|
|
37349
|
+
const modelDir2 = join49(homedir10(), ".open-agents", "models");
|
|
37196
37350
|
mkdirSync12(modelDir2, { recursive: true });
|
|
37197
|
-
const modelfilePath =
|
|
37351
|
+
const modelfilePath = join49(modelDir2, `Modelfile.${customName}`);
|
|
37198
37352
|
writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
|
|
37199
37353
|
process.stdout.write(` ${c2.dim("Creating model...")} `);
|
|
37200
37354
|
execSync24(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
@@ -37240,7 +37394,7 @@ async function isModelAvailable(config) {
|
|
|
37240
37394
|
}
|
|
37241
37395
|
function isFirstRun() {
|
|
37242
37396
|
try {
|
|
37243
|
-
return !
|
|
37397
|
+
return !existsSync33(join49(homedir10(), ".open-agents", "config.json"));
|
|
37244
37398
|
} catch {
|
|
37245
37399
|
return true;
|
|
37246
37400
|
}
|
|
@@ -37277,7 +37431,7 @@ function detectPkgManager() {
|
|
|
37277
37431
|
return null;
|
|
37278
37432
|
}
|
|
37279
37433
|
function getVenvDir() {
|
|
37280
|
-
return
|
|
37434
|
+
return join49(homedir10(), ".open-agents", "venv");
|
|
37281
37435
|
}
|
|
37282
37436
|
function hasVenvModule() {
|
|
37283
37437
|
try {
|
|
@@ -37289,8 +37443,8 @@ function hasVenvModule() {
|
|
|
37289
37443
|
}
|
|
37290
37444
|
function ensureVenv(log) {
|
|
37291
37445
|
const venvDir = getVenvDir();
|
|
37292
|
-
const venvPip =
|
|
37293
|
-
if (
|
|
37446
|
+
const venvPip = join49(venvDir, "bin", "pip");
|
|
37447
|
+
if (existsSync33(venvPip))
|
|
37294
37448
|
return venvDir;
|
|
37295
37449
|
log("Creating Python venv for vision deps...");
|
|
37296
37450
|
if (!hasCmd("python3")) {
|
|
@@ -37302,9 +37456,9 @@ function ensureVenv(log) {
|
|
|
37302
37456
|
return null;
|
|
37303
37457
|
}
|
|
37304
37458
|
try {
|
|
37305
|
-
mkdirSync12(
|
|
37459
|
+
mkdirSync12(join49(homedir10(), ".open-agents"), { recursive: true });
|
|
37306
37460
|
execSync24(`python3 -m venv "${venvDir}"`, { stdio: "pipe", timeout: 3e4 });
|
|
37307
|
-
execSync24(`"${
|
|
37461
|
+
execSync24(`"${join49(venvDir, "bin", "pip")}" install --upgrade pip`, {
|
|
37308
37462
|
stdio: "pipe",
|
|
37309
37463
|
timeout: 6e4
|
|
37310
37464
|
});
|
|
@@ -37495,15 +37649,15 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
37495
37649
|
}
|
|
37496
37650
|
}
|
|
37497
37651
|
const venvDir = getVenvDir();
|
|
37498
|
-
const venvBin =
|
|
37499
|
-
const venvMoondream =
|
|
37652
|
+
const venvBin = join49(venvDir, "bin");
|
|
37653
|
+
const venvMoondream = join49(venvBin, "moondream-station");
|
|
37500
37654
|
const venv = ensureVenv(log);
|
|
37501
|
-
if (venv && !hasCmd("moondream-station") && !
|
|
37502
|
-
const venvPip =
|
|
37655
|
+
if (venv && !hasCmd("moondream-station") && !existsSync33(venvMoondream)) {
|
|
37656
|
+
const venvPip = join49(venvBin, "pip");
|
|
37503
37657
|
log("Installing moondream-station in ~/.open-agents/venv...");
|
|
37504
37658
|
try {
|
|
37505
37659
|
execSync24(`"${venvPip}" install moondream-station`, { stdio: "pipe", timeout: 3e5 });
|
|
37506
|
-
if (
|
|
37660
|
+
if (existsSync33(venvMoondream)) {
|
|
37507
37661
|
log("moondream-station installed successfully.");
|
|
37508
37662
|
} else {
|
|
37509
37663
|
try {
|
|
@@ -37520,8 +37674,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
37520
37674
|
}
|
|
37521
37675
|
}
|
|
37522
37676
|
if (venv) {
|
|
37523
|
-
const venvPython =
|
|
37524
|
-
const venvPip2 =
|
|
37677
|
+
const venvPython = join49(venvBin, "python");
|
|
37678
|
+
const venvPip2 = join49(venvBin, "pip");
|
|
37525
37679
|
let ocrStackInstalled = false;
|
|
37526
37680
|
try {
|
|
37527
37681
|
execSync24(`"${venvPython}" -c "import cv2, pytesseract, numpy, PIL"`, { stdio: "pipe", timeout: 1e4 });
|
|
@@ -37665,9 +37819,9 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
|
|
|
37665
37819
|
`PARAMETER num_predict ${numPredict}`,
|
|
37666
37820
|
`PARAMETER stop "<|endoftext|>"`
|
|
37667
37821
|
].join("\n");
|
|
37668
|
-
const modelDir2 =
|
|
37822
|
+
const modelDir2 = join49(homedir10(), ".open-agents", "models");
|
|
37669
37823
|
mkdirSync12(modelDir2, { recursive: true });
|
|
37670
|
-
const modelfilePath =
|
|
37824
|
+
const modelfilePath = join49(modelDir2, `Modelfile.${customName}`);
|
|
37671
37825
|
writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
|
|
37672
37826
|
await execAsync(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
37673
37827
|
timeout: 12e4
|
|
@@ -37742,8 +37896,8 @@ async function ensureNeovim() {
|
|
|
37742
37896
|
const platform5 = process.platform;
|
|
37743
37897
|
const arch = process.arch;
|
|
37744
37898
|
if (platform5 === "linux") {
|
|
37745
|
-
const binDir =
|
|
37746
|
-
const nvimDest =
|
|
37899
|
+
const binDir = join49(homedir10(), ".local", "bin");
|
|
37900
|
+
const nvimDest = join49(binDir, "nvim");
|
|
37747
37901
|
try {
|
|
37748
37902
|
mkdirSync12(binDir, { recursive: true });
|
|
37749
37903
|
} catch {
|
|
@@ -37814,9 +37968,9 @@ async function ensureNeovim() {
|
|
|
37814
37968
|
}
|
|
37815
37969
|
function ensurePathInShellRc(binDir) {
|
|
37816
37970
|
const shell = process.env.SHELL ?? "";
|
|
37817
|
-
const rcFile = shell.includes("zsh") ?
|
|
37971
|
+
const rcFile = shell.includes("zsh") ? join49(homedir10(), ".zshrc") : join49(homedir10(), ".bashrc");
|
|
37818
37972
|
try {
|
|
37819
|
-
const rcContent =
|
|
37973
|
+
const rcContent = existsSync33(rcFile) ? readFileSync24(rcFile, "utf8") : "";
|
|
37820
37974
|
if (rcContent.includes(binDir))
|
|
37821
37975
|
return;
|
|
37822
37976
|
const exportLine = `
|
|
@@ -38531,7 +38685,7 @@ var init_tui_select = __esm({
|
|
|
38531
38685
|
});
|
|
38532
38686
|
|
|
38533
38687
|
// packages/cli/dist/tui/drop-panel.js
|
|
38534
|
-
import { existsSync as
|
|
38688
|
+
import { existsSync as existsSync34 } from "node:fs";
|
|
38535
38689
|
import { extname as extname9, resolve as resolve27 } from "node:path";
|
|
38536
38690
|
function ansi4(code, text) {
|
|
38537
38691
|
return isTTY4 ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
@@ -38646,7 +38800,7 @@ function showDropPanel(opts) {
|
|
|
38646
38800
|
filePath = decodeURIComponent(filePath.slice(7));
|
|
38647
38801
|
}
|
|
38648
38802
|
filePath = resolve27(filePath);
|
|
38649
|
-
if (!
|
|
38803
|
+
if (!existsSync34(filePath)) {
|
|
38650
38804
|
errorMsg = `File not found: ${filePath}`;
|
|
38651
38805
|
render();
|
|
38652
38806
|
return;
|
|
@@ -38717,9 +38871,9 @@ var init_drop_panel = __esm({
|
|
|
38717
38871
|
});
|
|
38718
38872
|
|
|
38719
38873
|
// packages/cli/dist/tui/neovim-mode.js
|
|
38720
|
-
import { existsSync as
|
|
38874
|
+
import { existsSync as existsSync35, unlinkSync as unlinkSync7 } from "node:fs";
|
|
38721
38875
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
38722
|
-
import { join as
|
|
38876
|
+
import { join as join50 } from "node:path";
|
|
38723
38877
|
import { execSync as execSync25 } from "node:child_process";
|
|
38724
38878
|
function isNeovimActive() {
|
|
38725
38879
|
return _state !== null && !_state.cleanedUp;
|
|
@@ -38767,9 +38921,9 @@ async function startNeovimMode(opts) {
|
|
|
38767
38921
|
);
|
|
38768
38922
|
} catch {
|
|
38769
38923
|
}
|
|
38770
|
-
const socketPath =
|
|
38924
|
+
const socketPath = join50(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
|
|
38771
38925
|
try {
|
|
38772
|
-
if (
|
|
38926
|
+
if (existsSync35(socketPath))
|
|
38773
38927
|
unlinkSync7(socketPath);
|
|
38774
38928
|
} catch {
|
|
38775
38929
|
}
|
|
@@ -38996,13 +39150,13 @@ function resizeNeovim(cols, contentRows) {
|
|
|
38996
39150
|
}
|
|
38997
39151
|
async function connectRPC(state, neovimPkg, cols) {
|
|
38998
39152
|
let attempts = 0;
|
|
38999
|
-
while (!
|
|
39153
|
+
while (!existsSync35(state.socketPath) && attempts < 30) {
|
|
39000
39154
|
await new Promise((r) => setTimeout(r, 200));
|
|
39001
39155
|
attempts++;
|
|
39002
39156
|
if (state.cleanedUp)
|
|
39003
39157
|
return;
|
|
39004
39158
|
}
|
|
39005
|
-
if (!
|
|
39159
|
+
if (!existsSync35(state.socketPath))
|
|
39006
39160
|
return;
|
|
39007
39161
|
const nvim = neovimPkg.attach({ socket: state.socketPath });
|
|
39008
39162
|
state.nvim = nvim;
|
|
@@ -39139,7 +39293,7 @@ function doCleanup(state) {
|
|
|
39139
39293
|
state.pty = null;
|
|
39140
39294
|
}
|
|
39141
39295
|
try {
|
|
39142
|
-
if (
|
|
39296
|
+
if (existsSync35(state.socketPath))
|
|
39143
39297
|
unlinkSync7(state.socketPath);
|
|
39144
39298
|
} catch {
|
|
39145
39299
|
}
|
|
@@ -39196,8 +39350,8 @@ __export(voice_exports, {
|
|
|
39196
39350
|
registerCustomOnnxModel: () => registerCustomOnnxModel,
|
|
39197
39351
|
resetNarrationContext: () => resetNarrationContext
|
|
39198
39352
|
});
|
|
39199
|
-
import { existsSync as
|
|
39200
|
-
import { join as
|
|
39353
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync13, writeFileSync as writeFileSync14, readFileSync as readFileSync25, unlinkSync as unlinkSync8, readdirSync as readdirSync9, renameSync, statSync as statSync12 } from "node:fs";
|
|
39354
|
+
import { join as join51, dirname as dirname17 } from "node:path";
|
|
39201
39355
|
import { homedir as homedir11, tmpdir as tmpdir9, platform as platform2 } from "node:os";
|
|
39202
39356
|
import { execSync as execSync26, spawn as nodeSpawn } from "node:child_process";
|
|
39203
39357
|
import { createRequire } from "node:module";
|
|
@@ -39222,37 +39376,37 @@ function listVoiceModels() {
|
|
|
39222
39376
|
}));
|
|
39223
39377
|
}
|
|
39224
39378
|
function voiceDir() {
|
|
39225
|
-
return
|
|
39379
|
+
return join51(homedir11(), ".open-agents", "voice");
|
|
39226
39380
|
}
|
|
39227
39381
|
function modelsDir() {
|
|
39228
|
-
return
|
|
39382
|
+
return join51(voiceDir(), "models");
|
|
39229
39383
|
}
|
|
39230
39384
|
function modelDir(id) {
|
|
39231
|
-
return
|
|
39385
|
+
return join51(modelsDir(), id);
|
|
39232
39386
|
}
|
|
39233
39387
|
function modelOnnxPath(id) {
|
|
39234
|
-
return
|
|
39388
|
+
return join51(modelDir(id), "model.onnx");
|
|
39235
39389
|
}
|
|
39236
39390
|
function modelConfigPath(id) {
|
|
39237
|
-
return
|
|
39391
|
+
return join51(modelDir(id), "config.json");
|
|
39238
39392
|
}
|
|
39239
39393
|
function luxttsVenvDir() {
|
|
39240
|
-
return
|
|
39394
|
+
return join51(voiceDir(), "luxtts-venv");
|
|
39241
39395
|
}
|
|
39242
39396
|
function luxttsVenvPy() {
|
|
39243
|
-
return platform2() === "win32" ?
|
|
39397
|
+
return platform2() === "win32" ? join51(luxttsVenvDir(), "Scripts", "python.exe") : join51(luxttsVenvDir(), "bin", "python3");
|
|
39244
39398
|
}
|
|
39245
39399
|
function luxttsRepoDir() {
|
|
39246
|
-
return
|
|
39400
|
+
return join51(voiceDir(), "LuxTTS");
|
|
39247
39401
|
}
|
|
39248
39402
|
function luxttsCloneRefsDir() {
|
|
39249
|
-
return
|
|
39403
|
+
return join51(voiceDir(), "clone-refs");
|
|
39250
39404
|
}
|
|
39251
39405
|
function luxttsInferScript() {
|
|
39252
|
-
return
|
|
39406
|
+
return join51(voiceDir(), "luxtts-infer.py");
|
|
39253
39407
|
}
|
|
39254
39408
|
function writeDetectTorchScript(targetPath) {
|
|
39255
|
-
if (
|
|
39409
|
+
if (existsSync36(targetPath))
|
|
39256
39410
|
return;
|
|
39257
39411
|
try {
|
|
39258
39412
|
mkdirSync13(dirname17(targetPath), { recursive: true });
|
|
@@ -40138,8 +40292,8 @@ var init_voice = __esm({
|
|
|
40138
40292
|
const refsDir = luxttsCloneRefsDir();
|
|
40139
40293
|
const targets = ["glados", "overwatch"];
|
|
40140
40294
|
for (const modelId of targets) {
|
|
40141
|
-
const refFile =
|
|
40142
|
-
if (
|
|
40295
|
+
const refFile = join51(refsDir, `${modelId}-ref.wav`);
|
|
40296
|
+
if (existsSync36(refFile))
|
|
40143
40297
|
continue;
|
|
40144
40298
|
try {
|
|
40145
40299
|
await this.generateCloneRef(modelId);
|
|
@@ -40218,23 +40372,23 @@ var init_voice = __esm({
|
|
|
40218
40372
|
}
|
|
40219
40373
|
p = p.replace(/\\ /g, " ");
|
|
40220
40374
|
if (p.startsWith("~/") || p === "~") {
|
|
40221
|
-
p =
|
|
40375
|
+
p = join51(homedir11(), p.slice(1));
|
|
40222
40376
|
}
|
|
40223
|
-
if (!
|
|
40377
|
+
if (!existsSync36(p)) {
|
|
40224
40378
|
return `File not found: ${p}
|
|
40225
40379
|
(original input: ${audioPath})`;
|
|
40226
40380
|
}
|
|
40227
40381
|
audioPath = p;
|
|
40228
40382
|
const refsDir = luxttsCloneRefsDir();
|
|
40229
|
-
if (!
|
|
40383
|
+
if (!existsSync36(refsDir))
|
|
40230
40384
|
mkdirSync13(refsDir, { recursive: true });
|
|
40231
40385
|
const ext = audioPath.split(".").pop() || "wav";
|
|
40232
40386
|
const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
40233
40387
|
const ts = Date.now().toString(36);
|
|
40234
40388
|
const destFilename = `clone-${srcName}-${ts}.${ext}`;
|
|
40235
|
-
const destPath =
|
|
40389
|
+
const destPath = join51(refsDir, destFilename);
|
|
40236
40390
|
try {
|
|
40237
|
-
const data =
|
|
40391
|
+
const data = readFileSync25(audioPath);
|
|
40238
40392
|
writeFileSync14(destPath, data);
|
|
40239
40393
|
} catch (err) {
|
|
40240
40394
|
return `Failed to copy audio file: ${err instanceof Error ? err.message : String(err)}`;
|
|
@@ -40275,9 +40429,9 @@ var init_voice = __esm({
|
|
|
40275
40429
|
return `Failed to synthesize reference audio from ${source.label}.`;
|
|
40276
40430
|
}
|
|
40277
40431
|
const refsDir = luxttsCloneRefsDir();
|
|
40278
|
-
if (!
|
|
40432
|
+
if (!existsSync36(refsDir))
|
|
40279
40433
|
mkdirSync13(refsDir, { recursive: true });
|
|
40280
|
-
const destPath =
|
|
40434
|
+
const destPath = join51(refsDir, `${sourceModelId}-ref.wav`);
|
|
40281
40435
|
const sampleRate = this.config?.audio?.sample_rate ?? 22050;
|
|
40282
40436
|
this.writeWav(audioData, sampleRate, destPath);
|
|
40283
40437
|
this.luxttsCloneRef = destPath;
|
|
@@ -40293,21 +40447,21 @@ var init_voice = __esm({
|
|
|
40293
40447
|
// -------------------------------------------------------------------------
|
|
40294
40448
|
/** Metadata file for friendly names of clone refs */
|
|
40295
40449
|
static cloneMetaFile() {
|
|
40296
|
-
return
|
|
40450
|
+
return join51(luxttsCloneRefsDir(), "meta.json");
|
|
40297
40451
|
}
|
|
40298
40452
|
loadCloneMeta() {
|
|
40299
40453
|
const p = _VoiceEngine.cloneMetaFile();
|
|
40300
|
-
if (!
|
|
40454
|
+
if (!existsSync36(p))
|
|
40301
40455
|
return {};
|
|
40302
40456
|
try {
|
|
40303
|
-
return JSON.parse(
|
|
40457
|
+
return JSON.parse(readFileSync25(p, "utf8"));
|
|
40304
40458
|
} catch {
|
|
40305
40459
|
return {};
|
|
40306
40460
|
}
|
|
40307
40461
|
}
|
|
40308
40462
|
saveCloneMeta(meta) {
|
|
40309
40463
|
const dir = luxttsCloneRefsDir();
|
|
40310
|
-
if (!
|
|
40464
|
+
if (!existsSync36(dir))
|
|
40311
40465
|
mkdirSync13(dir, { recursive: true });
|
|
40312
40466
|
writeFileSync14(_VoiceEngine.cloneMetaFile(), JSON.stringify(meta, null, 2));
|
|
40313
40467
|
}
|
|
@@ -40319,7 +40473,7 @@ var init_voice = __esm({
|
|
|
40319
40473
|
*/
|
|
40320
40474
|
listCloneRefs() {
|
|
40321
40475
|
const dir = luxttsCloneRefsDir();
|
|
40322
|
-
if (!
|
|
40476
|
+
if (!existsSync36(dir))
|
|
40323
40477
|
return [];
|
|
40324
40478
|
const meta = this.loadCloneMeta();
|
|
40325
40479
|
const files = readdirSync9(dir).filter((f) => {
|
|
@@ -40327,7 +40481,7 @@ var init_voice = __esm({
|
|
|
40327
40481
|
return _VoiceEngine.AUDIO_EXTS.has(ext);
|
|
40328
40482
|
});
|
|
40329
40483
|
return files.map((f) => {
|
|
40330
|
-
const p =
|
|
40484
|
+
const p = join51(dir, f);
|
|
40331
40485
|
let size = 0;
|
|
40332
40486
|
try {
|
|
40333
40487
|
size = statSync12(p).size;
|
|
@@ -40344,8 +40498,8 @@ var init_voice = __esm({
|
|
|
40344
40498
|
}
|
|
40345
40499
|
/** Delete a clone reference file by filename. Returns true if deleted. */
|
|
40346
40500
|
deleteCloneRef(filename) {
|
|
40347
|
-
const p =
|
|
40348
|
-
if (!
|
|
40501
|
+
const p = join51(luxttsCloneRefsDir(), filename);
|
|
40502
|
+
if (!existsSync36(p))
|
|
40349
40503
|
return false;
|
|
40350
40504
|
try {
|
|
40351
40505
|
unlinkSync8(p);
|
|
@@ -40369,8 +40523,8 @@ var init_voice = __esm({
|
|
|
40369
40523
|
}
|
|
40370
40524
|
/** Set the active clone reference by filename. */
|
|
40371
40525
|
setActiveCloneRef(filename) {
|
|
40372
|
-
const p =
|
|
40373
|
-
if (!
|
|
40526
|
+
const p = join51(luxttsCloneRefsDir(), filename);
|
|
40527
|
+
if (!existsSync36(p))
|
|
40374
40528
|
return `File not found: ${filename}`;
|
|
40375
40529
|
this.luxttsCloneRef = p;
|
|
40376
40530
|
return `Active clone voice set to: ${filename}`;
|
|
@@ -40695,7 +40849,7 @@ var init_voice = __esm({
|
|
|
40695
40849
|
}
|
|
40696
40850
|
this.onPCMOutput(Buffer.from(int16.buffer), sampleRate);
|
|
40697
40851
|
}
|
|
40698
|
-
const wavPath =
|
|
40852
|
+
const wavPath = join51(tmpdir9(), `oa-voice-${Date.now()}.wav`);
|
|
40699
40853
|
this.writeStereoWav(stereo.left, stereo.right, sampleRate, wavPath);
|
|
40700
40854
|
await this.playWav(wavPath);
|
|
40701
40855
|
try {
|
|
@@ -41088,7 +41242,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41088
41242
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
41089
41243
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
41090
41244
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
41091
|
-
const wavPath =
|
|
41245
|
+
const wavPath = join51(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
|
|
41092
41246
|
const pyScript = [
|
|
41093
41247
|
"import sys, json",
|
|
41094
41248
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -41105,11 +41259,11 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41105
41259
|
return;
|
|
41106
41260
|
}
|
|
41107
41261
|
}
|
|
41108
|
-
if (!
|
|
41262
|
+
if (!existsSync36(wavPath))
|
|
41109
41263
|
return;
|
|
41110
41264
|
if (volume !== 1) {
|
|
41111
41265
|
try {
|
|
41112
|
-
const wavData =
|
|
41266
|
+
const wavData = readFileSync25(wavPath);
|
|
41113
41267
|
if (wavData.length > 44) {
|
|
41114
41268
|
const header = wavData.subarray(0, 44);
|
|
41115
41269
|
const samples = new Int16Array(wavData.buffer, wavData.byteOffset + 44, (wavData.length - 44) / 2);
|
|
@@ -41124,7 +41278,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41124
41278
|
}
|
|
41125
41279
|
if (this.onPCMOutput) {
|
|
41126
41280
|
try {
|
|
41127
|
-
const wavData =
|
|
41281
|
+
const wavData = readFileSync25(wavPath);
|
|
41128
41282
|
if (wavData.length > 44) {
|
|
41129
41283
|
const pcm = Buffer.from(wavData.buffer, wavData.byteOffset + 44, wavData.length - 44);
|
|
41130
41284
|
const sampleRate = wavData.readUInt32LE(24);
|
|
@@ -41156,7 +41310,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41156
41310
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
41157
41311
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
41158
41312
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
41159
|
-
const wavPath =
|
|
41313
|
+
const wavPath = join51(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
|
|
41160
41314
|
const pyScript = [
|
|
41161
41315
|
"import sys, json",
|
|
41162
41316
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -41173,10 +41327,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41173
41327
|
return null;
|
|
41174
41328
|
}
|
|
41175
41329
|
}
|
|
41176
|
-
if (!
|
|
41330
|
+
if (!existsSync36(wavPath))
|
|
41177
41331
|
return null;
|
|
41178
41332
|
try {
|
|
41179
|
-
const data =
|
|
41333
|
+
const data = readFileSync25(wavPath);
|
|
41180
41334
|
unlinkSync8(wavPath);
|
|
41181
41335
|
return data;
|
|
41182
41336
|
} catch {
|
|
@@ -41199,7 +41353,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41199
41353
|
}
|
|
41200
41354
|
const venvDir = luxttsVenvDir();
|
|
41201
41355
|
const venvPy = luxttsVenvPy();
|
|
41202
|
-
if (
|
|
41356
|
+
if (existsSync36(venvPy)) {
|
|
41203
41357
|
try {
|
|
41204
41358
|
await this.asyncShell(`${venvPy} -c "import sys; sys.path.insert(0, '${luxttsRepoDir()}'); from zipvoice.luxvoice import LuxTTS; print('ok')"`, 3e4);
|
|
41205
41359
|
let hasCudaSys = false;
|
|
@@ -41213,7 +41367,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41213
41367
|
if (torchCheck === "cpu") {
|
|
41214
41368
|
renderWarning("GPU detected but PyTorch is CPU-only. Reinstalling with CUDA support in background...");
|
|
41215
41369
|
try {
|
|
41216
|
-
const detectScript =
|
|
41370
|
+
const detectScript = join51(voiceDir(), "detect-torch.py");
|
|
41217
41371
|
writeDetectTorchScript(detectScript);
|
|
41218
41372
|
let pipArgs = `torch torchaudio --index-url https://download.pytorch.org/whl/cu124`;
|
|
41219
41373
|
try {
|
|
@@ -41238,7 +41392,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41238
41392
|
}
|
|
41239
41393
|
}
|
|
41240
41394
|
renderInfo("Setting up LuxTTS voice cloning (first-time setup, this takes several minutes)...");
|
|
41241
|
-
if (!
|
|
41395
|
+
if (!existsSync36(venvDir)) {
|
|
41242
41396
|
renderInfo(" Creating Python virtual environment...");
|
|
41243
41397
|
try {
|
|
41244
41398
|
await this.asyncShell(`${py} -m venv ${JSON.stringify(venvDir)}`, 6e4);
|
|
@@ -41247,7 +41401,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41247
41401
|
}
|
|
41248
41402
|
}
|
|
41249
41403
|
{
|
|
41250
|
-
const detectScript =
|
|
41404
|
+
const detectScript = join51(voiceDir(), "detect-torch.py");
|
|
41251
41405
|
writeDetectTorchScript(detectScript);
|
|
41252
41406
|
let pipArgsStr = "torch torchaudio";
|
|
41253
41407
|
let torchDesc = "unknown platform";
|
|
@@ -41284,10 +41438,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41284
41438
|
}
|
|
41285
41439
|
}
|
|
41286
41440
|
const repoDir = luxttsRepoDir();
|
|
41287
|
-
if (!
|
|
41441
|
+
if (!existsSync36(join51(repoDir, "zipvoice", "luxvoice.py"))) {
|
|
41288
41442
|
renderInfo(" Cloning LuxTTS repository...");
|
|
41289
41443
|
try {
|
|
41290
|
-
if (
|
|
41444
|
+
if (existsSync36(repoDir)) {
|
|
41291
41445
|
await this.asyncShell(`rm -rf ${JSON.stringify(repoDir)}`, 3e4);
|
|
41292
41446
|
}
|
|
41293
41447
|
await this.asyncShell(`git clone --depth 1 https://github.com/ysharma3501/LuxTTS.git ${JSON.stringify(repoDir)}`, 12e4);
|
|
@@ -41325,7 +41479,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41325
41479
|
renderWarning(` Could not install system build deps: ${err instanceof Error ? err.message : String(err)}`);
|
|
41326
41480
|
}
|
|
41327
41481
|
}
|
|
41328
|
-
const isJetson = isArm && (
|
|
41482
|
+
const isJetson = isArm && (existsSync36("/etc/nv_tegra_release") || existsSync36("/usr/local/cuda/targets/aarch64-linux") || (process.env.JETSON_L4T_VERSION ?? "") !== "");
|
|
41329
41483
|
const installSteps = isArm ? [
|
|
41330
41484
|
// ARM: install individually so we get clear error messages per package.
|
|
41331
41485
|
// ALL are fatal because LuxTTS hard-imports them (no lazy/optional imports).
|
|
@@ -41387,14 +41541,14 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
41387
41541
|
}
|
|
41388
41542
|
/** Auto-detect an existing clone reference in the refs directory */
|
|
41389
41543
|
autoDetectCloneRef() {
|
|
41390
|
-
if (this.luxttsCloneRef &&
|
|
41544
|
+
if (this.luxttsCloneRef && existsSync36(this.luxttsCloneRef))
|
|
41391
41545
|
return;
|
|
41392
41546
|
const refsDir = luxttsCloneRefsDir();
|
|
41393
|
-
if (!
|
|
41547
|
+
if (!existsSync36(refsDir))
|
|
41394
41548
|
return;
|
|
41395
41549
|
for (const name of ["custom-clone.wav", "custom-clone.mp3", "glados-ref.wav", "overwatch-ref.wav"]) {
|
|
41396
|
-
const p =
|
|
41397
|
-
if (
|
|
41550
|
+
const p = join51(refsDir, name);
|
|
41551
|
+
if (existsSync36(p)) {
|
|
41398
41552
|
this.luxttsCloneRef = p;
|
|
41399
41553
|
return;
|
|
41400
41554
|
}
|
|
@@ -41502,7 +41656,7 @@ if __name__ == '__main__':
|
|
|
41502
41656
|
if (this._luxttsDaemon && !this._luxttsDaemon.killed)
|
|
41503
41657
|
return true;
|
|
41504
41658
|
const venvPy = luxttsVenvPy();
|
|
41505
|
-
if (!
|
|
41659
|
+
if (!existsSync36(venvPy))
|
|
41506
41660
|
return false;
|
|
41507
41661
|
return new Promise((resolve32) => {
|
|
41508
41662
|
const env = { ...process.env, LUXTTS_REPO_PATH: luxttsRepoDir() };
|
|
@@ -41586,7 +41740,7 @@ if __name__ == '__main__':
|
|
|
41586
41740
|
* Used by drainQueue's pre-fetch pipeline for gapless back-to-back playback.
|
|
41587
41741
|
*/
|
|
41588
41742
|
async synthesizeLuxttsWav(text, speedFactor = 1) {
|
|
41589
|
-
if (!this.luxttsCloneRef || !
|
|
41743
|
+
if (!this.luxttsCloneRef || !existsSync36(this.luxttsCloneRef))
|
|
41590
41744
|
return null;
|
|
41591
41745
|
const cleaned = text.replace(/\*/g, "").trim();
|
|
41592
41746
|
if (!cleaned)
|
|
@@ -41594,7 +41748,7 @@ if __name__ == '__main__':
|
|
|
41594
41748
|
const ready = await this.ensureLuxttsDaemon();
|
|
41595
41749
|
if (!ready)
|
|
41596
41750
|
return null;
|
|
41597
|
-
const wavPath =
|
|
41751
|
+
const wavPath = join51(tmpdir9(), `oa-luxtts-${Date.now()}-${Math.random().toString(36).slice(2, 6)}.wav`);
|
|
41598
41752
|
try {
|
|
41599
41753
|
await this.luxttsRequest({
|
|
41600
41754
|
action: "synthesize",
|
|
@@ -41606,17 +41760,17 @@ if __name__ == '__main__':
|
|
|
41606
41760
|
} catch {
|
|
41607
41761
|
return null;
|
|
41608
41762
|
}
|
|
41609
|
-
return
|
|
41763
|
+
return existsSync36(wavPath) ? wavPath : null;
|
|
41610
41764
|
}
|
|
41611
41765
|
/**
|
|
41612
41766
|
* Post-process (fade-in, volume, pitch, stereo) and play a LuxTTS WAV file.
|
|
41613
41767
|
* Cleans up the WAV file after playback.
|
|
41614
41768
|
*/
|
|
41615
41769
|
async postProcessAndPlayLuxtts(wavPath, volume = 1, pitchFactor = 1, stereoDelayMs = 0.6) {
|
|
41616
|
-
if (!
|
|
41770
|
+
if (!existsSync36(wavPath))
|
|
41617
41771
|
return;
|
|
41618
41772
|
try {
|
|
41619
|
-
const wavData =
|
|
41773
|
+
const wavData = readFileSync25(wavPath);
|
|
41620
41774
|
if (wavData.length > 44) {
|
|
41621
41775
|
const sampleRate = wavData.readUInt32LE(24);
|
|
41622
41776
|
const samples = new Int16Array(wavData.buffer, wavData.byteOffset + 44, (wavData.length - 44) / 2);
|
|
@@ -41637,7 +41791,7 @@ if __name__ == '__main__':
|
|
|
41637
41791
|
}
|
|
41638
41792
|
if (pitchFactor !== 1) {
|
|
41639
41793
|
try {
|
|
41640
|
-
const wavData =
|
|
41794
|
+
const wavData = readFileSync25(wavPath);
|
|
41641
41795
|
if (wavData.length > 44) {
|
|
41642
41796
|
const int16 = new Int16Array(wavData.buffer, wavData.byteOffset + 44, (wavData.length - 44) / 2);
|
|
41643
41797
|
const float32 = new Float32Array(int16.length);
|
|
@@ -41652,7 +41806,7 @@ if __name__ == '__main__':
|
|
|
41652
41806
|
}
|
|
41653
41807
|
if (this.onPCMOutput) {
|
|
41654
41808
|
try {
|
|
41655
|
-
const wavData =
|
|
41809
|
+
const wavData = readFileSync25(wavPath);
|
|
41656
41810
|
if (wavData.length > 44) {
|
|
41657
41811
|
const pcm = Buffer.from(wavData.buffer, wavData.byteOffset + 44, wavData.length - 44);
|
|
41658
41812
|
const sampleRate = wavData.readUInt32LE(24);
|
|
@@ -41663,7 +41817,7 @@ if __name__ == '__main__':
|
|
|
41663
41817
|
}
|
|
41664
41818
|
if (stereoDelayMs > 0) {
|
|
41665
41819
|
try {
|
|
41666
|
-
const wavData =
|
|
41820
|
+
const wavData = readFileSync25(wavPath);
|
|
41667
41821
|
if (wavData.length > 44) {
|
|
41668
41822
|
const sampleRate = wavData.readUInt32LE(24);
|
|
41669
41823
|
const numChannels = wavData.readUInt16LE(22);
|
|
@@ -41699,7 +41853,7 @@ if __name__ == '__main__':
|
|
|
41699
41853
|
* Used for Telegram voice messages and WebSocket streaming.
|
|
41700
41854
|
*/
|
|
41701
41855
|
async synthesizeLuxttsToBuffer(text) {
|
|
41702
|
-
if (!this.luxttsCloneRef || !
|
|
41856
|
+
if (!this.luxttsCloneRef || !existsSync36(this.luxttsCloneRef))
|
|
41703
41857
|
return null;
|
|
41704
41858
|
const cleaned = text.replace(/\*/g, "").trim();
|
|
41705
41859
|
if (!cleaned)
|
|
@@ -41707,7 +41861,7 @@ if __name__ == '__main__':
|
|
|
41707
41861
|
const ready = await this.ensureLuxttsDaemon();
|
|
41708
41862
|
if (!ready)
|
|
41709
41863
|
return null;
|
|
41710
|
-
const wavPath =
|
|
41864
|
+
const wavPath = join51(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
|
|
41711
41865
|
try {
|
|
41712
41866
|
await this.luxttsRequest({
|
|
41713
41867
|
action: "synthesize",
|
|
@@ -41719,10 +41873,10 @@ if __name__ == '__main__':
|
|
|
41719
41873
|
} catch {
|
|
41720
41874
|
return null;
|
|
41721
41875
|
}
|
|
41722
|
-
if (!
|
|
41876
|
+
if (!existsSync36(wavPath))
|
|
41723
41877
|
return null;
|
|
41724
41878
|
try {
|
|
41725
|
-
const data =
|
|
41879
|
+
const data = readFileSync25(wavPath);
|
|
41726
41880
|
unlinkSync8(wavPath);
|
|
41727
41881
|
return data;
|
|
41728
41882
|
} catch {
|
|
@@ -41737,14 +41891,14 @@ if __name__ == '__main__':
|
|
|
41737
41891
|
return;
|
|
41738
41892
|
const arch = process.arch;
|
|
41739
41893
|
mkdirSync13(voiceDir(), { recursive: true });
|
|
41740
|
-
const pkgPath =
|
|
41894
|
+
const pkgPath = join51(voiceDir(), "package.json");
|
|
41741
41895
|
const expectedDeps = {
|
|
41742
41896
|
"onnxruntime-node": "^1.21.0",
|
|
41743
41897
|
"phonemizer": "^1.2.1"
|
|
41744
41898
|
};
|
|
41745
|
-
if (
|
|
41899
|
+
if (existsSync36(pkgPath)) {
|
|
41746
41900
|
try {
|
|
41747
|
-
const existing = JSON.parse(
|
|
41901
|
+
const existing = JSON.parse(readFileSync25(pkgPath, "utf8"));
|
|
41748
41902
|
if (!existing.dependencies?.["phonemizer"]) {
|
|
41749
41903
|
existing.dependencies = { ...existing.dependencies, ...expectedDeps };
|
|
41750
41904
|
writeFileSync14(pkgPath, JSON.stringify(existing, null, 2));
|
|
@@ -41752,24 +41906,24 @@ if __name__ == '__main__':
|
|
|
41752
41906
|
} catch {
|
|
41753
41907
|
}
|
|
41754
41908
|
}
|
|
41755
|
-
if (!
|
|
41909
|
+
if (!existsSync36(pkgPath)) {
|
|
41756
41910
|
writeFileSync14(pkgPath, JSON.stringify({
|
|
41757
41911
|
name: "open-agents-voice",
|
|
41758
41912
|
private: true,
|
|
41759
41913
|
dependencies: expectedDeps
|
|
41760
41914
|
}, null, 2));
|
|
41761
41915
|
}
|
|
41762
|
-
const voiceRequire = createRequire(
|
|
41916
|
+
const voiceRequire = createRequire(join51(voiceDir(), "index.js"));
|
|
41763
41917
|
const probeOnnx = async () => {
|
|
41764
41918
|
try {
|
|
41765
|
-
const output = await this.asyncShell(`NODE_PATH="${
|
|
41919
|
+
const output = await this.asyncShell(`NODE_PATH="${join51(voiceDir(), "node_modules")}" node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, 15e3);
|
|
41766
41920
|
return output.trim() === "OK";
|
|
41767
41921
|
} catch {
|
|
41768
41922
|
return false;
|
|
41769
41923
|
}
|
|
41770
41924
|
};
|
|
41771
|
-
const onnxNodeModules =
|
|
41772
|
-
const onnxInstalled =
|
|
41925
|
+
const onnxNodeModules = join51(voiceDir(), "node_modules", "onnxruntime-node");
|
|
41926
|
+
const onnxInstalled = existsSync36(onnxNodeModules);
|
|
41773
41927
|
if (onnxInstalled && !await probeOnnx()) {
|
|
41774
41928
|
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.`);
|
|
41775
41929
|
}
|
|
@@ -41819,10 +41973,10 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
|
41819
41973
|
const dir = modelDir(id);
|
|
41820
41974
|
const onnxPath = modelOnnxPath(id);
|
|
41821
41975
|
const configPath = modelConfigPath(id);
|
|
41822
|
-
if (
|
|
41976
|
+
if (existsSync36(onnxPath) && existsSync36(configPath))
|
|
41823
41977
|
return;
|
|
41824
41978
|
mkdirSync13(dir, { recursive: true });
|
|
41825
|
-
if (!
|
|
41979
|
+
if (!existsSync36(configPath)) {
|
|
41826
41980
|
renderInfo(`Downloading ${model.label} voice config...`);
|
|
41827
41981
|
const configResp = await fetch(model.configUrl);
|
|
41828
41982
|
if (!configResp.ok)
|
|
@@ -41830,7 +41984,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
|
41830
41984
|
const configText = await configResp.text();
|
|
41831
41985
|
writeFileSync14(configPath, configText);
|
|
41832
41986
|
}
|
|
41833
|
-
if (!
|
|
41987
|
+
if (!existsSync36(onnxPath)) {
|
|
41834
41988
|
renderInfo(`Downloading ${model.label} voice model (this may take a minute)...`);
|
|
41835
41989
|
const onnxResp = await fetch(model.onnxUrl);
|
|
41836
41990
|
if (!onnxResp.ok)
|
|
@@ -41867,10 +42021,10 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
|
41867
42021
|
throw new Error("ONNX runtime not loaded");
|
|
41868
42022
|
const onnxPath = modelOnnxPath(this.modelId);
|
|
41869
42023
|
const configPath = modelConfigPath(this.modelId);
|
|
41870
|
-
if (!
|
|
42024
|
+
if (!existsSync36(onnxPath) || !existsSync36(configPath)) {
|
|
41871
42025
|
throw new Error(`Model files not found for ${this.modelId}`);
|
|
41872
42026
|
}
|
|
41873
|
-
this.config = JSON.parse(
|
|
42027
|
+
this.config = JSON.parse(readFileSync25(configPath, "utf8"));
|
|
41874
42028
|
this.session = await this.ort.InferenceSession.create(onnxPath, {
|
|
41875
42029
|
executionProviders: ["cpu"],
|
|
41876
42030
|
graphOptimizationLevel: "all"
|
|
@@ -41897,8 +42051,8 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
|
41897
42051
|
// packages/cli/dist/tui/commands.js
|
|
41898
42052
|
import * as nodeOs from "node:os";
|
|
41899
42053
|
import { execSync as nodeExecSync } from "node:child_process";
|
|
41900
|
-
import { existsSync as
|
|
41901
|
-
import { join as
|
|
42054
|
+
import { existsSync as existsSync37, readFileSync as readFileSync26, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, readdirSync as readdirSync10, statSync as statSync13, rmSync } from "node:fs";
|
|
42055
|
+
import { join as join52 } from "node:path";
|
|
41902
42056
|
function safeLog(text) {
|
|
41903
42057
|
if (isNeovimActive()) {
|
|
41904
42058
|
writeToNeovimOutput(text + "\n");
|
|
@@ -42382,22 +42536,22 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42382
42536
|
let content = "";
|
|
42383
42537
|
let metadata = {};
|
|
42384
42538
|
if (shareType === "tool") {
|
|
42385
|
-
const toolDir =
|
|
42386
|
-
const toolFile =
|
|
42387
|
-
if (!
|
|
42539
|
+
const toolDir = join52(ctx.repoRoot, ".oa", "tools");
|
|
42540
|
+
const toolFile = join52(toolDir, shareName.endsWith(".json") ? shareName : `${shareName}.json`);
|
|
42541
|
+
if (!existsSync37(toolFile)) {
|
|
42388
42542
|
renderWarning(`Tool not found: ${toolFile}`);
|
|
42389
42543
|
return "handled";
|
|
42390
42544
|
}
|
|
42391
|
-
content =
|
|
42545
|
+
content = readFileSync26(toolFile, "utf8");
|
|
42392
42546
|
metadata = { type: "tool", name: shareName };
|
|
42393
42547
|
} else if (shareType === "skill") {
|
|
42394
|
-
const skillDir =
|
|
42395
|
-
const skillFile =
|
|
42396
|
-
if (!
|
|
42548
|
+
const skillDir = join52(ctx.repoRoot, ".oa", "skills", shareName);
|
|
42549
|
+
const skillFile = join52(skillDir, "SKILL.md");
|
|
42550
|
+
if (!existsSync37(skillFile)) {
|
|
42397
42551
|
renderWarning(`Skill not found: ${skillFile}`);
|
|
42398
42552
|
return "handled";
|
|
42399
42553
|
}
|
|
42400
|
-
content =
|
|
42554
|
+
content = readFileSync26(skillFile, "utf8");
|
|
42401
42555
|
metadata = { type: "skill", name: shareName };
|
|
42402
42556
|
} else {
|
|
42403
42557
|
renderWarning(`Unknown share type: ${shareType}. Use 'tool' or 'skill'.`);
|
|
@@ -42436,9 +42590,9 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42436
42590
|
const { NexusTool: NexusTool2 } = __require("@open-agents/execution");
|
|
42437
42591
|
const nexus = new NexusTool2(ctx.repoRoot);
|
|
42438
42592
|
await nexus.execute({ action: "ipfs_pin", cid: importCid, source: "import" });
|
|
42439
|
-
const regFile =
|
|
42440
|
-
if (
|
|
42441
|
-
const reg = JSON.parse(
|
|
42593
|
+
const regFile = join52(ctx.repoRoot, ".oa", "nexus", "ipfs", "cid-registry", "learning-cids.json");
|
|
42594
|
+
if (existsSync37(regFile)) {
|
|
42595
|
+
const reg = JSON.parse(readFileSync26(regFile, "utf8"));
|
|
42442
42596
|
const pinned = Object.values(reg).some((e) => e.cid === importCid && e.pinned);
|
|
42443
42597
|
if (pinned) {
|
|
42444
42598
|
renderInfo(`CID ${importCid.slice(0, 20)}... pinned successfully.`);
|
|
@@ -42490,33 +42644,33 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42490
42644
|
lines.push(`
|
|
42491
42645
|
${c2.bold("IPFS / Helia Status")}
|
|
42492
42646
|
`);
|
|
42493
|
-
const ipfsDir =
|
|
42494
|
-
const ipfsLocalDir =
|
|
42647
|
+
const ipfsDir = join52(ctx.repoRoot, ".oa", "ipfs");
|
|
42648
|
+
const ipfsLocalDir = join52(ipfsDir, "local");
|
|
42495
42649
|
let ipfsFiles = 0;
|
|
42496
42650
|
let ipfsBytes = 0;
|
|
42497
42651
|
let heliaBlocks = 0;
|
|
42498
42652
|
let heliaBytes = 0;
|
|
42499
42653
|
try {
|
|
42500
|
-
if (
|
|
42654
|
+
if (existsSync37(ipfsLocalDir)) {
|
|
42501
42655
|
const files = readdirSync10(ipfsLocalDir).filter((f) => f.endsWith(".json"));
|
|
42502
42656
|
ipfsFiles = files.length;
|
|
42503
42657
|
for (const f of files) {
|
|
42504
42658
|
try {
|
|
42505
|
-
ipfsBytes += statSync13(
|
|
42659
|
+
ipfsBytes += statSync13(join52(ipfsLocalDir, f)).size;
|
|
42506
42660
|
} catch {
|
|
42507
42661
|
}
|
|
42508
42662
|
}
|
|
42509
42663
|
}
|
|
42510
|
-
const heliaBlockDir =
|
|
42511
|
-
if (
|
|
42664
|
+
const heliaBlockDir = join52(ipfsDir, "blocks");
|
|
42665
|
+
if (existsSync37(heliaBlockDir)) {
|
|
42512
42666
|
const walkDir = (dir) => {
|
|
42513
42667
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
42514
42668
|
if (entry.isDirectory())
|
|
42515
|
-
walkDir(
|
|
42669
|
+
walkDir(join52(dir, entry.name));
|
|
42516
42670
|
else {
|
|
42517
42671
|
heliaBlocks++;
|
|
42518
42672
|
try {
|
|
42519
|
-
heliaBytes += statSync13(
|
|
42673
|
+
heliaBytes += statSync13(join52(dir, entry.name)).size;
|
|
42520
42674
|
} catch {
|
|
42521
42675
|
}
|
|
42522
42676
|
}
|
|
@@ -42532,9 +42686,9 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42532
42686
|
lines.push(` Blocks: ${c2.bold(String(heliaBlocks))} Size: ${c2.bold(formatFileSize(heliaBytes))}`);
|
|
42533
42687
|
lines.push(` Backend: ${heliaBlocks > 0 ? c2.green("helia-ipfs") : c2.yellow("sha256-local (Helia not initialized)")}`);
|
|
42534
42688
|
try {
|
|
42535
|
-
const statusFile =
|
|
42536
|
-
if (
|
|
42537
|
-
const status = JSON.parse(
|
|
42689
|
+
const statusFile = join52(ctx.repoRoot, ".oa", "nexus", "status.json");
|
|
42690
|
+
if (existsSync37(statusFile)) {
|
|
42691
|
+
const status = JSON.parse(readFileSync26(statusFile, "utf8"));
|
|
42538
42692
|
if (status.peerId) {
|
|
42539
42693
|
lines.push(`
|
|
42540
42694
|
${c2.bold("Peer Info")}`);
|
|
@@ -42553,11 +42707,11 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42553
42707
|
${c2.dim("Commands: /ipfs pin <CID> /ipfs publish /ipfs cids")}`);
|
|
42554
42708
|
lines.push(`
|
|
42555
42709
|
${c2.bold("Identity Kernel")}`);
|
|
42556
|
-
const idDir =
|
|
42710
|
+
const idDir = join52(ctx.repoRoot, ".oa", "identity");
|
|
42557
42711
|
try {
|
|
42558
|
-
const stateFile =
|
|
42559
|
-
if (
|
|
42560
|
-
const state = JSON.parse(
|
|
42712
|
+
const stateFile = join52(idDir, "self-state.json");
|
|
42713
|
+
if (existsSync37(stateFile)) {
|
|
42714
|
+
const state = JSON.parse(readFileSync26(stateFile, "utf8"));
|
|
42561
42715
|
lines.push(` Version: ${c2.bold("v" + (state.version ?? "?"))} Sessions: ${c2.bold(String(state.session_count ?? 0))}`);
|
|
42562
42716
|
if (state.narrative_summary) {
|
|
42563
42717
|
lines.push(` Narrative: ${c2.dim(state.narrative_summary.slice(0, 60))}${state.narrative_summary.length > 60 ? "..." : ""}`);
|
|
@@ -42566,9 +42720,9 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42566
42720
|
const traits = typeof state.personality_traits === "object" ? Object.entries(state.personality_traits).map(([k, v]) => `${k}:${v}`).join(", ") : String(state.personality_traits);
|
|
42567
42721
|
lines.push(` Traits: ${c2.dim(traits.slice(0, 60))}`);
|
|
42568
42722
|
}
|
|
42569
|
-
const cidFile =
|
|
42570
|
-
if (
|
|
42571
|
-
const cids = JSON.parse(
|
|
42723
|
+
const cidFile = join52(idDir, "cids.json");
|
|
42724
|
+
if (existsSync37(cidFile)) {
|
|
42725
|
+
const cids = JSON.parse(readFileSync26(cidFile, "utf8"));
|
|
42572
42726
|
const lastCid = Array.isArray(cids) ? cids[cids.length - 1] : cids.latest;
|
|
42573
42727
|
if (lastCid)
|
|
42574
42728
|
lines.push(` Last CID: ${c2.dim(String(lastCid).slice(0, 50))}`);
|
|
@@ -42581,9 +42735,9 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42581
42735
|
lines.push(`
|
|
42582
42736
|
${c2.bold("Memory Sentiment")}`);
|
|
42583
42737
|
try {
|
|
42584
|
-
const metaFile =
|
|
42585
|
-
if (
|
|
42586
|
-
const store = JSON.parse(
|
|
42738
|
+
const metaFile = join52(ctx.repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
42739
|
+
if (existsSync37(metaFile)) {
|
|
42740
|
+
const store = JSON.parse(readFileSync26(metaFile, "utf8"));
|
|
42587
42741
|
const active = store.filter((m) => m.type !== "quarantine");
|
|
42588
42742
|
const recoveries = active.filter((m) => m.content?.startsWith("[recovery]")).length;
|
|
42589
42743
|
const strategies = active.filter((m) => m.content?.startsWith("[strategy]")).length;
|
|
@@ -42601,8 +42755,8 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42601
42755
|
} catch {
|
|
42602
42756
|
}
|
|
42603
42757
|
try {
|
|
42604
|
-
const dbPath =
|
|
42605
|
-
if (
|
|
42758
|
+
const dbPath = join52(ctx.repoRoot, ".oa", "memory", "structured.db");
|
|
42759
|
+
if (existsSync37(dbPath)) {
|
|
42606
42760
|
const { initDb: initDb2, closeDb: cDb, ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
42607
42761
|
const db = initDb2(dbPath);
|
|
42608
42762
|
const memStore = new ProceduralMemoryStore2(db);
|
|
@@ -42623,8 +42777,8 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42623
42777
|
lines.push(`
|
|
42624
42778
|
${c2.bold("Storage Overview")}
|
|
42625
42779
|
`);
|
|
42626
|
-
const oaDir =
|
|
42627
|
-
if (!
|
|
42780
|
+
const oaDir = join52(ctx.repoRoot, ".oa");
|
|
42781
|
+
if (!existsSync37(oaDir)) {
|
|
42628
42782
|
lines.push(` ${c2.dim("No .oa/ directory found.")}`);
|
|
42629
42783
|
safeLog(lines.join("\n") + "\n");
|
|
42630
42784
|
return "handled";
|
|
@@ -42634,7 +42788,7 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42634
42788
|
const walkStorage = (dir, category) => {
|
|
42635
42789
|
try {
|
|
42636
42790
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
42637
|
-
const full =
|
|
42791
|
+
const full = join52(dir, entry.name);
|
|
42638
42792
|
if (entry.isDirectory()) {
|
|
42639
42793
|
const subCat = category || entry.name;
|
|
42640
42794
|
walkStorage(full, subCat);
|
|
@@ -42670,10 +42824,10 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42670
42824
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
42671
42825
|
const name = entry.name.toLowerCase();
|
|
42672
42826
|
if (sensitivePatterns.some((p) => name.includes(p))) {
|
|
42673
|
-
sensitiveFound.push(
|
|
42827
|
+
sensitiveFound.push(join52(dir, entry.name).replace(oaDir + "/", ""));
|
|
42674
42828
|
}
|
|
42675
42829
|
if (entry.isDirectory())
|
|
42676
|
-
checkSensitive(
|
|
42830
|
+
checkSensitive(join52(dir, entry.name));
|
|
42677
42831
|
}
|
|
42678
42832
|
} catch {
|
|
42679
42833
|
}
|
|
@@ -42693,6 +42847,210 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42693
42847
|
safeLog(lines.join("\n"));
|
|
42694
42848
|
return "handled";
|
|
42695
42849
|
}
|
|
42850
|
+
case "ingest":
|
|
42851
|
+
case "transcribe": {
|
|
42852
|
+
const filePath = (arg || "").trim();
|
|
42853
|
+
if (!filePath) {
|
|
42854
|
+
renderInfo("Usage: /ingest <file> \u2014 ingest audio, PDF, or text file into memory");
|
|
42855
|
+
renderInfo("Supported: .wav .mp3 .flac .ogg (audio\u2192transcribe) | .pdf .txt .md (text\u2192chunk)");
|
|
42856
|
+
return "handled";
|
|
42857
|
+
}
|
|
42858
|
+
const resolvedPath = join52(ctx.repoRoot, filePath);
|
|
42859
|
+
if (!existsSync37(resolvedPath)) {
|
|
42860
|
+
renderWarning(`File not found: ${resolvedPath}`);
|
|
42861
|
+
return "handled";
|
|
42862
|
+
}
|
|
42863
|
+
const ext = filePath.split(".").pop()?.toLowerCase() || "";
|
|
42864
|
+
const audioExts = ["wav", "mp3", "flac", "ogg", "m4a", "webm"];
|
|
42865
|
+
const textExts = ["txt", "md", "markdown", "text", "rst"];
|
|
42866
|
+
const isAudio = audioExts.includes(ext);
|
|
42867
|
+
const isPdf = ext === "pdf";
|
|
42868
|
+
const isText = textExts.includes(ext);
|
|
42869
|
+
if (!isAudio && !isPdf && !isText) {
|
|
42870
|
+
renderWarning(`Unsupported file type: .${ext}`);
|
|
42871
|
+
return "handled";
|
|
42872
|
+
}
|
|
42873
|
+
try {
|
|
42874
|
+
const { initDb: initDb2, closeDb: cDb, ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
42875
|
+
const dbDir = join52(ctx.repoRoot, ".oa", "memory");
|
|
42876
|
+
mkdirSync14(dbDir, { recursive: true });
|
|
42877
|
+
const db = initDb2(join52(dbDir, "structured.db"));
|
|
42878
|
+
const memStore = new ProceduralMemoryStore2(db);
|
|
42879
|
+
if (isAudio) {
|
|
42880
|
+
renderInfo(`Transcribing: ${filePath}...`);
|
|
42881
|
+
let transcript = "";
|
|
42882
|
+
try {
|
|
42883
|
+
transcript = nodeExecSync(`transcribe-cli "${resolvedPath}" --format text 2>/dev/null || whisper "${resolvedPath}" --output-format txt 2>/dev/null`, { encoding: "utf8", timeout: 12e4 }).trim();
|
|
42884
|
+
} catch {
|
|
42885
|
+
renderWarning("Transcription failed. Install transcribe-cli or whisper.");
|
|
42886
|
+
cDb(db);
|
|
42887
|
+
return "handled";
|
|
42888
|
+
}
|
|
42889
|
+
if (!transcript) {
|
|
42890
|
+
renderWarning("No transcription output.");
|
|
42891
|
+
cDb(db);
|
|
42892
|
+
return "handled";
|
|
42893
|
+
}
|
|
42894
|
+
memStore.create({
|
|
42895
|
+
content: transcript.slice(0, 2e3),
|
|
42896
|
+
type: "episodic",
|
|
42897
|
+
category: "strategy",
|
|
42898
|
+
triggerPattern: `Transcription of ${filePath}`,
|
|
42899
|
+
sourceTrace: "audio-ingest",
|
|
42900
|
+
utility: 0.6,
|
|
42901
|
+
confidence: 0.7
|
|
42902
|
+
});
|
|
42903
|
+
renderInfo(`Transcribed ${transcript.length} chars \u2192 stored as episodic memory`);
|
|
42904
|
+
} else {
|
|
42905
|
+
let content = "";
|
|
42906
|
+
if (isPdf) {
|
|
42907
|
+
try {
|
|
42908
|
+
content = nodeExecSync(`pdftotext "${resolvedPath}" - 2>/dev/null`, {
|
|
42909
|
+
encoding: "utf8",
|
|
42910
|
+
timeout: 3e4
|
|
42911
|
+
}).trim();
|
|
42912
|
+
} catch {
|
|
42913
|
+
renderWarning("PDF extraction failed. Install poppler-utils: sudo apt-get install poppler-utils");
|
|
42914
|
+
cDb(db);
|
|
42915
|
+
return "handled";
|
|
42916
|
+
}
|
|
42917
|
+
} else {
|
|
42918
|
+
content = readFileSync26(resolvedPath, "utf8");
|
|
42919
|
+
}
|
|
42920
|
+
if (!content.trim()) {
|
|
42921
|
+
renderWarning("No content extracted.");
|
|
42922
|
+
cDb(db);
|
|
42923
|
+
return "handled";
|
|
42924
|
+
}
|
|
42925
|
+
const chunks = [];
|
|
42926
|
+
const chunkSize = 800;
|
|
42927
|
+
const overlap = 100;
|
|
42928
|
+
for (let i = 0; i < content.length; i += chunkSize - overlap) {
|
|
42929
|
+
chunks.push(content.slice(i, i + chunkSize));
|
|
42930
|
+
}
|
|
42931
|
+
renderInfo(`Ingesting ${chunks.length} chunks from ${filePath}...`);
|
|
42932
|
+
let stored = 0;
|
|
42933
|
+
for (const chunk of chunks) {
|
|
42934
|
+
if (chunk.trim().length < 20)
|
|
42935
|
+
continue;
|
|
42936
|
+
memStore.create({
|
|
42937
|
+
content: chunk.slice(0, 2e3),
|
|
42938
|
+
type: "semantic",
|
|
42939
|
+
category: "strategy",
|
|
42940
|
+
triggerPattern: `Document chunk from ${filePath}`,
|
|
42941
|
+
sourceTrace: "document-ingest",
|
|
42942
|
+
utility: 0.5,
|
|
42943
|
+
confidence: 0.8
|
|
42944
|
+
});
|
|
42945
|
+
stored++;
|
|
42946
|
+
}
|
|
42947
|
+
renderInfo(`Ingested ${stored} chunks \u2192 stored as semantic memories`);
|
|
42948
|
+
}
|
|
42949
|
+
cDb(db);
|
|
42950
|
+
} catch (e) {
|
|
42951
|
+
renderWarning(`Ingest failed: ${e.message ?? e}`);
|
|
42952
|
+
}
|
|
42953
|
+
return "handled";
|
|
42954
|
+
}
|
|
42955
|
+
case "fortemi": {
|
|
42956
|
+
const fortemiSubCmd = (arg || "").trim().toLowerCase();
|
|
42957
|
+
const fortemiDir = join52(ctx.repoRoot, "..", "fortemi-react");
|
|
42958
|
+
const altFortemiDir = join52(nodeOs.homedir(), "fortemi-react");
|
|
42959
|
+
const fDir = existsSync37(fortemiDir) ? fortemiDir : existsSync37(altFortemiDir) ? altFortemiDir : null;
|
|
42960
|
+
if (fortemiSubCmd === "start" || fortemiSubCmd === "") {
|
|
42961
|
+
if (!fDir) {
|
|
42962
|
+
renderWarning("fortemi-react not found adjacent or in home directory.");
|
|
42963
|
+
renderInfo("Clone it: git clone https://github.com/robit-man/fortemi-react.git");
|
|
42964
|
+
return "handled";
|
|
42965
|
+
}
|
|
42966
|
+
const jwtPayload = {
|
|
42967
|
+
iss: "open-agents",
|
|
42968
|
+
sub: ctx.config.model || "agent",
|
|
42969
|
+
iat: Math.floor(Date.now() / 1e3),
|
|
42970
|
+
exp: Math.floor(Date.now() / 1e3) + 86400,
|
|
42971
|
+
// 24h
|
|
42972
|
+
nonce: Math.random().toString(36).slice(2, 10)
|
|
42973
|
+
};
|
|
42974
|
+
const jwtFile = join52(ctx.repoRoot, ".oa", "fortemi-jwt.json");
|
|
42975
|
+
mkdirSync14(join52(ctx.repoRoot, ".oa"), { recursive: true });
|
|
42976
|
+
writeFileSync15(jwtFile, JSON.stringify(jwtPayload, null, 2));
|
|
42977
|
+
renderInfo(`Launching fortemi-react from ${fDir}...`);
|
|
42978
|
+
try {
|
|
42979
|
+
const { spawn: spawn20 } = __require("node:child_process");
|
|
42980
|
+
const child = spawn20("npx", ["vite", "dev", "--host", "0.0.0.0", "--port", "3000"], {
|
|
42981
|
+
cwd: join52(fDir, "apps", "standalone"),
|
|
42982
|
+
stdio: "ignore",
|
|
42983
|
+
detached: true,
|
|
42984
|
+
env: { ...process.env, OA_JWT: JSON.stringify(jwtPayload) }
|
|
42985
|
+
});
|
|
42986
|
+
child.unref();
|
|
42987
|
+
renderInfo("Fortemi-React starting on http://localhost:3000");
|
|
42988
|
+
renderInfo(`JWT saved to ${jwtFile}`);
|
|
42989
|
+
renderInfo("Memory operations will proxy to fortemi when available.");
|
|
42990
|
+
const bridgeFile = join52(ctx.repoRoot, ".oa", "fortemi-bridge.json");
|
|
42991
|
+
writeFileSync15(bridgeFile, JSON.stringify({
|
|
42992
|
+
url: "http://localhost:3000",
|
|
42993
|
+
pid: child.pid,
|
|
42994
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
42995
|
+
jwtFile
|
|
42996
|
+
}, null, 2));
|
|
42997
|
+
} catch (e) {
|
|
42998
|
+
renderWarning(`Failed to launch: ${e.message ?? e}`);
|
|
42999
|
+
}
|
|
43000
|
+
return "handled";
|
|
43001
|
+
}
|
|
43002
|
+
if (fortemiSubCmd === "status") {
|
|
43003
|
+
const bridgeFile = join52(ctx.repoRoot, ".oa", "fortemi-bridge.json");
|
|
43004
|
+
if (!existsSync37(bridgeFile)) {
|
|
43005
|
+
renderInfo("Fortemi bridge: not connected. Run /fortemi start");
|
|
43006
|
+
return "handled";
|
|
43007
|
+
}
|
|
43008
|
+
const bridge = JSON.parse(readFileSync26(bridgeFile, "utf8"));
|
|
43009
|
+
let alive = false;
|
|
43010
|
+
try {
|
|
43011
|
+
process.kill(bridge.pid, 0);
|
|
43012
|
+
alive = true;
|
|
43013
|
+
} catch {
|
|
43014
|
+
}
|
|
43015
|
+
let httpOk = false;
|
|
43016
|
+
try {
|
|
43017
|
+
const resp = await fetch(`${bridge.url}/api/v1/tools/list_notes`, { signal: AbortSignal.timeout(3e3) });
|
|
43018
|
+
httpOk = resp.ok;
|
|
43019
|
+
} catch {
|
|
43020
|
+
}
|
|
43021
|
+
const lines = [`
|
|
43022
|
+
${c2.bold("Fortemi Bridge Status")}
|
|
43023
|
+
`];
|
|
43024
|
+
lines.push(` URL: ${bridge.url}`);
|
|
43025
|
+
lines.push(` Process: ${alive ? c2.green("running") : c2.yellow("not running")} (PID ${bridge.pid})`);
|
|
43026
|
+
lines.push(` HTTP: ${httpOk ? c2.green("connected") : c2.yellow("unreachable")}`);
|
|
43027
|
+
lines.push(` Started: ${bridge.startedAt}`);
|
|
43028
|
+
lines.push(` JWT: ${existsSync37(bridge.jwtFile) ? c2.green("valid") : c2.yellow("missing")}`);
|
|
43029
|
+
lines.push("");
|
|
43030
|
+
safeLog(lines.join("\n"));
|
|
43031
|
+
return "handled";
|
|
43032
|
+
}
|
|
43033
|
+
if (fortemiSubCmd === "stop") {
|
|
43034
|
+
const bridgeFile = join52(ctx.repoRoot, ".oa", "fortemi-bridge.json");
|
|
43035
|
+
if (existsSync37(bridgeFile)) {
|
|
43036
|
+
const bridge = JSON.parse(readFileSync26(bridgeFile, "utf8"));
|
|
43037
|
+
try {
|
|
43038
|
+
process.kill(bridge.pid, "SIGTERM");
|
|
43039
|
+
} catch {
|
|
43040
|
+
}
|
|
43041
|
+
try {
|
|
43042
|
+
rmSync(bridgeFile);
|
|
43043
|
+
} catch {
|
|
43044
|
+
}
|
|
43045
|
+
renderInfo("Fortemi bridge stopped.");
|
|
43046
|
+
} else {
|
|
43047
|
+
renderInfo("No active fortemi bridge.");
|
|
43048
|
+
}
|
|
43049
|
+
return "handled";
|
|
43050
|
+
}
|
|
43051
|
+
renderInfo("Usage: /fortemi [start|status|stop]");
|
|
43052
|
+
return "handled";
|
|
43053
|
+
}
|
|
42696
43054
|
case "model":
|
|
42697
43055
|
if (arg) {
|
|
42698
43056
|
await switchModel(arg, ctx, hasLocal);
|
|
@@ -44147,9 +44505,9 @@ async function handleVoiceMenu(ctx, save, hasLocal) {
|
|
|
44147
44505
|
}
|
|
44148
44506
|
const { basename: basename16, join: pathJoin } = await import("node:path");
|
|
44149
44507
|
const { copyFileSync: copyFileSync2, mkdirSync: mkdirSync22, existsSync: exists } = await import("node:fs");
|
|
44150
|
-
const { homedir:
|
|
44508
|
+
const { homedir: homedir16 } = await import("node:os");
|
|
44151
44509
|
const modelName = basename16(onnxDrop.path, ".onnx").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
44152
|
-
const destDir = pathJoin(
|
|
44510
|
+
const destDir = pathJoin(homedir16(), ".open-agents", "voice", "models", modelName);
|
|
44153
44511
|
if (!exists(destDir))
|
|
44154
44512
|
mkdirSync22(destDir, { recursive: true });
|
|
44155
44513
|
copyFileSync2(onnxDrop.path, pathJoin(destDir, "model.onnx"));
|
|
@@ -44644,8 +45002,8 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
|
|
|
44644
45002
|
if (models.length > 0) {
|
|
44645
45003
|
try {
|
|
44646
45004
|
const { writeFileSync: writeFileSync21, mkdirSync: mkdirSync22 } = await import("node:fs");
|
|
44647
|
-
const { join:
|
|
44648
|
-
const cachePath =
|
|
45005
|
+
const { join: join66, dirname: dirname21 } = await import("node:path");
|
|
45006
|
+
const cachePath = join66(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
|
|
44649
45007
|
mkdirSync22(dirname21(cachePath), { recursive: true });
|
|
44650
45008
|
writeFileSync21(cachePath, JSON.stringify({
|
|
44651
45009
|
peerId,
|
|
@@ -44846,17 +45204,17 @@ async function handleUpdate(subcommand, ctx) {
|
|
|
44846
45204
|
try {
|
|
44847
45205
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
44848
45206
|
const { fileURLToPath: fileURLToPath14 } = await import("node:url");
|
|
44849
|
-
const { dirname: dirname21, join:
|
|
44850
|
-
const { existsSync:
|
|
45207
|
+
const { dirname: dirname21, join: join66 } = await import("node:path");
|
|
45208
|
+
const { existsSync: existsSync47 } = await import("node:fs");
|
|
44851
45209
|
const req = createRequire4(import.meta.url);
|
|
44852
45210
|
const thisDir = dirname21(fileURLToPath14(import.meta.url));
|
|
44853
45211
|
const candidates = [
|
|
44854
|
-
|
|
44855
|
-
|
|
44856
|
-
|
|
45212
|
+
join66(thisDir, "..", "package.json"),
|
|
45213
|
+
join66(thisDir, "..", "..", "package.json"),
|
|
45214
|
+
join66(thisDir, "..", "..", "..", "package.json")
|
|
44857
45215
|
];
|
|
44858
45216
|
for (const pkgPath of candidates) {
|
|
44859
|
-
if (
|
|
45217
|
+
if (existsSync47(pkgPath)) {
|
|
44860
45218
|
const pkg = req(pkgPath);
|
|
44861
45219
|
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
|
|
44862
45220
|
currentVersion = pkg.version ?? "0.0.0";
|
|
@@ -45693,10 +46051,10 @@ var init_commands = __esm({
|
|
|
45693
46051
|
});
|
|
45694
46052
|
|
|
45695
46053
|
// packages/cli/dist/tui/project-context.js
|
|
45696
|
-
import { existsSync as
|
|
45697
|
-
import { join as
|
|
46054
|
+
import { existsSync as existsSync38, readFileSync as readFileSync27, readdirSync as readdirSync11 } from "node:fs";
|
|
46055
|
+
import { join as join53, basename as basename10 } from "node:path";
|
|
45698
46056
|
import { execSync as execSync27 } from "node:child_process";
|
|
45699
|
-
import { homedir as
|
|
46057
|
+
import { homedir as homedir13, platform as platform3, release } from "node:os";
|
|
45700
46058
|
function getModelTier(modelName) {
|
|
45701
46059
|
const m = modelName.toLowerCase();
|
|
45702
46060
|
const sizeMatch = m.match(/\b(\d+)b\b/);
|
|
@@ -45729,10 +46087,10 @@ function loadProjectMap(repoRoot) {
|
|
|
45729
46087
|
if (!hasOaDirectory(repoRoot)) {
|
|
45730
46088
|
initOaDirectory(repoRoot);
|
|
45731
46089
|
}
|
|
45732
|
-
const mapPath =
|
|
45733
|
-
if (
|
|
46090
|
+
const mapPath = join53(repoRoot, OA_DIR, "context", "project-map.md");
|
|
46091
|
+
if (existsSync38(mapPath)) {
|
|
45734
46092
|
try {
|
|
45735
|
-
const content =
|
|
46093
|
+
const content = readFileSync27(mapPath, "utf-8");
|
|
45736
46094
|
return content;
|
|
45737
46095
|
} catch {
|
|
45738
46096
|
}
|
|
@@ -45773,31 +46131,31 @@ ${log}`);
|
|
|
45773
46131
|
}
|
|
45774
46132
|
function loadMemoryContext(repoRoot) {
|
|
45775
46133
|
const sections = [];
|
|
45776
|
-
const oaMemDir =
|
|
46134
|
+
const oaMemDir = join53(repoRoot, OA_DIR, "memory");
|
|
45777
46135
|
const oaEntries = loadMemoryDir(oaMemDir, "project");
|
|
45778
46136
|
if (oaEntries)
|
|
45779
46137
|
sections.push(oaEntries);
|
|
45780
|
-
const legacyMemDir =
|
|
45781
|
-
if (legacyMemDir !== oaMemDir &&
|
|
46138
|
+
const legacyMemDir = join53(repoRoot, ".open-agents", "memory");
|
|
46139
|
+
if (legacyMemDir !== oaMemDir && existsSync38(legacyMemDir)) {
|
|
45782
46140
|
const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
|
|
45783
46141
|
if (legacyEntries)
|
|
45784
46142
|
sections.push(legacyEntries);
|
|
45785
46143
|
}
|
|
45786
|
-
const globalMemDir =
|
|
46144
|
+
const globalMemDir = join53(homedir13(), ".open-agents", "memory");
|
|
45787
46145
|
const globalEntries = loadMemoryDir(globalMemDir, "global");
|
|
45788
46146
|
if (globalEntries)
|
|
45789
46147
|
sections.push(globalEntries);
|
|
45790
46148
|
return sections.join("\n\n");
|
|
45791
46149
|
}
|
|
45792
46150
|
function loadMemoryDir(memDir, scope) {
|
|
45793
|
-
if (!
|
|
46151
|
+
if (!existsSync38(memDir))
|
|
45794
46152
|
return "";
|
|
45795
46153
|
const lines = [];
|
|
45796
46154
|
try {
|
|
45797
46155
|
const files = readdirSync11(memDir).filter((f) => f.endsWith(".json"));
|
|
45798
46156
|
for (const file of files.slice(0, 10)) {
|
|
45799
46157
|
try {
|
|
45800
|
-
const raw =
|
|
46158
|
+
const raw = readFileSync27(join53(memDir, file), "utf-8");
|
|
45801
46159
|
const entries = JSON.parse(raw);
|
|
45802
46160
|
const topic = basename10(file, ".json");
|
|
45803
46161
|
const keys = Object.keys(entries);
|
|
@@ -47316,22 +47674,22 @@ var init_banner = __esm({
|
|
|
47316
47674
|
});
|
|
47317
47675
|
|
|
47318
47676
|
// packages/cli/dist/tui/carousel-descriptors.js
|
|
47319
|
-
import { existsSync as
|
|
47320
|
-
import { join as
|
|
47677
|
+
import { existsSync as existsSync39, readFileSync as readFileSync28, writeFileSync as writeFileSync16, mkdirSync as mkdirSync15, readdirSync as readdirSync12 } from "node:fs";
|
|
47678
|
+
import { join as join54, basename as basename11 } from "node:path";
|
|
47321
47679
|
function loadToolProfile(repoRoot) {
|
|
47322
|
-
const filePath =
|
|
47680
|
+
const filePath = join54(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
47323
47681
|
try {
|
|
47324
|
-
if (!
|
|
47682
|
+
if (!existsSync39(filePath))
|
|
47325
47683
|
return null;
|
|
47326
|
-
return JSON.parse(
|
|
47684
|
+
return JSON.parse(readFileSync28(filePath, "utf-8"));
|
|
47327
47685
|
} catch {
|
|
47328
47686
|
return null;
|
|
47329
47687
|
}
|
|
47330
47688
|
}
|
|
47331
47689
|
function saveToolProfile(repoRoot, profile) {
|
|
47332
|
-
const contextDir =
|
|
47690
|
+
const contextDir = join54(repoRoot, OA_DIR, "context");
|
|
47333
47691
|
mkdirSync15(contextDir, { recursive: true });
|
|
47334
|
-
writeFileSync16(
|
|
47692
|
+
writeFileSync16(join54(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
|
|
47335
47693
|
}
|
|
47336
47694
|
function categorizeToolCall(toolName) {
|
|
47337
47695
|
for (const cat of TOOL_CATEGORIES) {
|
|
@@ -47389,25 +47747,25 @@ function weightedColor(profile) {
|
|
|
47389
47747
|
return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
|
|
47390
47748
|
}
|
|
47391
47749
|
function loadCachedDescriptors(repoRoot) {
|
|
47392
|
-
const filePath =
|
|
47750
|
+
const filePath = join54(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
|
|
47393
47751
|
try {
|
|
47394
|
-
if (!
|
|
47752
|
+
if (!existsSync39(filePath))
|
|
47395
47753
|
return null;
|
|
47396
|
-
const cached = JSON.parse(
|
|
47754
|
+
const cached = JSON.parse(readFileSync28(filePath, "utf-8"));
|
|
47397
47755
|
return cached.phrases.length > 0 ? cached.phrases : null;
|
|
47398
47756
|
} catch {
|
|
47399
47757
|
return null;
|
|
47400
47758
|
}
|
|
47401
47759
|
}
|
|
47402
47760
|
function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
47403
|
-
const contextDir =
|
|
47761
|
+
const contextDir = join54(repoRoot, OA_DIR, "context");
|
|
47404
47762
|
mkdirSync15(contextDir, { recursive: true });
|
|
47405
47763
|
const cached = {
|
|
47406
47764
|
phrases,
|
|
47407
47765
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
47408
47766
|
sourceHash
|
|
47409
47767
|
};
|
|
47410
|
-
writeFileSync16(
|
|
47768
|
+
writeFileSync16(join54(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
47411
47769
|
}
|
|
47412
47770
|
function generateDescriptors(repoRoot) {
|
|
47413
47771
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -47455,11 +47813,11 @@ function generateDescriptors(repoRoot) {
|
|
|
47455
47813
|
return phrases;
|
|
47456
47814
|
}
|
|
47457
47815
|
function extractFromPackageJson(repoRoot, tags) {
|
|
47458
|
-
const pkgPath =
|
|
47816
|
+
const pkgPath = join54(repoRoot, "package.json");
|
|
47459
47817
|
try {
|
|
47460
|
-
if (!
|
|
47818
|
+
if (!existsSync39(pkgPath))
|
|
47461
47819
|
return;
|
|
47462
|
-
const pkg = JSON.parse(
|
|
47820
|
+
const pkg = JSON.parse(readFileSync28(pkgPath, "utf-8"));
|
|
47463
47821
|
if (pkg.name && typeof pkg.name === "string") {
|
|
47464
47822
|
const parts = pkg.name.replace(/^@/, "").split("/");
|
|
47465
47823
|
for (const p of parts)
|
|
@@ -47503,7 +47861,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
47503
47861
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
47504
47862
|
];
|
|
47505
47863
|
for (const check of manifestChecks) {
|
|
47506
|
-
if (
|
|
47864
|
+
if (existsSync39(join54(repoRoot, check.file))) {
|
|
47507
47865
|
tags.push(check.tag);
|
|
47508
47866
|
}
|
|
47509
47867
|
}
|
|
@@ -47525,16 +47883,16 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
47525
47883
|
}
|
|
47526
47884
|
}
|
|
47527
47885
|
function extractFromMemory(repoRoot, tags) {
|
|
47528
|
-
const memoryDir =
|
|
47886
|
+
const memoryDir = join54(repoRoot, OA_DIR, "memory");
|
|
47529
47887
|
try {
|
|
47530
|
-
if (!
|
|
47888
|
+
if (!existsSync39(memoryDir))
|
|
47531
47889
|
return;
|
|
47532
47890
|
const files = readdirSync12(memoryDir).filter((f) => f.endsWith(".json"));
|
|
47533
47891
|
for (const file of files) {
|
|
47534
47892
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
47535
47893
|
tags.push(topic);
|
|
47536
47894
|
try {
|
|
47537
|
-
const data = JSON.parse(
|
|
47895
|
+
const data = JSON.parse(readFileSync28(join54(memoryDir, file), "utf-8"));
|
|
47538
47896
|
if (data && typeof data === "object") {
|
|
47539
47897
|
const keys = Object.keys(data).slice(0, 3);
|
|
47540
47898
|
for (const key of keys) {
|
|
@@ -48168,10 +48526,10 @@ var init_stream_renderer = __esm({
|
|
|
48168
48526
|
|
|
48169
48527
|
// packages/cli/dist/tui/edit-history.js
|
|
48170
48528
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync16 } from "node:fs";
|
|
48171
|
-
import { join as
|
|
48529
|
+
import { join as join55 } from "node:path";
|
|
48172
48530
|
function createEditHistoryLogger(repoRoot, sessionId) {
|
|
48173
|
-
const historyDir =
|
|
48174
|
-
const logPath =
|
|
48531
|
+
const historyDir = join55(repoRoot, ".oa", "history");
|
|
48532
|
+
const logPath = join55(historyDir, "edits.jsonl");
|
|
48175
48533
|
try {
|
|
48176
48534
|
mkdirSync16(historyDir, { recursive: true });
|
|
48177
48535
|
} catch {
|
|
@@ -48282,17 +48640,17 @@ var init_edit_history = __esm({
|
|
|
48282
48640
|
});
|
|
48283
48641
|
|
|
48284
48642
|
// packages/cli/dist/tui/promptLoader.js
|
|
48285
|
-
import { readFileSync as
|
|
48286
|
-
import { join as
|
|
48643
|
+
import { readFileSync as readFileSync29, existsSync as existsSync40 } from "node:fs";
|
|
48644
|
+
import { join as join56, dirname as dirname18 } from "node:path";
|
|
48287
48645
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
48288
48646
|
function loadPrompt3(promptPath, vars) {
|
|
48289
48647
|
let content = cache3.get(promptPath);
|
|
48290
48648
|
if (content === void 0) {
|
|
48291
|
-
const fullPath =
|
|
48292
|
-
if (!
|
|
48649
|
+
const fullPath = join56(PROMPTS_DIR3, promptPath);
|
|
48650
|
+
if (!existsSync40(fullPath)) {
|
|
48293
48651
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
48294
48652
|
}
|
|
48295
|
-
content =
|
|
48653
|
+
content = readFileSync29(fullPath, "utf-8");
|
|
48296
48654
|
cache3.set(promptPath, content);
|
|
48297
48655
|
}
|
|
48298
48656
|
if (!vars)
|
|
@@ -48305,23 +48663,23 @@ var init_promptLoader3 = __esm({
|
|
|
48305
48663
|
"use strict";
|
|
48306
48664
|
__filename3 = fileURLToPath11(import.meta.url);
|
|
48307
48665
|
__dirname6 = dirname18(__filename3);
|
|
48308
|
-
devPath2 =
|
|
48309
|
-
publishedPath2 =
|
|
48310
|
-
PROMPTS_DIR3 =
|
|
48666
|
+
devPath2 = join56(__dirname6, "..", "..", "prompts");
|
|
48667
|
+
publishedPath2 = join56(__dirname6, "..", "prompts");
|
|
48668
|
+
PROMPTS_DIR3 = existsSync40(devPath2) ? devPath2 : publishedPath2;
|
|
48311
48669
|
cache3 = /* @__PURE__ */ new Map();
|
|
48312
48670
|
}
|
|
48313
48671
|
});
|
|
48314
48672
|
|
|
48315
48673
|
// packages/cli/dist/tui/dream-engine.js
|
|
48316
|
-
import { mkdirSync as mkdirSync17, writeFileSync as writeFileSync17, readFileSync as
|
|
48317
|
-
import { join as
|
|
48674
|
+
import { mkdirSync as mkdirSync17, writeFileSync as writeFileSync17, readFileSync as readFileSync30, existsSync as existsSync41, cpSync, rmSync as rmSync2, readdirSync as readdirSync13 } from "node:fs";
|
|
48675
|
+
import { join as join57, basename as basename12 } from "node:path";
|
|
48318
48676
|
import { execSync as execSync28 } from "node:child_process";
|
|
48319
48677
|
function loadAutoresearchMemory(repoRoot) {
|
|
48320
|
-
const memoryPath =
|
|
48321
|
-
if (!
|
|
48678
|
+
const memoryPath = join57(repoRoot, ".oa", "memory", "autoresearch.json");
|
|
48679
|
+
if (!existsSync41(memoryPath))
|
|
48322
48680
|
return "";
|
|
48323
48681
|
try {
|
|
48324
|
-
const raw =
|
|
48682
|
+
const raw = readFileSync30(memoryPath, "utf-8");
|
|
48325
48683
|
const data = JSON.parse(raw);
|
|
48326
48684
|
const sections = [];
|
|
48327
48685
|
for (const key of AUTORESEARCH_MEMORY_KEYS) {
|
|
@@ -48511,12 +48869,12 @@ var init_dream_engine = __esm({
|
|
|
48511
48869
|
const content = String(args["content"] ?? "");
|
|
48512
48870
|
if (!rawPath)
|
|
48513
48871
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
48514
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
48872
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join57(this.autoresearchDir, basename12(rawPath)) : join57(this.autoresearchDir, rawPath);
|
|
48515
48873
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
48516
48874
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
48517
48875
|
}
|
|
48518
48876
|
try {
|
|
48519
|
-
const dir =
|
|
48877
|
+
const dir = join57(targetPath, "..");
|
|
48520
48878
|
mkdirSync17(dir, { recursive: true });
|
|
48521
48879
|
writeFileSync17(targetPath, content, "utf-8");
|
|
48522
48880
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
@@ -48546,15 +48904,15 @@ var init_dream_engine = __esm({
|
|
|
48546
48904
|
const rawPath = String(args["path"] ?? "");
|
|
48547
48905
|
const oldStr = String(args["old_string"] ?? "");
|
|
48548
48906
|
const newStr = String(args["new_string"] ?? "");
|
|
48549
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
48907
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join57(this.autoresearchDir, basename12(rawPath)) : join57(this.autoresearchDir, rawPath);
|
|
48550
48908
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
48551
48909
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
48552
48910
|
}
|
|
48553
48911
|
try {
|
|
48554
|
-
if (!
|
|
48912
|
+
if (!existsSync41(targetPath)) {
|
|
48555
48913
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start };
|
|
48556
48914
|
}
|
|
48557
|
-
let content =
|
|
48915
|
+
let content = readFileSync30(targetPath, "utf-8");
|
|
48558
48916
|
if (!content.includes(oldStr)) {
|
|
48559
48917
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start };
|
|
48560
48918
|
}
|
|
@@ -48600,12 +48958,12 @@ var init_dream_engine = __esm({
|
|
|
48600
48958
|
const content = String(args["content"] ?? "");
|
|
48601
48959
|
if (!rawPath)
|
|
48602
48960
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
48603
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
48961
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join57(this.dreamsDir, basename12(rawPath)) : join57(this.dreamsDir, rawPath);
|
|
48604
48962
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
48605
48963
|
return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
48606
48964
|
}
|
|
48607
48965
|
try {
|
|
48608
|
-
const dir =
|
|
48966
|
+
const dir = join57(targetPath, "..");
|
|
48609
48967
|
mkdirSync17(dir, { recursive: true });
|
|
48610
48968
|
writeFileSync17(targetPath, content, "utf-8");
|
|
48611
48969
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
@@ -48635,15 +48993,15 @@ var init_dream_engine = __esm({
|
|
|
48635
48993
|
const rawPath = String(args["path"] ?? "");
|
|
48636
48994
|
const oldStr = String(args["old_string"] ?? "");
|
|
48637
48995
|
const newStr = String(args["new_string"] ?? "");
|
|
48638
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
48996
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join57(this.dreamsDir, basename12(rawPath)) : join57(this.dreamsDir, rawPath);
|
|
48639
48997
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
48640
48998
|
return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
48641
48999
|
}
|
|
48642
49000
|
try {
|
|
48643
|
-
if (!
|
|
49001
|
+
if (!existsSync41(targetPath)) {
|
|
48644
49002
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start };
|
|
48645
49003
|
}
|
|
48646
|
-
let content =
|
|
49004
|
+
let content = readFileSync30(targetPath, "utf-8");
|
|
48647
49005
|
if (!content.includes(oldStr)) {
|
|
48648
49006
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start };
|
|
48649
49007
|
}
|
|
@@ -48702,7 +49060,7 @@ var init_dream_engine = __esm({
|
|
|
48702
49060
|
constructor(config, repoRoot) {
|
|
48703
49061
|
this.config = config;
|
|
48704
49062
|
this.repoRoot = repoRoot;
|
|
48705
|
-
this.dreamsDir =
|
|
49063
|
+
this.dreamsDir = join57(repoRoot, ".oa", "dreams");
|
|
48706
49064
|
this.state = {
|
|
48707
49065
|
mode: "default",
|
|
48708
49066
|
active: false,
|
|
@@ -48786,7 +49144,7 @@ ${result.summary}`;
|
|
|
48786
49144
|
if (mode !== "default" || cycle === totalCycles) {
|
|
48787
49145
|
renderDreamContraction(cycle);
|
|
48788
49146
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
48789
|
-
const summaryPath =
|
|
49147
|
+
const summaryPath = join57(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
48790
49148
|
writeFileSync17(summaryPath, cycleSummary, "utf-8");
|
|
48791
49149
|
}
|
|
48792
49150
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
@@ -48999,7 +49357,7 @@ After synthesis, call task_complete with the final prioritized summary.`, toolMo
|
|
|
48999
49357
|
}
|
|
49000
49358
|
/** Build role-specific tool sets for swarm agents */
|
|
49001
49359
|
buildSwarmTools(role, _workspace) {
|
|
49002
|
-
const autoresearchDir =
|
|
49360
|
+
const autoresearchDir = join57(this.repoRoot, ".oa", "autoresearch");
|
|
49003
49361
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
49004
49362
|
switch (role) {
|
|
49005
49363
|
case "researcher": {
|
|
@@ -49363,7 +49721,7 @@ INSTRUCTIONS:
|
|
|
49363
49721
|
2. Summarize the key learnings and next steps
|
|
49364
49722
|
|
|
49365
49723
|
Call task_complete with a human-readable summary of the autoresearch session.`, workspace, onEvent);
|
|
49366
|
-
const reportPath =
|
|
49724
|
+
const reportPath = join57(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
49367
49725
|
const report = `# Autoresearch Swarm Report \u2014 Cycle ${cycleNum}
|
|
49368
49726
|
|
|
49369
49727
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -49452,7 +49810,7 @@ ${summaryResult}
|
|
|
49452
49810
|
}
|
|
49453
49811
|
/** Save workspace backup for lucid mode */
|
|
49454
49812
|
saveVersionCheckpoint(cycle) {
|
|
49455
|
-
const checkpointDir =
|
|
49813
|
+
const checkpointDir = join57(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
49456
49814
|
try {
|
|
49457
49815
|
mkdirSync17(checkpointDir, { recursive: true });
|
|
49458
49816
|
try {
|
|
@@ -49471,10 +49829,10 @@ ${summaryResult}
|
|
|
49471
49829
|
encoding: "utf-8",
|
|
49472
49830
|
timeout: 5e3
|
|
49473
49831
|
}).trim();
|
|
49474
|
-
writeFileSync17(
|
|
49475
|
-
writeFileSync17(
|
|
49476
|
-
writeFileSync17(
|
|
49477
|
-
writeFileSync17(
|
|
49832
|
+
writeFileSync17(join57(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
|
|
49833
|
+
writeFileSync17(join57(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
|
|
49834
|
+
writeFileSync17(join57(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
|
|
49835
|
+
writeFileSync17(join57(checkpointDir, "checkpoint.json"), JSON.stringify({
|
|
49478
49836
|
cycle,
|
|
49479
49837
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
49480
49838
|
gitHash,
|
|
@@ -49482,7 +49840,7 @@ ${summaryResult}
|
|
|
49482
49840
|
}, null, 2), "utf-8");
|
|
49483
49841
|
renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
49484
49842
|
} catch {
|
|
49485
|
-
writeFileSync17(
|
|
49843
|
+
writeFileSync17(join57(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
|
|
49486
49844
|
renderInfo(`Checkpoint saved: cycle ${cycle} (no git)`);
|
|
49487
49845
|
}
|
|
49488
49846
|
} catch (err) {
|
|
@@ -49540,14 +49898,14 @@ ${files.map((f) => `- [\`${f}\`](./${f})`).join("\n")}
|
|
|
49540
49898
|
---
|
|
49541
49899
|
*Auto-generated by open-agents dream engine*
|
|
49542
49900
|
`;
|
|
49543
|
-
writeFileSync17(
|
|
49901
|
+
writeFileSync17(join57(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
49544
49902
|
} catch {
|
|
49545
49903
|
}
|
|
49546
49904
|
}
|
|
49547
49905
|
/** Save dream state for resume/inspection */
|
|
49548
49906
|
saveDreamState() {
|
|
49549
49907
|
try {
|
|
49550
|
-
writeFileSync17(
|
|
49908
|
+
writeFileSync17(join57(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
49551
49909
|
} catch {
|
|
49552
49910
|
}
|
|
49553
49911
|
}
|
|
@@ -49921,8 +50279,8 @@ var init_bless_engine = __esm({
|
|
|
49921
50279
|
});
|
|
49922
50280
|
|
|
49923
50281
|
// packages/cli/dist/tui/dmn-engine.js
|
|
49924
|
-
import { existsSync as
|
|
49925
|
-
import { join as
|
|
50282
|
+
import { existsSync as existsSync42, readFileSync as readFileSync31, writeFileSync as writeFileSync18, mkdirSync as mkdirSync18, readdirSync as readdirSync14, unlinkSync as unlinkSync9 } from "node:fs";
|
|
50283
|
+
import { join as join58, basename as basename13 } from "node:path";
|
|
49926
50284
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
49927
50285
|
const competenceReport = competence.length > 0 ? competence.map((c3) => {
|
|
49928
50286
|
const rate = c3.attempts > 0 ? Math.round(c3.successes / c3.attempts * 100) : 0;
|
|
@@ -50035,8 +50393,8 @@ var init_dmn_engine = __esm({
|
|
|
50035
50393
|
constructor(config, repoRoot) {
|
|
50036
50394
|
this.config = config;
|
|
50037
50395
|
this.repoRoot = repoRoot;
|
|
50038
|
-
this.stateDir =
|
|
50039
|
-
this.historyDir =
|
|
50396
|
+
this.stateDir = join58(repoRoot, ".oa", "dmn");
|
|
50397
|
+
this.historyDir = join58(repoRoot, ".oa", "dmn", "cycles");
|
|
50040
50398
|
mkdirSync18(this.historyDir, { recursive: true });
|
|
50041
50399
|
this.loadState();
|
|
50042
50400
|
}
|
|
@@ -50626,11 +50984,11 @@ OUTPUT: Call task_complete with JSON:
|
|
|
50626
50984
|
async gatherMemoryTopics() {
|
|
50627
50985
|
const topics = [];
|
|
50628
50986
|
const dirs = [
|
|
50629
|
-
|
|
50630
|
-
|
|
50987
|
+
join58(this.repoRoot, ".oa", "memory"),
|
|
50988
|
+
join58(this.repoRoot, ".open-agents", "memory")
|
|
50631
50989
|
];
|
|
50632
50990
|
for (const dir of dirs) {
|
|
50633
|
-
if (!
|
|
50991
|
+
if (!existsSync42(dir))
|
|
50634
50992
|
continue;
|
|
50635
50993
|
try {
|
|
50636
50994
|
const files = readdirSync14(dir).filter((f) => f.endsWith(".json"));
|
|
@@ -50646,29 +51004,29 @@ OUTPUT: Call task_complete with JSON:
|
|
|
50646
51004
|
}
|
|
50647
51005
|
// ── State persistence ─────────────────────────────────────────────────
|
|
50648
51006
|
loadState() {
|
|
50649
|
-
const path =
|
|
50650
|
-
if (
|
|
51007
|
+
const path = join58(this.stateDir, "state.json");
|
|
51008
|
+
if (existsSync42(path)) {
|
|
50651
51009
|
try {
|
|
50652
|
-
this.state = JSON.parse(
|
|
51010
|
+
this.state = JSON.parse(readFileSync31(path, "utf-8"));
|
|
50653
51011
|
} catch {
|
|
50654
51012
|
}
|
|
50655
51013
|
}
|
|
50656
51014
|
}
|
|
50657
51015
|
saveState() {
|
|
50658
51016
|
try {
|
|
50659
|
-
writeFileSync18(
|
|
51017
|
+
writeFileSync18(join58(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
50660
51018
|
} catch {
|
|
50661
51019
|
}
|
|
50662
51020
|
}
|
|
50663
51021
|
saveCycleResult(result) {
|
|
50664
51022
|
try {
|
|
50665
51023
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
50666
|
-
writeFileSync18(
|
|
51024
|
+
writeFileSync18(join58(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
|
|
50667
51025
|
const files = readdirSync14(this.historyDir).filter((f) => f.startsWith("cycle-") && f.endsWith(".json")).sort();
|
|
50668
51026
|
if (files.length > 50) {
|
|
50669
51027
|
for (const old of files.slice(0, files.length - 50)) {
|
|
50670
51028
|
try {
|
|
50671
|
-
unlinkSync9(
|
|
51029
|
+
unlinkSync9(join58(this.historyDir, old));
|
|
50672
51030
|
} catch {
|
|
50673
51031
|
}
|
|
50674
51032
|
}
|
|
@@ -50681,8 +51039,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
50681
51039
|
});
|
|
50682
51040
|
|
|
50683
51041
|
// packages/cli/dist/tui/snr-engine.js
|
|
50684
|
-
import { existsSync as
|
|
50685
|
-
import { join as
|
|
51042
|
+
import { existsSync as existsSync43, readdirSync as readdirSync15, readFileSync as readFileSync32 } from "node:fs";
|
|
51043
|
+
import { join as join59, basename as basename14 } from "node:path";
|
|
50686
51044
|
function computeDPrime(signalScores, noiseScores) {
|
|
50687
51045
|
if (signalScores.length === 0 || noiseScores.length === 0)
|
|
50688
51046
|
return 0;
|
|
@@ -50922,11 +51280,11 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
50922
51280
|
loadMemoryEntries(topics) {
|
|
50923
51281
|
const entries = [];
|
|
50924
51282
|
const dirs = [
|
|
50925
|
-
|
|
50926
|
-
|
|
51283
|
+
join59(this.repoRoot, ".oa", "memory"),
|
|
51284
|
+
join59(this.repoRoot, ".open-agents", "memory")
|
|
50927
51285
|
];
|
|
50928
51286
|
for (const dir of dirs) {
|
|
50929
|
-
if (!
|
|
51287
|
+
if (!existsSync43(dir))
|
|
50930
51288
|
continue;
|
|
50931
51289
|
try {
|
|
50932
51290
|
const files = readdirSync15(dir).filter((f) => f.endsWith(".json"));
|
|
@@ -50935,7 +51293,7 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
50935
51293
|
if (topics.length > 0 && !topics.includes(topic))
|
|
50936
51294
|
continue;
|
|
50937
51295
|
try {
|
|
50938
|
-
const data = JSON.parse(
|
|
51296
|
+
const data = JSON.parse(readFileSync32(join59(dir, f), "utf-8"));
|
|
50939
51297
|
for (const [key, val] of Object.entries(data)) {
|
|
50940
51298
|
const value = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
50941
51299
|
entries.push({ topic, key, value });
|
|
@@ -51502,8 +51860,8 @@ var init_tool_policy = __esm({
|
|
|
51502
51860
|
});
|
|
51503
51861
|
|
|
51504
51862
|
// packages/cli/dist/tui/telegram-bridge.js
|
|
51505
|
-
import { mkdirSync as mkdirSync19, existsSync as
|
|
51506
|
-
import { join as
|
|
51863
|
+
import { mkdirSync as mkdirSync19, existsSync as existsSync44, unlinkSync as unlinkSync10, readdirSync as readdirSync16, statSync as statSync14 } from "node:fs";
|
|
51864
|
+
import { join as join60, resolve as resolve28 } from "node:path";
|
|
51507
51865
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
51508
51866
|
function convertMarkdownToTelegramHTML(md) {
|
|
51509
51867
|
let html = md;
|
|
@@ -52268,7 +52626,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
|
|
|
52268
52626
|
return null;
|
|
52269
52627
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
52270
52628
|
const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension}`;
|
|
52271
|
-
const localPath =
|
|
52629
|
+
const localPath = join60(this.mediaCacheDir, fileName);
|
|
52272
52630
|
await writeFileAsync(localPath, buffer);
|
|
52273
52631
|
return localPath;
|
|
52274
52632
|
} catch {
|
|
@@ -53602,7 +53960,7 @@ var init_text_selection = __esm({
|
|
|
53602
53960
|
});
|
|
53603
53961
|
|
|
53604
53962
|
// packages/cli/dist/tui/status-bar.js
|
|
53605
|
-
import { readFileSync as
|
|
53963
|
+
import { readFileSync as readFileSync33 } from "node:fs";
|
|
53606
53964
|
function setTerminalTitle(task, version) {
|
|
53607
53965
|
if (!process.stdout.isTTY)
|
|
53608
53966
|
return;
|
|
@@ -54277,7 +54635,7 @@ var init_status_bar = __esm({
|
|
|
54277
54635
|
if (nexusDir) {
|
|
54278
54636
|
try {
|
|
54279
54637
|
const metricsPath = nexusDir + "/remote-metrics.json";
|
|
54280
|
-
const raw =
|
|
54638
|
+
const raw = readFileSync33(metricsPath, "utf8");
|
|
54281
54639
|
const cached = JSON.parse(raw);
|
|
54282
54640
|
if (cached && cached.ts && Date.now() - cached.ts < 6e4) {
|
|
54283
54641
|
const m = cached.data;
|
|
@@ -55708,13 +56066,13 @@ var init_mouse_filter = __esm({
|
|
|
55708
56066
|
import * as readline2 from "node:readline";
|
|
55709
56067
|
import { Writable } from "node:stream";
|
|
55710
56068
|
import { cwd } from "node:process";
|
|
55711
|
-
import { resolve as resolve29, join as
|
|
56069
|
+
import { resolve as resolve29, join as join61, dirname as dirname19, extname as extname10 } from "node:path";
|
|
55712
56070
|
import { createRequire as createRequire2 } from "node:module";
|
|
55713
56071
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
55714
|
-
import { readFileSync as
|
|
55715
|
-
import { existsSync as
|
|
56072
|
+
import { readFileSync as readFileSync34, writeFileSync as writeFileSync19, appendFileSync as appendFileSync4, rmSync as rmSync3, readdirSync as readdirSync17, mkdirSync as mkdirSync20 } from "node:fs";
|
|
56073
|
+
import { existsSync as existsSync45 } from "node:fs";
|
|
55716
56074
|
import { execSync as execSync30 } from "node:child_process";
|
|
55717
|
-
import { homedir as
|
|
56075
|
+
import { homedir as homedir14 } from "node:os";
|
|
55718
56076
|
function formatTimeAgo(date) {
|
|
55719
56077
|
const seconds = Math.floor((Date.now() - date.getTime()) / 1e3);
|
|
55720
56078
|
if (seconds < 60)
|
|
@@ -55733,12 +56091,12 @@ function getVersion3() {
|
|
|
55733
56091
|
const require2 = createRequire2(import.meta.url);
|
|
55734
56092
|
const thisDir = dirname19(fileURLToPath12(import.meta.url));
|
|
55735
56093
|
const candidates = [
|
|
55736
|
-
|
|
55737
|
-
|
|
55738
|
-
|
|
56094
|
+
join61(thisDir, "..", "package.json"),
|
|
56095
|
+
join61(thisDir, "..", "..", "package.json"),
|
|
56096
|
+
join61(thisDir, "..", "..", "..", "package.json")
|
|
55739
56097
|
];
|
|
55740
56098
|
for (const pkgPath of candidates) {
|
|
55741
|
-
if (
|
|
56099
|
+
if (existsSync45(pkgPath)) {
|
|
55742
56100
|
const pkg = require2(pkgPath);
|
|
55743
56101
|
if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
|
|
55744
56102
|
return pkg.version ?? "0.0.0";
|
|
@@ -55959,15 +56317,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
|
|
|
55959
56317
|
function gatherMemorySnippets(root) {
|
|
55960
56318
|
const snippets = [];
|
|
55961
56319
|
const dirs = [
|
|
55962
|
-
|
|
55963
|
-
|
|
56320
|
+
join61(root, ".oa", "memory"),
|
|
56321
|
+
join61(root, ".open-agents", "memory")
|
|
55964
56322
|
];
|
|
55965
56323
|
for (const dir of dirs) {
|
|
55966
|
-
if (!
|
|
56324
|
+
if (!existsSync45(dir))
|
|
55967
56325
|
continue;
|
|
55968
56326
|
try {
|
|
55969
56327
|
for (const f of readdirSync17(dir).filter((f2) => f2.endsWith(".json"))) {
|
|
55970
|
-
const data = JSON.parse(
|
|
56328
|
+
const data = JSON.parse(readFileSync34(join61(dir, f), "utf-8"));
|
|
55971
56329
|
for (const val of Object.values(data)) {
|
|
55972
56330
|
const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
55973
56331
|
if (v.length > 10)
|
|
@@ -56102,9 +56460,9 @@ ${metabolismMemories}
|
|
|
56102
56460
|
} catch {
|
|
56103
56461
|
}
|
|
56104
56462
|
try {
|
|
56105
|
-
const archeFile =
|
|
56106
|
-
if (
|
|
56107
|
-
const variants = JSON.parse(
|
|
56463
|
+
const archeFile = join61(repoRoot, ".oa", "arche", "variants.json");
|
|
56464
|
+
if (existsSync45(archeFile)) {
|
|
56465
|
+
const variants = JSON.parse(readFileSync34(archeFile, "utf8"));
|
|
56108
56466
|
if (variants.length > 0) {
|
|
56109
56467
|
let filtered = variants;
|
|
56110
56468
|
if (taskType) {
|
|
@@ -56241,9 +56599,9 @@ ${lines.join("\n")}
|
|
|
56241
56599
|
const compactionThreshold = modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4;
|
|
56242
56600
|
let identityInjection = "";
|
|
56243
56601
|
try {
|
|
56244
|
-
const ikStateFile =
|
|
56245
|
-
if (
|
|
56246
|
-
const selfState = JSON.parse(
|
|
56602
|
+
const ikStateFile = join61(repoRoot, ".oa", "identity", "self-state.json");
|
|
56603
|
+
if (existsSync45(ikStateFile)) {
|
|
56604
|
+
const selfState = JSON.parse(readFileSync34(ikStateFile, "utf8"));
|
|
56247
56605
|
const lines = [
|
|
56248
56606
|
`[Identity State v${selfState.version}]`,
|
|
56249
56607
|
`Self: ${selfState.narrative_summary}`,
|
|
@@ -56880,11 +57238,11 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
56880
57238
|
});
|
|
56881
57239
|
}
|
|
56882
57240
|
try {
|
|
56883
|
-
const ikDir =
|
|
56884
|
-
const ikFile =
|
|
57241
|
+
const ikDir = join61(repoRoot, ".oa", "identity");
|
|
57242
|
+
const ikFile = join61(ikDir, "self-state.json");
|
|
56885
57243
|
let ikState;
|
|
56886
|
-
if (
|
|
56887
|
-
ikState = JSON.parse(
|
|
57244
|
+
if (existsSync45(ikFile)) {
|
|
57245
|
+
ikState = JSON.parse(readFileSync34(ikFile, "utf8"));
|
|
56888
57246
|
} else {
|
|
56889
57247
|
mkdirSync20(ikDir, { recursive: true });
|
|
56890
57248
|
const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
@@ -56927,9 +57285,9 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
56927
57285
|
} else {
|
|
56928
57286
|
renderTaskIncomplete(result.turns, result.toolCalls, result.durationMs, tokens);
|
|
56929
57287
|
try {
|
|
56930
|
-
const ikFile =
|
|
56931
|
-
if (
|
|
56932
|
-
const ikState = JSON.parse(
|
|
57288
|
+
const ikFile = join61(repoRoot, ".oa", "identity", "self-state.json");
|
|
57289
|
+
if (existsSync45(ikFile)) {
|
|
57290
|
+
const ikState = JSON.parse(readFileSync34(ikFile, "utf8"));
|
|
56933
57291
|
ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
|
|
56934
57292
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
56935
57293
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
@@ -57257,7 +57615,7 @@ async function startInteractive(config, repoPath) {
|
|
|
57257
57615
|
let p2pGateway = null;
|
|
57258
57616
|
let peerMesh = null;
|
|
57259
57617
|
let inferenceRouter = null;
|
|
57260
|
-
const secretVault = new SecretVault(
|
|
57618
|
+
const secretVault = new SecretVault(join61(repoRoot, ".oa", "vault.enc"));
|
|
57261
57619
|
let adminSessionKey = null;
|
|
57262
57620
|
const callSubAgents = /* @__PURE__ */ new Map();
|
|
57263
57621
|
const streamRenderer = new StreamRenderer();
|
|
@@ -57477,13 +57835,13 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
57477
57835
|
const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
|
|
57478
57836
|
return [hits, line];
|
|
57479
57837
|
}
|
|
57480
|
-
const HISTORY_DIR =
|
|
57481
|
-
const HISTORY_FILE =
|
|
57838
|
+
const HISTORY_DIR = join61(homedir14(), ".open-agents");
|
|
57839
|
+
const HISTORY_FILE = join61(HISTORY_DIR, "repl-history");
|
|
57482
57840
|
const MAX_HISTORY_LINES = 500;
|
|
57483
57841
|
let savedHistory = [];
|
|
57484
57842
|
try {
|
|
57485
|
-
if (
|
|
57486
|
-
const raw =
|
|
57843
|
+
if (existsSync45(HISTORY_FILE)) {
|
|
57844
|
+
const raw = readFileSync34(HISTORY_FILE, "utf8").trim();
|
|
57487
57845
|
if (raw)
|
|
57488
57846
|
savedHistory = raw.split("\n").reverse();
|
|
57489
57847
|
}
|
|
@@ -57572,7 +57930,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
57572
57930
|
mkdirSync20(HISTORY_DIR, { recursive: true });
|
|
57573
57931
|
appendFileSync4(HISTORY_FILE, line + "\n", "utf8");
|
|
57574
57932
|
if (Math.random() < 0.02) {
|
|
57575
|
-
const all =
|
|
57933
|
+
const all = readFileSync34(HISTORY_FILE, "utf8").trim().split("\n");
|
|
57576
57934
|
if (all.length > MAX_HISTORY_LINES) {
|
|
57577
57935
|
writeFileSync19(HISTORY_FILE, all.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
|
|
57578
57936
|
}
|
|
@@ -57750,7 +58108,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
57750
58108
|
} catch {
|
|
57751
58109
|
}
|
|
57752
58110
|
try {
|
|
57753
|
-
const oaDir =
|
|
58111
|
+
const oaDir = join61(repoRoot, ".oa");
|
|
57754
58112
|
const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
|
|
57755
58113
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
57756
58114
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -57773,7 +58131,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
57773
58131
|
} catch {
|
|
57774
58132
|
}
|
|
57775
58133
|
try {
|
|
57776
|
-
const oaDir =
|
|
58134
|
+
const oaDir = join61(repoRoot, ".oa");
|
|
57777
58135
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
|
|
57778
58136
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
57779
58137
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -58630,7 +58988,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
58630
58988
|
kind,
|
|
58631
58989
|
targetUrl,
|
|
58632
58990
|
authKey,
|
|
58633
|
-
stateDir:
|
|
58991
|
+
stateDir: join61(repoRoot, ".oa"),
|
|
58634
58992
|
passthrough: passthrough ?? false,
|
|
58635
58993
|
loadbalance: loadbalance ?? false,
|
|
58636
58994
|
endpointAuth: passthrough ? currentConfig.apiKey : void 0,
|
|
@@ -58678,7 +59036,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
58678
59036
|
await tunnelGateway.stop();
|
|
58679
59037
|
tunnelGateway = null;
|
|
58680
59038
|
}
|
|
58681
|
-
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir:
|
|
59039
|
+
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join61(repoRoot, ".oa") });
|
|
58682
59040
|
newTunnel.on("stats", (stats) => {
|
|
58683
59041
|
statusBar.setExposeStatus({
|
|
58684
59042
|
status: stats.status,
|
|
@@ -58947,10 +59305,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
58947
59305
|
writeContent(() => renderInfo(`Killed ${bgKilled} background task(s).`));
|
|
58948
59306
|
}
|
|
58949
59307
|
try {
|
|
58950
|
-
const nexusDir =
|
|
58951
|
-
const pidFile =
|
|
58952
|
-
if (
|
|
58953
|
-
const pid = parseInt(
|
|
59308
|
+
const nexusDir = join61(repoRoot, OA_DIR, "nexus");
|
|
59309
|
+
const pidFile = join61(nexusDir, "daemon.pid");
|
|
59310
|
+
if (existsSync45(pidFile)) {
|
|
59311
|
+
const pid = parseInt(readFileSync34(pidFile, "utf8").trim(), 10);
|
|
58954
59312
|
if (pid > 0) {
|
|
58955
59313
|
try {
|
|
58956
59314
|
if (process.platform === "win32") {
|
|
@@ -58972,13 +59330,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
58972
59330
|
} catch {
|
|
58973
59331
|
}
|
|
58974
59332
|
try {
|
|
58975
|
-
const voiceDir2 =
|
|
59333
|
+
const voiceDir2 = join61(homedir14(), ".open-agents", "voice");
|
|
58976
59334
|
const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
|
|
58977
59335
|
for (const pf of voicePidFiles) {
|
|
58978
|
-
const pidPath =
|
|
58979
|
-
if (
|
|
59336
|
+
const pidPath = join61(voiceDir2, pf);
|
|
59337
|
+
if (existsSync45(pidPath)) {
|
|
58980
59338
|
try {
|
|
58981
|
-
const pid = parseInt(
|
|
59339
|
+
const pid = parseInt(readFileSync34(pidPath, "utf8").trim(), 10);
|
|
58982
59340
|
if (pid > 0) {
|
|
58983
59341
|
if (process.platform === "win32") {
|
|
58984
59342
|
try {
|
|
@@ -59002,8 +59360,8 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
59002
59360
|
execSync30(process.platform === "win32" ? "timeout /t 1 /nobreak >nul" : "sleep 0.5", { timeout: 3e3, stdio: "ignore" });
|
|
59003
59361
|
} catch {
|
|
59004
59362
|
}
|
|
59005
|
-
const oaPath =
|
|
59006
|
-
if (
|
|
59363
|
+
const oaPath = join61(repoRoot, OA_DIR);
|
|
59364
|
+
if (existsSync45(oaPath)) {
|
|
59007
59365
|
let deleted = false;
|
|
59008
59366
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
59009
59367
|
try {
|
|
@@ -59375,8 +59733,8 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
59375
59733
|
}
|
|
59376
59734
|
}
|
|
59377
59735
|
const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
|
|
59378
|
-
const isImage = isImagePath(cleanPath) &&
|
|
59379
|
-
const isMedia = !isImage && isTranscribablePath(cleanPath) &&
|
|
59736
|
+
const isImage = isImagePath(cleanPath) && existsSync45(resolve29(repoRoot, cleanPath));
|
|
59737
|
+
const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync45(resolve29(repoRoot, cleanPath));
|
|
59380
59738
|
if (activeTask) {
|
|
59381
59739
|
if (activeTask.runner.isPaused) {
|
|
59382
59740
|
activeTask.runner.resume();
|
|
@@ -59385,7 +59743,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
59385
59743
|
if (isImage) {
|
|
59386
59744
|
try {
|
|
59387
59745
|
const imgPath = resolve29(repoRoot, cleanPath);
|
|
59388
|
-
const imgBuffer =
|
|
59746
|
+
const imgBuffer = readFileSync34(imgPath);
|
|
59389
59747
|
const base64 = imgBuffer.toString("base64");
|
|
59390
59748
|
const ext = extname10(cleanPath).toLowerCase();
|
|
59391
59749
|
const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
|
|
@@ -59883,11 +60241,11 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
59883
60241
|
const handle = startTask(task, config, repoRoot);
|
|
59884
60242
|
await handle.promise;
|
|
59885
60243
|
try {
|
|
59886
|
-
const ikDir =
|
|
59887
|
-
const ikFile =
|
|
60244
|
+
const ikDir = join61(repoRoot, ".oa", "identity");
|
|
60245
|
+
const ikFile = join61(ikDir, "self-state.json");
|
|
59888
60246
|
let ikState;
|
|
59889
|
-
if (
|
|
59890
|
-
ikState = JSON.parse(
|
|
60247
|
+
if (existsSync45(ikFile)) {
|
|
60248
|
+
ikState = JSON.parse(readFileSync34(ikFile, "utf8"));
|
|
59891
60249
|
} else {
|
|
59892
60250
|
mkdirSync20(ikDir, { recursive: true });
|
|
59893
60251
|
ikState = {
|
|
@@ -59920,12 +60278,12 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
59920
60278
|
ec.archiveVariantSync(`Task: ${task.slice(0, 200)}`, "success \u2014 completed", ["general"]);
|
|
59921
60279
|
} catch {
|
|
59922
60280
|
try {
|
|
59923
|
-
const archeDir =
|
|
59924
|
-
const archeFile =
|
|
60281
|
+
const archeDir = join61(repoRoot, ".oa", "arche");
|
|
60282
|
+
const archeFile = join61(archeDir, "variants.json");
|
|
59925
60283
|
let variants = [];
|
|
59926
60284
|
try {
|
|
59927
|
-
if (
|
|
59928
|
-
variants = JSON.parse(
|
|
60285
|
+
if (existsSync45(archeFile))
|
|
60286
|
+
variants = JSON.parse(readFileSync34(archeFile, "utf8"));
|
|
59929
60287
|
} catch {
|
|
59930
60288
|
}
|
|
59931
60289
|
variants.push({
|
|
@@ -59946,9 +60304,9 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
59946
60304
|
}
|
|
59947
60305
|
}
|
|
59948
60306
|
try {
|
|
59949
|
-
const metaFile =
|
|
59950
|
-
if (
|
|
59951
|
-
const store = JSON.parse(
|
|
60307
|
+
const metaFile = join61(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
60308
|
+
if (existsSync45(metaFile)) {
|
|
60309
|
+
const store = JSON.parse(readFileSync34(metaFile, "utf8"));
|
|
59952
60310
|
const surfaced = store.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
|
|
59953
60311
|
let updated = false;
|
|
59954
60312
|
for (const item of surfaced) {
|
|
@@ -60012,9 +60370,9 @@ Rules:
|
|
|
60012
60370
|
try {
|
|
60013
60371
|
const { initDb: initDb2 } = __require("@open-agents/memory");
|
|
60014
60372
|
const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
|
|
60015
|
-
const dbDir =
|
|
60373
|
+
const dbDir = join61(repoRoot, ".oa", "memory");
|
|
60016
60374
|
mkdirSync20(dbDir, { recursive: true });
|
|
60017
|
-
const db = initDb2(
|
|
60375
|
+
const db = initDb2(join61(dbDir, "structured.db"));
|
|
60018
60376
|
const memStore = new ProceduralMemoryStore2(db);
|
|
60019
60377
|
memStore.createWithEmbedding({
|
|
60020
60378
|
content: content.slice(0, 600),
|
|
@@ -60029,12 +60387,12 @@ Rules:
|
|
|
60029
60387
|
db.close();
|
|
60030
60388
|
} catch {
|
|
60031
60389
|
}
|
|
60032
|
-
const metaDir =
|
|
60033
|
-
const storeFile =
|
|
60390
|
+
const metaDir = join61(repoRoot, ".oa", "memory", "metabolism");
|
|
60391
|
+
const storeFile = join61(metaDir, "store.json");
|
|
60034
60392
|
let store = [];
|
|
60035
60393
|
try {
|
|
60036
|
-
if (
|
|
60037
|
-
store = JSON.parse(
|
|
60394
|
+
if (existsSync45(storeFile))
|
|
60395
|
+
store = JSON.parse(readFileSync34(storeFile, "utf8"));
|
|
60038
60396
|
} catch {
|
|
60039
60397
|
}
|
|
60040
60398
|
store.push({
|
|
@@ -60057,19 +60415,19 @@ Rules:
|
|
|
60057
60415
|
} catch {
|
|
60058
60416
|
}
|
|
60059
60417
|
try {
|
|
60060
|
-
const cohereSettingsFile =
|
|
60418
|
+
const cohereSettingsFile = join61(repoRoot, ".oa", "settings.json");
|
|
60061
60419
|
let cohereActive = false;
|
|
60062
60420
|
try {
|
|
60063
|
-
if (
|
|
60064
|
-
const settings = JSON.parse(
|
|
60421
|
+
if (existsSync45(cohereSettingsFile)) {
|
|
60422
|
+
const settings = JSON.parse(readFileSync34(cohereSettingsFile, "utf8"));
|
|
60065
60423
|
cohereActive = settings.cohere === true;
|
|
60066
60424
|
}
|
|
60067
60425
|
} catch {
|
|
60068
60426
|
}
|
|
60069
60427
|
if (cohereActive) {
|
|
60070
|
-
const metaFile =
|
|
60071
|
-
if (
|
|
60072
|
-
const store = JSON.parse(
|
|
60428
|
+
const metaFile = join61(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
60429
|
+
if (existsSync45(metaFile)) {
|
|
60430
|
+
const store = JSON.parse(readFileSync34(metaFile, "utf8"));
|
|
60073
60431
|
const latest = store.filter((m) => m.sourceTrace === "trajectory-extraction" || m.sourceTrace === "llm-trajectory-extraction").slice(-1)[0];
|
|
60074
60432
|
if (latest && latest.scores?.confidence >= 0.6) {
|
|
60075
60433
|
try {
|
|
@@ -60094,18 +60452,18 @@ Rules:
|
|
|
60094
60452
|
}
|
|
60095
60453
|
} catch (err) {
|
|
60096
60454
|
try {
|
|
60097
|
-
const ikFile =
|
|
60098
|
-
if (
|
|
60099
|
-
const ikState = JSON.parse(
|
|
60455
|
+
const ikFile = join61(repoRoot, ".oa", "identity", "self-state.json");
|
|
60456
|
+
if (existsSync45(ikFile)) {
|
|
60457
|
+
const ikState = JSON.parse(readFileSync34(ikFile, "utf8"));
|
|
60100
60458
|
ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
|
|
60101
60459
|
ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
|
|
60102
60460
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
60103
60461
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
60104
60462
|
writeFileSync19(ikFile, JSON.stringify(ikState, null, 2));
|
|
60105
60463
|
}
|
|
60106
|
-
const metaFile =
|
|
60107
|
-
if (
|
|
60108
|
-
const store = JSON.parse(
|
|
60464
|
+
const metaFile = join61(repoRoot, ".oa", "memory", "metabolism", "store.json");
|
|
60465
|
+
if (existsSync45(metaFile)) {
|
|
60466
|
+
const store = JSON.parse(readFileSync34(metaFile, "utf8"));
|
|
60109
60467
|
const surfaced = store.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
|
|
60110
60468
|
for (const item of surfaced) {
|
|
60111
60469
|
item.accessCount = (item.accessCount || 0) + 1;
|
|
@@ -60116,12 +60474,12 @@ Rules:
|
|
|
60116
60474
|
writeFileSync19(metaFile, JSON.stringify(store, null, 2));
|
|
60117
60475
|
}
|
|
60118
60476
|
try {
|
|
60119
|
-
const archeDir =
|
|
60120
|
-
const archeFile =
|
|
60477
|
+
const archeDir = join61(repoRoot, ".oa", "arche");
|
|
60478
|
+
const archeFile = join61(archeDir, "variants.json");
|
|
60121
60479
|
let variants = [];
|
|
60122
60480
|
try {
|
|
60123
|
-
if (
|
|
60124
|
-
variants = JSON.parse(
|
|
60481
|
+
if (existsSync45(archeFile))
|
|
60482
|
+
variants = JSON.parse(readFileSync34(archeFile, "utf8"));
|
|
60125
60483
|
} catch {
|
|
60126
60484
|
}
|
|
60127
60485
|
variants.push({
|
|
@@ -60222,7 +60580,7 @@ import { glob } from "glob";
|
|
|
60222
60580
|
import ignore from "ignore";
|
|
60223
60581
|
import { readFile as readFile22, stat as stat4 } from "node:fs/promises";
|
|
60224
60582
|
import { createHash as createHash4 } from "node:crypto";
|
|
60225
|
-
import { join as
|
|
60583
|
+
import { join as join62, relative as relative3, extname as extname11, basename as basename15 } from "node:path";
|
|
60226
60584
|
var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
|
|
60227
60585
|
var init_codebase_indexer = __esm({
|
|
60228
60586
|
"packages/indexer/dist/codebase-indexer.js"() {
|
|
@@ -60266,7 +60624,7 @@ var init_codebase_indexer = __esm({
|
|
|
60266
60624
|
const ig = ignore.default();
|
|
60267
60625
|
if (this.config.respectGitignore) {
|
|
60268
60626
|
try {
|
|
60269
|
-
const gitignoreContent = await readFile22(
|
|
60627
|
+
const gitignoreContent = await readFile22(join62(this.config.rootDir, ".gitignore"), "utf-8");
|
|
60270
60628
|
ig.add(gitignoreContent);
|
|
60271
60629
|
} catch {
|
|
60272
60630
|
}
|
|
@@ -60281,7 +60639,7 @@ var init_codebase_indexer = __esm({
|
|
|
60281
60639
|
for (const relativePath of files) {
|
|
60282
60640
|
if (ig.ignores(relativePath))
|
|
60283
60641
|
continue;
|
|
60284
|
-
const fullPath =
|
|
60642
|
+
const fullPath = join62(this.config.rootDir, relativePath);
|
|
60285
60643
|
try {
|
|
60286
60644
|
const fileStat = await stat4(fullPath);
|
|
60287
60645
|
if (fileStat.size > this.config.maxFileSize)
|
|
@@ -60327,7 +60685,7 @@ var init_codebase_indexer = __esm({
|
|
|
60327
60685
|
if (!child) {
|
|
60328
60686
|
child = {
|
|
60329
60687
|
name: part,
|
|
60330
|
-
path:
|
|
60688
|
+
path: join62(current.path, part),
|
|
60331
60689
|
type: "directory",
|
|
60332
60690
|
children: []
|
|
60333
60691
|
};
|
|
@@ -60410,13 +60768,13 @@ __export(index_repo_exports, {
|
|
|
60410
60768
|
indexRepoCommand: () => indexRepoCommand
|
|
60411
60769
|
});
|
|
60412
60770
|
import { resolve as resolve30 } from "node:path";
|
|
60413
|
-
import { existsSync as
|
|
60771
|
+
import { existsSync as existsSync46, statSync as statSync15 } from "node:fs";
|
|
60414
60772
|
import { cwd as cwd2 } from "node:process";
|
|
60415
60773
|
async function indexRepoCommand(opts, _config) {
|
|
60416
60774
|
const repoRoot = resolve30(opts.repoPath ?? cwd2());
|
|
60417
60775
|
printHeader("Index Repository");
|
|
60418
60776
|
printInfo(`Indexing: ${repoRoot}`);
|
|
60419
|
-
if (!
|
|
60777
|
+
if (!existsSync46(repoRoot)) {
|
|
60420
60778
|
printError(`Path does not exist: ${repoRoot}`);
|
|
60421
60779
|
process.exit(1);
|
|
60422
60780
|
}
|
|
@@ -60668,8 +61026,8 @@ var config_exports = {};
|
|
|
60668
61026
|
__export(config_exports, {
|
|
60669
61027
|
configCommand: () => configCommand
|
|
60670
61028
|
});
|
|
60671
|
-
import { join as
|
|
60672
|
-
import { homedir as
|
|
61029
|
+
import { join as join63, resolve as resolve31 } from "node:path";
|
|
61030
|
+
import { homedir as homedir15 } from "node:os";
|
|
60673
61031
|
import { cwd as cwd3 } from "node:process";
|
|
60674
61032
|
function redactIfSensitive(key, value) {
|
|
60675
61033
|
if (SENSITIVE_KEYS.has(key) && typeof value === "string" && value.length > 0) {
|
|
@@ -60751,7 +61109,7 @@ function handleShow(opts, config) {
|
|
|
60751
61109
|
}
|
|
60752
61110
|
}
|
|
60753
61111
|
printSection("Config File");
|
|
60754
|
-
printInfo(`~/.open-agents/config.json (${
|
|
61112
|
+
printInfo(`~/.open-agents/config.json (${join63(homedir15(), ".open-agents", "config.json")})`);
|
|
60755
61113
|
printSection("Priority Chain");
|
|
60756
61114
|
printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
|
|
60757
61115
|
printInfo(" 2. Project .oa/settings.json (--local)");
|
|
@@ -60790,7 +61148,7 @@ function handleSet(opts, _config) {
|
|
|
60790
61148
|
const coerced = coerceForSettings(key, value);
|
|
60791
61149
|
saveProjectSettings(repoRoot, { [key]: coerced });
|
|
60792
61150
|
printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value)}`);
|
|
60793
|
-
printInfo(`Saved to ${
|
|
61151
|
+
printInfo(`Saved to ${join63(repoRoot, ".oa", "settings.json")}`);
|
|
60794
61152
|
printInfo("This override applies only when running in this workspace.");
|
|
60795
61153
|
} catch (err) {
|
|
60796
61154
|
printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -61049,7 +61407,7 @@ __export(eval_exports, {
|
|
|
61049
61407
|
});
|
|
61050
61408
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
61051
61409
|
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync20 } from "node:fs";
|
|
61052
|
-
import { join as
|
|
61410
|
+
import { join as join64 } from "node:path";
|
|
61053
61411
|
async function evalCommand(opts, config) {
|
|
61054
61412
|
const suiteName = opts.suite ?? "basic";
|
|
61055
61413
|
const suite = SUITES[suiteName];
|
|
@@ -61174,9 +61532,9 @@ async function evalCommand(opts, config) {
|
|
|
61174
61532
|
process.exit(failed > 0 ? 1 : 0);
|
|
61175
61533
|
}
|
|
61176
61534
|
function createTempEvalRepo() {
|
|
61177
|
-
const dir =
|
|
61535
|
+
const dir = join64(tmpdir10(), `open-agents-eval-${Date.now()}`);
|
|
61178
61536
|
mkdirSync21(dir, { recursive: true });
|
|
61179
|
-
writeFileSync20(
|
|
61537
|
+
writeFileSync20(join64(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
|
|
61180
61538
|
return dir;
|
|
61181
61539
|
}
|
|
61182
61540
|
var BASIC_SUITE, FULL_SUITE, SUITES;
|
|
@@ -61236,7 +61594,7 @@ init_updater();
|
|
|
61236
61594
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
61237
61595
|
import { createRequire as createRequire3 } from "node:module";
|
|
61238
61596
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
61239
|
-
import { dirname as dirname20, join as
|
|
61597
|
+
import { dirname as dirname20, join as join65 } from "node:path";
|
|
61240
61598
|
|
|
61241
61599
|
// packages/cli/dist/cli.js
|
|
61242
61600
|
import { createInterface } from "node:readline";
|
|
@@ -61343,7 +61701,7 @@ init_output();
|
|
|
61343
61701
|
function getVersion4() {
|
|
61344
61702
|
try {
|
|
61345
61703
|
const require2 = createRequire3(import.meta.url);
|
|
61346
|
-
const pkgPath =
|
|
61704
|
+
const pkgPath = join65(dirname20(fileURLToPath13(import.meta.url)), "..", "package.json");
|
|
61347
61705
|
const pkg = require2(pkgPath);
|
|
61348
61706
|
return pkg.version;
|
|
61349
61707
|
} catch {
|