open-agents-ai 0.108.0 → 0.109.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 +711 -391
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7547,6 +7547,8 @@ var init_repl = __esm({
|
|
|
7547
7547
|
subCallCount = 0;
|
|
7548
7548
|
maxSubCalls;
|
|
7549
7549
|
execTimeout;
|
|
7550
|
+
/** Trajectory log for fine-tuning data collection (COHERE §Archive, RLM paper §4) */
|
|
7551
|
+
trajectory = [];
|
|
7550
7552
|
constructor(cwd4, options) {
|
|
7551
7553
|
this.cwd = cwd4;
|
|
7552
7554
|
this.llmQueryHandler = options?.llmQueryHandler ?? null;
|
|
@@ -7567,6 +7569,10 @@ var init_repl = __esm({
|
|
|
7567
7569
|
getSubCallCount() {
|
|
7568
7570
|
return this.subCallCount;
|
|
7569
7571
|
}
|
|
7572
|
+
/** Get the trajectory log for fine-tuning data collection */
|
|
7573
|
+
getTrajectory() {
|
|
7574
|
+
return [...this.trajectory];
|
|
7575
|
+
}
|
|
7570
7576
|
/**
|
|
7571
7577
|
* Pre-load a large context string into the REPL as the `context` variable.
|
|
7572
7578
|
* Used by prompt externalization (RLM paper §2, Principle 1: symbolic handle).
|
|
@@ -7621,7 +7627,15 @@ except NameError:
|
|
|
7621
7627
|
await this.startProcess();
|
|
7622
7628
|
}
|
|
7623
7629
|
const result = await this.executeCode(code);
|
|
7624
|
-
|
|
7630
|
+
const dur = performance.now() - start;
|
|
7631
|
+
this.trajectory.push({
|
|
7632
|
+
type: "repl_exec",
|
|
7633
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7634
|
+
input: code.slice(0, 1e3),
|
|
7635
|
+
output: result.output.slice(0, 500),
|
|
7636
|
+
durationMs: dur
|
|
7637
|
+
});
|
|
7638
|
+
return { ...result, durationMs: dur };
|
|
7625
7639
|
} catch (err) {
|
|
7626
7640
|
const msg = err instanceof Error ? err.message : String(err);
|
|
7627
7641
|
return { success: false, output: `REPL error: ${msg}`, error: msg, durationMs: performance.now() - start };
|
|
@@ -7729,6 +7743,35 @@ def retrieve(handle_id):
|
|
|
7729
7743
|
finally:
|
|
7730
7744
|
sock.close()
|
|
7731
7745
|
|
|
7746
|
+
def parallel_llm_query(queries):
|
|
7747
|
+
"""Run multiple llm_query calls in parallel using threads.
|
|
7748
|
+
SPRINT-style parallel reasoning (arxiv:2506.05745, COHERE Layer 3).
|
|
7749
|
+
Args:
|
|
7750
|
+
queries: List of (prompt, context) tuples or list of prompt strings
|
|
7751
|
+
Returns: List of response strings in the same order
|
|
7752
|
+
Example:
|
|
7753
|
+
results = parallel_llm_query([
|
|
7754
|
+
("Summarize this section", chunk1),
|
|
7755
|
+
("Summarize this section", chunk2),
|
|
7756
|
+
("Summarize this section", chunk3),
|
|
7757
|
+
])
|
|
7758
|
+
"""
|
|
7759
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
7760
|
+
def _run(item):
|
|
7761
|
+
if isinstance(item, (list, tuple)) and len(item) >= 2:
|
|
7762
|
+
return llm_query(item[0], item[1])
|
|
7763
|
+
return llm_query(str(item))
|
|
7764
|
+
results = [None] * len(queries)
|
|
7765
|
+
with ThreadPoolExecutor(max_workers=min(len(queries), 8)) as executor:
|
|
7766
|
+
futures = {executor.submit(_run, q): i for i, q in enumerate(queries)}
|
|
7767
|
+
for future in as_completed(futures):
|
|
7768
|
+
idx = futures[future]
|
|
7769
|
+
try:
|
|
7770
|
+
results[idx] = future.result()
|
|
7771
|
+
except Exception as e:
|
|
7772
|
+
results[idx] = f"[parallel_llm_query error: {e}]"
|
|
7773
|
+
return results
|
|
7774
|
+
|
|
7732
7775
|
# Signal REPL ready
|
|
7733
7776
|
print("__OA_REPL_READY__")
|
|
7734
7777
|
`.trim();
|
|
@@ -7788,8 +7831,16 @@ print("__OA_REPL_READY__")
|
|
|
7788
7831
|
response = { error: `Sub-call limit reached (${this.maxSubCalls})` };
|
|
7789
7832
|
} else {
|
|
7790
7833
|
this.subCallCount++;
|
|
7834
|
+
const queryStart = performance.now();
|
|
7791
7835
|
const result = await this.llmQueryHandler(req.prompt ?? "", req.context);
|
|
7792
7836
|
response = { response: result };
|
|
7837
|
+
this.trajectory.push({
|
|
7838
|
+
type: "llm_query",
|
|
7839
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7840
|
+
input: JSON.stringify({ prompt: req.prompt, context: (req.context ?? "").slice(0, 200) }),
|
|
7841
|
+
output: result.slice(0, 500),
|
|
7842
|
+
durationMs: performance.now() - queryStart
|
|
7843
|
+
});
|
|
7793
7844
|
}
|
|
7794
7845
|
}
|
|
7795
7846
|
} catch (err) {
|
|
@@ -7910,14 +7961,279 @@ print("${sentinel}")
|
|
|
7910
7961
|
}
|
|
7911
7962
|
this.ipcPath = null;
|
|
7912
7963
|
}
|
|
7964
|
+
if (this.trajectory.length > 0) {
|
|
7965
|
+
try {
|
|
7966
|
+
const { mkdirSync: mkFs, writeFileSync: writeFs } = await import("node:fs");
|
|
7967
|
+
const trajDir = join18(this.cwd, ".oa", "rlm-trajectories");
|
|
7968
|
+
mkFs(trajDir, { recursive: true });
|
|
7969
|
+
const trajFile = join18(trajDir, `trajectory-${Date.now()}.jsonl`);
|
|
7970
|
+
const lines = this.trajectory.map((e) => JSON.stringify(e)).join("\n");
|
|
7971
|
+
writeFs(trajFile, lines + "\n", "utf8");
|
|
7972
|
+
} catch {
|
|
7973
|
+
}
|
|
7974
|
+
}
|
|
7913
7975
|
this.subCallCount = 0;
|
|
7976
|
+
this.trajectory = [];
|
|
7977
|
+
}
|
|
7978
|
+
};
|
|
7979
|
+
}
|
|
7980
|
+
});
|
|
7981
|
+
|
|
7982
|
+
// packages/execution/dist/tools/memory-metabolism.js
|
|
7983
|
+
import { readFile as readFile8, writeFile as writeFile8, mkdir as mkdir4 } from "node:fs/promises";
|
|
7984
|
+
import { join as join19 } from "node:path";
|
|
7985
|
+
var MemoryMetabolismTool;
|
|
7986
|
+
var init_memory_metabolism = __esm({
|
|
7987
|
+
"packages/execution/dist/tools/memory-metabolism.js"() {
|
|
7988
|
+
"use strict";
|
|
7989
|
+
MemoryMetabolismTool = class {
|
|
7990
|
+
name = "memory_metabolize";
|
|
7991
|
+
description = "Governed memory lifecycle \u2014 classify, score, and store memories with admission control. Supports memory types: episodic (events), semantic (facts), procedural (recipes/patterns), normative (values/rules), quarantine (uncertain). Memories are scored for novelty, utility, confidence, and identity relevance. Use this for important learnings that should persist. (COHERE Layer 5, arxiv:2512.13564)";
|
|
7992
|
+
parameters = {
|
|
7993
|
+
type: "object",
|
|
7994
|
+
properties: {
|
|
7995
|
+
op: {
|
|
7996
|
+
type: "string",
|
|
7997
|
+
enum: ["admit", "consolidate", "list", "promote", "forget"],
|
|
7998
|
+
description: "Operation: admit (store new), consolidate (extract lessons from recent work), list (show memories), promote (upgrade type), forget (remove)"
|
|
7999
|
+
},
|
|
8000
|
+
memory_type: {
|
|
8001
|
+
type: "string",
|
|
8002
|
+
enum: ["episodic", "semantic", "procedural", "normative", "quarantine"],
|
|
8003
|
+
description: "Memory classification type"
|
|
8004
|
+
},
|
|
8005
|
+
content: {
|
|
8006
|
+
type: "string",
|
|
8007
|
+
description: "Memory content to store"
|
|
8008
|
+
},
|
|
8009
|
+
source: {
|
|
8010
|
+
type: "string",
|
|
8011
|
+
description: "What generated this memory (tool name, event, etc.)"
|
|
8012
|
+
},
|
|
8013
|
+
id: {
|
|
8014
|
+
type: "string",
|
|
8015
|
+
description: "Memory ID (for promote/forget operations)"
|
|
8016
|
+
}
|
|
8017
|
+
},
|
|
8018
|
+
required: ["op"]
|
|
8019
|
+
};
|
|
8020
|
+
cwd;
|
|
8021
|
+
constructor(cwd4) {
|
|
8022
|
+
this.cwd = cwd4;
|
|
8023
|
+
}
|
|
8024
|
+
async execute(args) {
|
|
8025
|
+
const op = String(args.op ?? "");
|
|
8026
|
+
const start = performance.now();
|
|
8027
|
+
try {
|
|
8028
|
+
switch (op) {
|
|
8029
|
+
case "admit":
|
|
8030
|
+
return await this.admitMemory(args, start);
|
|
8031
|
+
case "consolidate":
|
|
8032
|
+
return await this.consolidateMemories(start);
|
|
8033
|
+
case "list":
|
|
8034
|
+
return await this.listMemories(args, start);
|
|
8035
|
+
case "promote":
|
|
8036
|
+
return await this.promoteMemory(args, start);
|
|
8037
|
+
case "forget":
|
|
8038
|
+
return await this.forgetMemory(args, start);
|
|
8039
|
+
default:
|
|
8040
|
+
return { success: false, output: `Unknown op: ${op}`, error: "Invalid operation", durationMs: performance.now() - start };
|
|
8041
|
+
}
|
|
8042
|
+
} catch (err) {
|
|
8043
|
+
return { success: false, output: `Error: ${err instanceof Error ? err.message : String(err)}`, durationMs: performance.now() - start };
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
8046
|
+
// ── Admit ────────────────────────────────────────────────────────────────
|
|
8047
|
+
async admitMemory(args, start) {
|
|
8048
|
+
const content = String(args.content ?? "");
|
|
8049
|
+
const memType = args.memory_type ?? "episodic";
|
|
8050
|
+
const source = String(args.source ?? "user");
|
|
8051
|
+
if (!content.trim()) {
|
|
8052
|
+
return { success: false, output: "No content provided", error: "Empty content", durationMs: performance.now() - start };
|
|
8053
|
+
}
|
|
8054
|
+
const scores = this.scoreMemory(content, memType, source);
|
|
8055
|
+
const admissionThreshold = 0.3;
|
|
8056
|
+
const avgScore = (scores.novelty + scores.utility + scores.confidence + scores.identityRelevance) / 4;
|
|
8057
|
+
const admitted = avgScore >= admissionThreshold;
|
|
8058
|
+
const item = {
|
|
8059
|
+
id: `mem-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
8060
|
+
type: memType,
|
|
8061
|
+
content,
|
|
8062
|
+
sourceTrace: source,
|
|
8063
|
+
scores,
|
|
8064
|
+
decision: {
|
|
8065
|
+
action: admitted ? "admit" : "quarantine",
|
|
8066
|
+
reason: admitted ? `Admitted: avg score ${avgScore.toFixed(2)} >= ${admissionThreshold}` : `Quarantined: avg score ${avgScore.toFixed(2)} < ${admissionThreshold}`
|
|
8067
|
+
},
|
|
8068
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8069
|
+
lastAccessedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8070
|
+
accessCount: 0
|
|
8071
|
+
};
|
|
8072
|
+
const metaDir = join19(this.cwd, ".oa", "memory", "metabolism");
|
|
8073
|
+
await mkdir4(metaDir, { recursive: true });
|
|
8074
|
+
const store = await this.loadStore(metaDir);
|
|
8075
|
+
store.push(item);
|
|
8076
|
+
await this.saveStore(metaDir, store);
|
|
8077
|
+
return {
|
|
8078
|
+
success: true,
|
|
8079
|
+
output: `Memory ${item.decision.action}: [${item.id}] type=${memType} scores={novelty:${scores.novelty.toFixed(2)} utility:${scores.utility.toFixed(2)} confidence:${scores.confidence.toFixed(2)} identity:${scores.identityRelevance.toFixed(2)}} avg=${avgScore.toFixed(2)} \u2014 ${item.decision.reason}`,
|
|
8080
|
+
durationMs: performance.now() - start
|
|
8081
|
+
};
|
|
8082
|
+
}
|
|
8083
|
+
// ── Consolidate ──────────────────────────────────────────────────────────
|
|
8084
|
+
async consolidateMemories(start) {
|
|
8085
|
+
const trajDir = join19(this.cwd, ".oa", "rlm-trajectories");
|
|
8086
|
+
let lessons = [];
|
|
8087
|
+
try {
|
|
8088
|
+
const { readdirSync: readdirSync17, readFileSync: readFileSync33 } = await import("node:fs");
|
|
8089
|
+
const files = readdirSync17(trajDir).filter((f) => f.endsWith(".jsonl")).sort().reverse().slice(0, 3);
|
|
8090
|
+
for (const file of files) {
|
|
8091
|
+
const lines = readFileSync33(join19(trajDir, file), "utf8").split("\n").filter((l) => l.trim());
|
|
8092
|
+
for (const line of lines) {
|
|
8093
|
+
try {
|
|
8094
|
+
const entry = JSON.parse(line);
|
|
8095
|
+
if (entry.type === "llm_query") {
|
|
8096
|
+
lessons.push({
|
|
8097
|
+
type: "strategy",
|
|
8098
|
+
description: `Used llm_query for: ${entry.input.slice(0, 100)}`,
|
|
8099
|
+
context: entry.output.slice(0, 200),
|
|
8100
|
+
confidence: 0.7
|
|
8101
|
+
});
|
|
8102
|
+
} else if (entry.type === "repl_exec" && entry.output.includes("Error")) {
|
|
8103
|
+
lessons.push({
|
|
8104
|
+
type: "recovery",
|
|
8105
|
+
description: `REPL error encountered: ${entry.output.slice(0, 100)}`,
|
|
8106
|
+
context: entry.input.slice(0, 200),
|
|
8107
|
+
confidence: 0.5
|
|
8108
|
+
});
|
|
8109
|
+
}
|
|
8110
|
+
} catch {
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8113
|
+
}
|
|
8114
|
+
} catch {
|
|
8115
|
+
}
|
|
8116
|
+
if (lessons.length > 0) {
|
|
8117
|
+
const metaDir = join19(this.cwd, ".oa", "memory", "metabolism");
|
|
8118
|
+
await mkdir4(metaDir, { recursive: true });
|
|
8119
|
+
const store = await this.loadStore(metaDir);
|
|
8120
|
+
for (const lesson of lessons.slice(0, 10)) {
|
|
8121
|
+
store.push({
|
|
8122
|
+
id: `lesson-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
8123
|
+
type: lesson.type === "recovery" ? "procedural" : "procedural",
|
|
8124
|
+
content: `${lesson.description}
|
|
8125
|
+
Context: ${lesson.context}`,
|
|
8126
|
+
sourceTrace: "trajectory-consolidation",
|
|
8127
|
+
scores: { novelty: 0.6, utility: 0.7, confidence: lesson.confidence, identityRelevance: 0.3 },
|
|
8128
|
+
decision: { action: "admit", reason: "Extracted from RLM trajectory" },
|
|
8129
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8130
|
+
lastAccessedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8131
|
+
accessCount: 0
|
|
8132
|
+
});
|
|
8133
|
+
}
|
|
8134
|
+
await this.saveStore(metaDir, store);
|
|
8135
|
+
}
|
|
8136
|
+
return {
|
|
8137
|
+
success: true,
|
|
8138
|
+
output: `Consolidated ${lessons.length} lessons from recent trajectories.
|
|
8139
|
+
` + lessons.map((l, i) => ` ${i + 1}. [${l.type}] ${l.description}`).join("\n"),
|
|
8140
|
+
durationMs: performance.now() - start
|
|
8141
|
+
};
|
|
8142
|
+
}
|
|
8143
|
+
// ── List ─────────────────────────────────────────────────────────────────
|
|
8144
|
+
async listMemories(args, start) {
|
|
8145
|
+
const filterType = args.memory_type;
|
|
8146
|
+
const metaDir = join19(this.cwd, ".oa", "memory", "metabolism");
|
|
8147
|
+
const store = await this.loadStore(metaDir);
|
|
8148
|
+
const filtered = filterType ? store.filter((m) => m.type === filterType) : store;
|
|
8149
|
+
if (filtered.length === 0) {
|
|
8150
|
+
return { success: true, output: "No memories stored yet.", durationMs: performance.now() - start };
|
|
8151
|
+
}
|
|
8152
|
+
const lines = filtered.map((m) => `[${m.id}] type=${m.type} action=${m.decision.action} created=${m.createdAt.slice(0, 10)} accesses=${m.accessCount}
|
|
8153
|
+
${m.content.slice(0, 100)}${m.content.length > 100 ? "..." : ""}`);
|
|
8154
|
+
return {
|
|
8155
|
+
success: true,
|
|
8156
|
+
output: `Memory store (${filtered.length}${filterType ? ` ${filterType}` : ""} entries):
|
|
8157
|
+
${lines.join("\n")}`,
|
|
8158
|
+
durationMs: performance.now() - start
|
|
8159
|
+
};
|
|
8160
|
+
}
|
|
8161
|
+
// ── Promote ──────────────────────────────────────────────────────────────
|
|
8162
|
+
async promoteMemory(args, start) {
|
|
8163
|
+
const id = String(args.id ?? "");
|
|
8164
|
+
const newType = args.memory_type;
|
|
8165
|
+
if (!id || !newType) {
|
|
8166
|
+
return { success: false, output: "id and memory_type required", durationMs: performance.now() - start };
|
|
8167
|
+
}
|
|
8168
|
+
const metaDir = join19(this.cwd, ".oa", "memory", "metabolism");
|
|
8169
|
+
const store = await this.loadStore(metaDir);
|
|
8170
|
+
const item = store.find((m) => m.id === id);
|
|
8171
|
+
if (!item) {
|
|
8172
|
+
return { success: false, output: `Memory ${id} not found`, durationMs: performance.now() - start };
|
|
8173
|
+
}
|
|
8174
|
+
const oldType = item.type;
|
|
8175
|
+
item.type = newType;
|
|
8176
|
+
item.decision = { action: "promote", reason: `Promoted from ${oldType} to ${newType}` };
|
|
8177
|
+
await this.saveStore(metaDir, store);
|
|
8178
|
+
return {
|
|
8179
|
+
success: true,
|
|
8180
|
+
output: `Promoted ${id}: ${oldType} \u2192 ${newType}`,
|
|
8181
|
+
durationMs: performance.now() - start
|
|
8182
|
+
};
|
|
8183
|
+
}
|
|
8184
|
+
// ── Forget ───────────────────────────────────────────────────────────────
|
|
8185
|
+
async forgetMemory(args, start) {
|
|
8186
|
+
const id = String(args.id ?? "");
|
|
8187
|
+
if (!id) {
|
|
8188
|
+
return { success: false, output: "id required", durationMs: performance.now() - start };
|
|
8189
|
+
}
|
|
8190
|
+
const metaDir = join19(this.cwd, ".oa", "memory", "metabolism");
|
|
8191
|
+
const store = await this.loadStore(metaDir);
|
|
8192
|
+
const idx = store.findIndex((m) => m.id === id);
|
|
8193
|
+
if (idx === -1) {
|
|
8194
|
+
return { success: false, output: `Memory ${id} not found`, durationMs: performance.now() - start };
|
|
8195
|
+
}
|
|
8196
|
+
const removed = store.splice(idx, 1)[0];
|
|
8197
|
+
await this.saveStore(metaDir, store);
|
|
8198
|
+
return {
|
|
8199
|
+
success: true,
|
|
8200
|
+
output: `Forgotten: [${removed.id}] ${removed.content.slice(0, 60)}`,
|
|
8201
|
+
durationMs: performance.now() - start
|
|
8202
|
+
};
|
|
8203
|
+
}
|
|
8204
|
+
// ── Scoring ──────────────────────────────────────────────────────────────
|
|
8205
|
+
scoreMemory(content, type, source) {
|
|
8206
|
+
const words = content.split(/\s+/).length;
|
|
8207
|
+
const hasCode = /```|def |function |import |require/.test(content);
|
|
8208
|
+
const hasError = /error|fail|bug|fix/i.test(content);
|
|
8209
|
+
const hasPattern = /pattern|strategy|approach|lesson|tip/i.test(content);
|
|
8210
|
+
return {
|
|
8211
|
+
novelty: Math.min(1, words / 100),
|
|
8212
|
+
// longer = likely more novel
|
|
8213
|
+
utility: hasCode ? 0.8 : hasPattern ? 0.7 : hasError ? 0.6 : 0.4,
|
|
8214
|
+
confidence: source === "trajectory-consolidation" ? 0.7 : source === "user" ? 0.9 : 0.5,
|
|
8215
|
+
identityRelevance: type === "normative" ? 0.9 : type === "procedural" ? 0.6 : type === "semantic" ? 0.5 : 0.3
|
|
8216
|
+
};
|
|
8217
|
+
}
|
|
8218
|
+
// ── Store I/O ────────────────────────────────────────────────────────────
|
|
8219
|
+
async loadStore(dir) {
|
|
8220
|
+
try {
|
|
8221
|
+
const raw = await readFile8(join19(dir, "store.json"), "utf8");
|
|
8222
|
+
return JSON.parse(raw);
|
|
8223
|
+
} catch {
|
|
8224
|
+
return [];
|
|
8225
|
+
}
|
|
8226
|
+
}
|
|
8227
|
+
async saveStore(dir, items) {
|
|
8228
|
+
await mkdir4(dir, { recursive: true });
|
|
8229
|
+
await writeFile8(join19(dir, "store.json"), JSON.stringify(items, null, 2), "utf8");
|
|
7914
8230
|
}
|
|
7915
8231
|
};
|
|
7916
8232
|
}
|
|
7917
8233
|
});
|
|
7918
8234
|
|
|
7919
8235
|
// packages/execution/dist/tools/structured-read.js
|
|
7920
|
-
import { readFile as
|
|
8236
|
+
import { readFile as readFile9, stat as stat2 } from "node:fs/promises";
|
|
7921
8237
|
import { resolve as resolve15, extname as extname5 } from "node:path";
|
|
7922
8238
|
function parseCSV(text, separator = ",") {
|
|
7923
8239
|
const lines = text.split("\n").filter((l) => l.trim() !== "");
|
|
@@ -8112,7 +8428,7 @@ var init_structured_read = __esm({
|
|
|
8112
8428
|
}
|
|
8113
8429
|
}
|
|
8114
8430
|
if (format === "xlsx" || format === "pdf" || format === "docx" || format === "auto") {
|
|
8115
|
-
const buffer = await
|
|
8431
|
+
const buffer = await readFile9(fullPath);
|
|
8116
8432
|
const detected = detectBinaryFormat(buffer);
|
|
8117
8433
|
if (detected === "xlsx") {
|
|
8118
8434
|
return {
|
|
@@ -8157,7 +8473,7 @@ Or install mammoth for programmatic access.`,
|
|
|
8157
8473
|
}
|
|
8158
8474
|
}
|
|
8159
8475
|
}
|
|
8160
|
-
const text = await
|
|
8476
|
+
const text = await readFile9(fullPath, "utf-8");
|
|
8161
8477
|
switch (format) {
|
|
8162
8478
|
case "csv": {
|
|
8163
8479
|
const rows = parseCSV(text, ",");
|
|
@@ -8254,7 +8570,7 @@ ${parts.join("\n\n")}`,
|
|
|
8254
8570
|
// packages/execution/dist/tools/vision.js
|
|
8255
8571
|
import { readFileSync as readFileSync11, existsSync as existsSync14, statSync as statSync5 } from "node:fs";
|
|
8256
8572
|
import { execSync as execSync11, spawn as spawn7 } from "node:child_process";
|
|
8257
|
-
import { resolve as resolve16, extname as extname6, basename as basename5, dirname as dirname6, join as
|
|
8573
|
+
import { resolve as resolve16, extname as extname6, basename as basename5, dirname as dirname6, join as join20 } from "node:path";
|
|
8258
8574
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8259
8575
|
async function probeStation(endpoint) {
|
|
8260
8576
|
try {
|
|
@@ -8269,7 +8585,7 @@ async function probeStation(endpoint) {
|
|
|
8269
8585
|
}
|
|
8270
8586
|
}
|
|
8271
8587
|
function findStationBinary() {
|
|
8272
|
-
const oaVenvPython =
|
|
8588
|
+
const oaVenvPython = join20(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "python");
|
|
8273
8589
|
if (existsSync14(oaVenvPython)) {
|
|
8274
8590
|
try {
|
|
8275
8591
|
execSync11(`${JSON.stringify(oaVenvPython)} -c "import moondream_station"`, { stdio: "pipe", timeout: 5e3 });
|
|
@@ -8277,7 +8593,7 @@ function findStationBinary() {
|
|
|
8277
8593
|
} catch {
|
|
8278
8594
|
}
|
|
8279
8595
|
}
|
|
8280
|
-
const oaVenvBin =
|
|
8596
|
+
const oaVenvBin = join20(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "moondream-station");
|
|
8281
8597
|
if (existsSync14(oaVenvBin))
|
|
8282
8598
|
return oaVenvBin;
|
|
8283
8599
|
const thisDir = dirname6(fileURLToPath2(import.meta.url));
|
|
@@ -8629,7 +8945,7 @@ ${response}`, durationMs: performance.now() - start };
|
|
|
8629
8945
|
import { readFileSync as readFileSync12, existsSync as existsSync15 } from "node:fs";
|
|
8630
8946
|
import { execSync as execSync12 } from "node:child_process";
|
|
8631
8947
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
8632
|
-
import { join as
|
|
8948
|
+
import { join as join21, dirname as dirname7 } from "node:path";
|
|
8633
8949
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
8634
8950
|
function hasCommand2(cmd) {
|
|
8635
8951
|
try {
|
|
@@ -8753,7 +9069,7 @@ for i in range(${clicks}):
|
|
|
8753
9069
|
} catch {
|
|
8754
9070
|
}
|
|
8755
9071
|
try {
|
|
8756
|
-
const venvPy =
|
|
9072
|
+
const venvPy = join21(__dirname2, "../../../../.moondream-venv/bin/python");
|
|
8757
9073
|
execSync12(`DISPLAY=:0 ${JSON.stringify(venvPy)} -c "${pyScript}"`, { stdio: "pipe", timeout: 5e3 });
|
|
8758
9074
|
return;
|
|
8759
9075
|
} catch {
|
|
@@ -8845,7 +9161,7 @@ var init_desktop_click = __esm({
|
|
|
8845
9161
|
if (delayMs > 0) {
|
|
8846
9162
|
await new Promise((r) => setTimeout(r, delayMs));
|
|
8847
9163
|
}
|
|
8848
|
-
const screenshotPath =
|
|
9164
|
+
const screenshotPath = join21(tmpdir4(), `oa-desktop-click-${Date.now()}.png`);
|
|
8849
9165
|
captureScreenshot(screenshotPath);
|
|
8850
9166
|
const dims = getImageDimensions2(screenshotPath);
|
|
8851
9167
|
if (!dims) {
|
|
@@ -9020,7 +9336,7 @@ Screenshot: ${screenshotPath}`,
|
|
|
9020
9336
|
if (delayMs > 0) {
|
|
9021
9337
|
await new Promise((r) => setTimeout(r, delayMs));
|
|
9022
9338
|
}
|
|
9023
|
-
const screenshotPath =
|
|
9339
|
+
const screenshotPath = join21(tmpdir4(), `oa-desktop-describe-${Date.now()}.png`);
|
|
9024
9340
|
captureScreenshot(screenshotPath);
|
|
9025
9341
|
const dims = getImageDimensions2(screenshotPath);
|
|
9026
9342
|
const imageBuffer = readFileSync12(screenshotPath);
|
|
@@ -9259,7 +9575,7 @@ Language: ${language}
|
|
|
9259
9575
|
|
|
9260
9576
|
// packages/execution/dist/tools/pdf-to-text.js
|
|
9261
9577
|
import { existsSync as existsSync17, statSync as statSync7, readFileSync as readFileSync13, unlinkSync as unlinkSync3 } from "node:fs";
|
|
9262
|
-
import { resolve as resolve18, basename as basename7, join as
|
|
9578
|
+
import { resolve as resolve18, basename as basename7, join as join22 } from "node:path";
|
|
9263
9579
|
import { execSync as execSync14 } from "node:child_process";
|
|
9264
9580
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
9265
9581
|
var PdfToTextTool;
|
|
@@ -9413,7 +9729,7 @@ ${text}`,
|
|
|
9413
9729
|
if (!ocrCheck.available || !tesCheck.available || !gsCheck.available) {
|
|
9414
9730
|
return null;
|
|
9415
9731
|
}
|
|
9416
|
-
const tmpPdf =
|
|
9732
|
+
const tmpPdf = join22(tmpdir5(), `oa-ocr-${Date.now()}.pdf`);
|
|
9417
9733
|
try {
|
|
9418
9734
|
const ocrCmd = `ocrmypdf -l ${language} --skip-text ${JSON.stringify(inputPath)} ${JSON.stringify(tmpPdf)}`;
|
|
9419
9735
|
execSync14(ocrCmd, { stdio: "pipe", timeout: 6e5 });
|
|
@@ -9444,7 +9760,7 @@ ${text}`,
|
|
|
9444
9760
|
|
|
9445
9761
|
// packages/execution/dist/tools/ocr-image-advanced.js
|
|
9446
9762
|
import { existsSync as existsSync18, statSync as statSync8 } from "node:fs";
|
|
9447
|
-
import { resolve as resolve19, basename as basename8, dirname as dirname8, join as
|
|
9763
|
+
import { resolve as resolve19, basename as basename8, dirname as dirname8, join as join23 } from "node:path";
|
|
9448
9764
|
import { execSync as execSync15 } from "node:child_process";
|
|
9449
9765
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
9450
9766
|
import { homedir as homedir7, tmpdir as tmpdir6 } from "node:os";
|
|
@@ -9462,7 +9778,7 @@ function findOcrScript() {
|
|
|
9462
9778
|
return null;
|
|
9463
9779
|
}
|
|
9464
9780
|
function findPython() {
|
|
9465
|
-
const venvPython =
|
|
9781
|
+
const venvPython = join23(homedir7(), ".open-agents", "venv", "bin", "python");
|
|
9466
9782
|
if (existsSync18(venvPython)) {
|
|
9467
9783
|
try {
|
|
9468
9784
|
execSync15(`${JSON.stringify(venvPython)} -c "import cv2, pytesseract, numpy, PIL"`, {
|
|
@@ -9608,7 +9924,7 @@ var init_ocr_image_advanced = __esm({
|
|
|
9608
9924
|
cmdParts.push("--output-dir", JSON.stringify(resolve19(this.workingDir, outputDir)));
|
|
9609
9925
|
let debugDir;
|
|
9610
9926
|
if (debug) {
|
|
9611
|
-
debugDir =
|
|
9927
|
+
debugDir = join23(tmpdir6(), `oa-ocr-debug-${Date.now()}`);
|
|
9612
9928
|
cmdParts.push("--debug-dir", debugDir);
|
|
9613
9929
|
}
|
|
9614
9930
|
try {
|
|
@@ -9707,7 +10023,7 @@ var init_ocr_image_advanced = __esm({
|
|
|
9707
10023
|
if (region) {
|
|
9708
10024
|
try {
|
|
9709
10025
|
const [x, y, w, h] = region.split(",").map(Number);
|
|
9710
|
-
const croppedPath =
|
|
10026
|
+
const croppedPath = join23(tmpdir6(), `oa-ocr-crop-${Date.now()}.png`);
|
|
9711
10027
|
execSync15(`convert ${JSON.stringify(imagePath)} -crop ${w}x${h}+${x}+${y} +repage ${JSON.stringify(croppedPath)}`, { stdio: "pipe", timeout: 1e4 });
|
|
9712
10028
|
inputPath = croppedPath;
|
|
9713
10029
|
} catch {
|
|
@@ -9748,18 +10064,18 @@ Note: Advanced Python pipeline not available \u2014 install pytesseract, opencv-
|
|
|
9748
10064
|
// packages/execution/dist/tools/browser-action.js
|
|
9749
10065
|
import { execSync as execSync16, spawn as spawn8 } from "node:child_process";
|
|
9750
10066
|
import { existsSync as existsSync19, readFileSync as readFileSync14 } from "node:fs";
|
|
9751
|
-
import { join as
|
|
10067
|
+
import { join as join24, dirname as dirname9 } from "node:path";
|
|
9752
10068
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
9753
10069
|
function findScrapeScript() {
|
|
9754
10070
|
const candidates = [
|
|
9755
10071
|
// Published npm package: dist/scripts/web_scrape.py
|
|
9756
|
-
|
|
10072
|
+
join24(__dirname3, "scripts", "web_scrape.py"),
|
|
9757
10073
|
// Published npm package (from node_modules): node_modules/open-agents-ai/dist/scripts/
|
|
9758
|
-
|
|
10074
|
+
join24(__dirname3, "..", "node_modules", "open-agents-ai", "dist", "scripts", "web_scrape.py"),
|
|
9759
10075
|
// Dev monorepo: packages/execution/src/tools/../../scripts/
|
|
9760
|
-
|
|
10076
|
+
join24(__dirname3, "..", "..", "scripts", "web_scrape.py"),
|
|
9761
10077
|
// Dev monorepo alt: packages/execution/scripts/
|
|
9762
|
-
|
|
10078
|
+
join24(__dirname3, "..", "scripts", "web_scrape.py")
|
|
9763
10079
|
];
|
|
9764
10080
|
return candidates.find((p) => existsSync19(p)) || candidates[0];
|
|
9765
10081
|
}
|
|
@@ -10014,7 +10330,7 @@ var init_browser_action = __esm({
|
|
|
10014
10330
|
// packages/execution/dist/tools/autoresearch.js
|
|
10015
10331
|
import { execSync as execSync17, spawn as spawn9 } from "node:child_process";
|
|
10016
10332
|
import { existsSync as existsSync20, readFileSync as readFileSync15, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, appendFileSync, copyFileSync } from "node:fs";
|
|
10017
|
-
import { join as
|
|
10333
|
+
import { join as join25, resolve as resolve20, dirname as dirname10 } from "node:path";
|
|
10018
10334
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
10019
10335
|
function findAutoresearchScript(scriptName) {
|
|
10020
10336
|
const thisDir = dirname10(fileURLToPath6(import.meta.url));
|
|
@@ -10116,7 +10432,7 @@ Requires: NVIDIA GPU, Python 3.10+, uv (astral.sh package manager).`;
|
|
|
10116
10432
|
async execute(args) {
|
|
10117
10433
|
const start = Date.now();
|
|
10118
10434
|
const action = String(args["action"] ?? "status");
|
|
10119
|
-
const workspacePath = String(args["workspace"] ??
|
|
10435
|
+
const workspacePath = String(args["workspace"] ?? join25(this.repoRoot, ".oa", "autoresearch"));
|
|
10120
10436
|
try {
|
|
10121
10437
|
switch (action) {
|
|
10122
10438
|
case "setup":
|
|
@@ -10157,13 +10473,13 @@ Requires: NVIDIA GPU, Python 3.10+, uv (astral.sh package manager).`;
|
|
|
10157
10473
|
const prepareScript = findAutoresearchScript("autoresearch-prepare.py");
|
|
10158
10474
|
const trainScript = findAutoresearchScript("autoresearch-train.py");
|
|
10159
10475
|
if (prepareScript) {
|
|
10160
|
-
copyFileSync(prepareScript,
|
|
10476
|
+
copyFileSync(prepareScript, join25(workspace, "prepare.py"));
|
|
10161
10477
|
output.push("Copied prepare.py template");
|
|
10162
10478
|
} else {
|
|
10163
10479
|
return { success: false, output: output.join("\n"), error: "autoresearch-prepare.py template not found in distribution", durationMs: Date.now() - start };
|
|
10164
10480
|
}
|
|
10165
10481
|
if (trainScript) {
|
|
10166
|
-
copyFileSync(trainScript,
|
|
10482
|
+
copyFileSync(trainScript, join25(workspace, "train.py"));
|
|
10167
10483
|
output.push("Copied train.py template");
|
|
10168
10484
|
} else {
|
|
10169
10485
|
return { success: false, output: output.join("\n"), error: "autoresearch-train.py template not found in distribution", durationMs: Date.now() - start };
|
|
@@ -10195,7 +10511,7 @@ name = "pytorch-cu128"
|
|
|
10195
10511
|
url = "https://download.pytorch.org/whl/cu128"
|
|
10196
10512
|
explicit = true
|
|
10197
10513
|
`;
|
|
10198
|
-
writeFileSync6(
|
|
10514
|
+
writeFileSync6(join25(workspace, "pyproject.toml"), pyprojectContent, "utf-8");
|
|
10199
10515
|
output.push("Created pyproject.toml");
|
|
10200
10516
|
try {
|
|
10201
10517
|
execSync17("git rev-parse --git-dir", { cwd: workspace, encoding: "utf-8", timeout: 5e3 });
|
|
@@ -10237,7 +10553,7 @@ explicit = true
|
|
|
10237
10553
|
const e = err;
|
|
10238
10554
|
output.push(`Data prep warning: ${(e.stderr ?? e.stdout ?? "failed").slice(0, 500)}`);
|
|
10239
10555
|
}
|
|
10240
|
-
const tsvPath =
|
|
10556
|
+
const tsvPath = join25(workspace, "results.tsv");
|
|
10241
10557
|
if (!existsSync20(tsvPath)) {
|
|
10242
10558
|
writeFileSync6(tsvPath, "commit val_bpb memory_gb status description\n", "utf-8");
|
|
10243
10559
|
output.push("Created results.tsv");
|
|
@@ -10259,10 +10575,10 @@ Next steps:
|
|
|
10259
10575
|
}
|
|
10260
10576
|
// ── Run experiment ─────────────────────────────────────────────────────
|
|
10261
10577
|
async run(workspace, args, start) {
|
|
10262
|
-
if (!existsSync20(
|
|
10578
|
+
if (!existsSync20(join25(workspace, "train.py"))) {
|
|
10263
10579
|
return { success: false, output: "", error: `No train.py found in ${workspace}. Run autoresearch(action="setup") first.`, durationMs: Date.now() - start };
|
|
10264
10580
|
}
|
|
10265
|
-
if (!existsSync20(
|
|
10581
|
+
if (!existsSync20(join25(workspace, ".venv")) && existsSync20(join25(workspace, "pyproject.toml"))) {
|
|
10266
10582
|
try {
|
|
10267
10583
|
execSync17("uv sync 2>&1", { cwd: workspace, encoding: "utf-8", timeout: 3e5 });
|
|
10268
10584
|
} catch {
|
|
@@ -10270,7 +10586,7 @@ Next steps:
|
|
|
10270
10586
|
}
|
|
10271
10587
|
const timeoutMin = Number(args["timeout_minutes"] ?? 10);
|
|
10272
10588
|
const timeoutMs = timeoutMin * 60 * 1e3;
|
|
10273
|
-
const logPath =
|
|
10589
|
+
const logPath = join25(workspace, "run.log");
|
|
10274
10590
|
return new Promise((resolveResult) => {
|
|
10275
10591
|
const proc = spawn9("uv", ["run", "train.py"], {
|
|
10276
10592
|
cwd: workspace,
|
|
@@ -10341,7 +10657,7 @@ ${fullLog.slice(-2e3)}`,
|
|
|
10341
10657
|
return;
|
|
10342
10658
|
}
|
|
10343
10659
|
try {
|
|
10344
|
-
writeFileSync6(
|
|
10660
|
+
writeFileSync6(join25(workspace, ".last-result.json"), JSON.stringify(result, null, 2), "utf-8");
|
|
10345
10661
|
} catch {
|
|
10346
10662
|
}
|
|
10347
10663
|
const memGB = (result.peak_vram_mb / 1024).toFixed(1);
|
|
@@ -10377,7 +10693,7 @@ ${fullLog.slice(-2e3)}`,
|
|
|
10377
10693
|
}
|
|
10378
10694
|
// ── Results ────────────────────────────────────────────────────────────
|
|
10379
10695
|
getResults(workspace, start) {
|
|
10380
|
-
const tsvPath =
|
|
10696
|
+
const tsvPath = join25(workspace, "results.tsv");
|
|
10381
10697
|
if (!existsSync20(tsvPath)) {
|
|
10382
10698
|
return { success: false, output: "", error: `No results.tsv found. Run autoresearch(action="setup") first.`, durationMs: Date.now() - start };
|
|
10383
10699
|
}
|
|
@@ -10404,7 +10720,7 @@ ${fullLog.slice(-2e3)}`,
|
|
|
10404
10720
|
// ── Status ─────────────────────────────────────────────────────────────
|
|
10405
10721
|
getStatus(workspace, start) {
|
|
10406
10722
|
const output = [];
|
|
10407
|
-
if (!existsSync20(
|
|
10723
|
+
if (!existsSync20(join25(workspace, "train.py"))) {
|
|
10408
10724
|
return {
|
|
10409
10725
|
success: true,
|
|
10410
10726
|
output: `Autoresearch workspace not initialized at ${workspace}.
|
|
@@ -10427,7 +10743,7 @@ Run autoresearch(action="setup") to begin.`,
|
|
|
10427
10743
|
} catch {
|
|
10428
10744
|
output.push("GPU: not detected");
|
|
10429
10745
|
}
|
|
10430
|
-
const lastResultPath =
|
|
10746
|
+
const lastResultPath = join25(workspace, ".last-result.json");
|
|
10431
10747
|
if (existsSync20(lastResultPath)) {
|
|
10432
10748
|
try {
|
|
10433
10749
|
const last = JSON.parse(readFileSync15(lastResultPath, "utf-8"));
|
|
@@ -10435,20 +10751,20 @@ Run autoresearch(action="setup") to begin.`,
|
|
|
10435
10751
|
} catch {
|
|
10436
10752
|
}
|
|
10437
10753
|
}
|
|
10438
|
-
const tsvPath =
|
|
10754
|
+
const tsvPath = join25(workspace, "results.tsv");
|
|
10439
10755
|
if (existsSync20(tsvPath)) {
|
|
10440
10756
|
const lines = readFileSync15(tsvPath, "utf-8").trim().split("\n");
|
|
10441
10757
|
output.push(`Experiments recorded: ${lines.length - 1}`);
|
|
10442
10758
|
}
|
|
10443
|
-
const cacheDir =
|
|
10759
|
+
const cacheDir = join25(process.env["HOME"] ?? "~", ".cache", "autoresearch");
|
|
10444
10760
|
output.push(`Data cache: ${existsSync20(cacheDir) ? "present" : "not found"} (${cacheDir})`);
|
|
10445
10761
|
return { success: true, output: output.join("\n"), durationMs: Date.now() - start };
|
|
10446
10762
|
}
|
|
10447
10763
|
// ── Keep / Discard ─────────────────────────────────────────────────────
|
|
10448
10764
|
keepExperiment(workspace, args, start) {
|
|
10449
10765
|
const desc = String(args["description"] ?? "experiment");
|
|
10450
|
-
const tsvPath =
|
|
10451
|
-
const lastResultPath =
|
|
10766
|
+
const tsvPath = join25(workspace, "results.tsv");
|
|
10767
|
+
const lastResultPath = join25(workspace, ".last-result.json");
|
|
10452
10768
|
let valBpb = args["val_bpb"];
|
|
10453
10769
|
let memGb = args["memory_gb"];
|
|
10454
10770
|
if ((valBpb === void 0 || memGb === void 0) && existsSync20(lastResultPath)) {
|
|
@@ -10486,8 +10802,8 @@ Branch advanced. Ready for next experiment.`,
|
|
|
10486
10802
|
}
|
|
10487
10803
|
discardExperiment(workspace, args, start) {
|
|
10488
10804
|
const desc = String(args["description"] ?? "experiment");
|
|
10489
|
-
const tsvPath =
|
|
10490
|
-
const lastResultPath =
|
|
10805
|
+
const tsvPath = join25(workspace, "results.tsv");
|
|
10806
|
+
const lastResultPath = join25(workspace, ".last-result.json");
|
|
10491
10807
|
let valBpb = args["val_bpb"];
|
|
10492
10808
|
let memGb = args["memory_gb"];
|
|
10493
10809
|
if ((valBpb === void 0 || memGb === void 0) && existsSync20(lastResultPath)) {
|
|
@@ -10533,8 +10849,8 @@ train.py reverted to last kept state. Ready for next experiment.`,
|
|
|
10533
10849
|
|
|
10534
10850
|
// packages/execution/dist/tools/scheduler.js
|
|
10535
10851
|
import { execSync as execSync18, exec as execCb } from "node:child_process";
|
|
10536
|
-
import { readFile as
|
|
10537
|
-
import { resolve as resolve21, join as
|
|
10852
|
+
import { readFile as readFile10, writeFile as writeFile9, mkdir as mkdir5 } from "node:fs/promises";
|
|
10853
|
+
import { resolve as resolve21, join as join26 } from "node:path";
|
|
10538
10854
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
10539
10855
|
function isValidCron(expr) {
|
|
10540
10856
|
const parts = expr.trim().split(/\s+/);
|
|
@@ -10618,7 +10934,7 @@ function installCronJob(task, workingDir) {
|
|
|
10618
10934
|
const lines = getCurrentCrontab();
|
|
10619
10935
|
const oaBin = findOaBinary();
|
|
10620
10936
|
const logDir = resolve21(workingDir, ".oa", "scheduled", "logs");
|
|
10621
|
-
const logFile =
|
|
10937
|
+
const logFile = join26(logDir, `${task.id}.log`);
|
|
10622
10938
|
const storeFile = resolve21(workingDir, ".oa", "scheduled", "tasks.json");
|
|
10623
10939
|
const taskEscaped = task.task.replace(/'/g, "'\\''");
|
|
10624
10940
|
const taskId = task.id;
|
|
@@ -10651,7 +10967,7 @@ function listCronJobs() {
|
|
|
10651
10967
|
async function loadStore(workingDir) {
|
|
10652
10968
|
const storePath = resolve21(workingDir, ".oa", "scheduled", "tasks.json");
|
|
10653
10969
|
try {
|
|
10654
|
-
const raw = await
|
|
10970
|
+
const raw = await readFile10(storePath, "utf-8");
|
|
10655
10971
|
return JSON.parse(raw);
|
|
10656
10972
|
} catch {
|
|
10657
10973
|
return { tasks: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -10659,10 +10975,10 @@ async function loadStore(workingDir) {
|
|
|
10659
10975
|
}
|
|
10660
10976
|
async function saveStore(workingDir, store) {
|
|
10661
10977
|
const dir = resolve21(workingDir, ".oa", "scheduled");
|
|
10662
|
-
await
|
|
10663
|
-
await
|
|
10978
|
+
await mkdir5(dir, { recursive: true });
|
|
10979
|
+
await mkdir5(join26(dir, "logs"), { recursive: true });
|
|
10664
10980
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
10665
|
-
await
|
|
10981
|
+
await writeFile9(join26(dir, "tasks.json"), JSON.stringify(store, null, 2), "utf-8");
|
|
10666
10982
|
}
|
|
10667
10983
|
var SCHEDULE_PRESETS, CRON_MARKER, SchedulerTool;
|
|
10668
10984
|
var init_scheduler = __esm({
|
|
@@ -10882,7 +11198,7 @@ var init_scheduler = __esm({
|
|
|
10882
11198
|
return { success: false, output: "", error: "id is required for logs action", durationMs: performance.now() - start };
|
|
10883
11199
|
const logFile = resolve21(this.workingDir, ".oa", "scheduled", "logs", `${id}.log`);
|
|
10884
11200
|
try {
|
|
10885
|
-
const raw = await
|
|
11201
|
+
const raw = await readFile10(logFile, "utf-8");
|
|
10886
11202
|
const truncated = raw.length > 1e4 ? "...(truncated)\n" + raw.slice(-1e4) : raw;
|
|
10887
11203
|
return { success: true, output: `Logs for ${id}:
|
|
10888
11204
|
${truncated}`, durationMs: performance.now() - start };
|
|
@@ -10895,8 +11211,8 @@ ${truncated}`, durationMs: performance.now() - start };
|
|
|
10895
11211
|
});
|
|
10896
11212
|
|
|
10897
11213
|
// packages/execution/dist/tools/reminder.js
|
|
10898
|
-
import { readFile as
|
|
10899
|
-
import { resolve as resolve22, join as
|
|
11214
|
+
import { readFile as readFile11, writeFile as writeFile10, mkdir as mkdir6 } from "node:fs/promises";
|
|
11215
|
+
import { resolve as resolve22, join as join27 } from "node:path";
|
|
10900
11216
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
10901
11217
|
function parseDueTime(due) {
|
|
10902
11218
|
const lower = due.toLowerCase().trim();
|
|
@@ -10947,13 +11263,13 @@ function parseDueTime(due) {
|
|
|
10947
11263
|
}
|
|
10948
11264
|
async function getStorePath(workingDir) {
|
|
10949
11265
|
const dir = resolve22(workingDir, ".oa", "scheduled");
|
|
10950
|
-
await
|
|
10951
|
-
return
|
|
11266
|
+
await mkdir6(dir, { recursive: true });
|
|
11267
|
+
return join27(dir, STORE_FILE);
|
|
10952
11268
|
}
|
|
10953
11269
|
async function loadReminderStore(workingDir) {
|
|
10954
11270
|
const storePath = await getStorePath(workingDir);
|
|
10955
11271
|
try {
|
|
10956
|
-
const raw = await
|
|
11272
|
+
const raw = await readFile11(storePath, "utf-8");
|
|
10957
11273
|
return JSON.parse(raw);
|
|
10958
11274
|
} catch {
|
|
10959
11275
|
return { reminders: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -10962,7 +11278,7 @@ async function loadReminderStore(workingDir) {
|
|
|
10962
11278
|
async function saveReminderStore(workingDir, store) {
|
|
10963
11279
|
const storePath = await getStorePath(workingDir);
|
|
10964
11280
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
10965
|
-
await
|
|
11281
|
+
await writeFile10(storePath, JSON.stringify(store, null, 2), "utf-8");
|
|
10966
11282
|
}
|
|
10967
11283
|
async function getDueReminders(workingDir) {
|
|
10968
11284
|
const store = await loadReminderStore(workingDir);
|
|
@@ -11208,13 +11524,13 @@ var init_reminder = __esm({
|
|
|
11208
11524
|
});
|
|
11209
11525
|
|
|
11210
11526
|
// packages/execution/dist/tools/agenda.js
|
|
11211
|
-
import { readFile as
|
|
11212
|
-
import { resolve as resolve23, join as
|
|
11527
|
+
import { readFile as readFile12, writeFile as writeFile11, mkdir as mkdir7 } from "node:fs/promises";
|
|
11528
|
+
import { resolve as resolve23, join as join28 } from "node:path";
|
|
11213
11529
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
11214
11530
|
async function loadAttentionStore(workingDir) {
|
|
11215
11531
|
const storePath = resolve23(workingDir, ".oa", "scheduled", "attention.json");
|
|
11216
11532
|
try {
|
|
11217
|
-
const raw = await
|
|
11533
|
+
const raw = await readFile12(storePath, "utf-8");
|
|
11218
11534
|
return JSON.parse(raw);
|
|
11219
11535
|
} catch {
|
|
11220
11536
|
return { items: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -11222,9 +11538,9 @@ async function loadAttentionStore(workingDir) {
|
|
|
11222
11538
|
}
|
|
11223
11539
|
async function saveAttentionStore(workingDir, store) {
|
|
11224
11540
|
const dir = resolve23(workingDir, ".oa", "scheduled");
|
|
11225
|
-
await
|
|
11541
|
+
await mkdir7(dir, { recursive: true });
|
|
11226
11542
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
11227
|
-
await
|
|
11543
|
+
await writeFile11(join28(dir, "attention.json"), JSON.stringify(store, null, 2), "utf-8");
|
|
11228
11544
|
}
|
|
11229
11545
|
async function getActiveAttentionItems(workingDir) {
|
|
11230
11546
|
const store = await loadAttentionStore(workingDir);
|
|
@@ -11520,7 +11836,7 @@ ${sections.join("\n")}`,
|
|
|
11520
11836
|
async loadScheduleStore() {
|
|
11521
11837
|
try {
|
|
11522
11838
|
const storePath = resolve23(this.workingDir, ".oa", "scheduled", "tasks.json");
|
|
11523
|
-
const raw = await
|
|
11839
|
+
const raw = await readFile12(storePath, "utf-8");
|
|
11524
11840
|
const store = JSON.parse(raw);
|
|
11525
11841
|
return store.tasks ?? [];
|
|
11526
11842
|
} catch {
|
|
@@ -11534,7 +11850,7 @@ ${sections.join("\n")}`,
|
|
|
11534
11850
|
// packages/execution/dist/tools/opencode.js
|
|
11535
11851
|
import { execSync as execSync19, spawn as spawn10 } from "node:child_process";
|
|
11536
11852
|
import { existsSync as existsSync21 } from "node:fs";
|
|
11537
|
-
import { join as
|
|
11853
|
+
import { join as join29, resolve as resolve24 } from "node:path";
|
|
11538
11854
|
function findOpencode() {
|
|
11539
11855
|
for (const cmd of ["opencode"]) {
|
|
11540
11856
|
try {
|
|
@@ -11546,8 +11862,8 @@ function findOpencode() {
|
|
|
11546
11862
|
}
|
|
11547
11863
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
11548
11864
|
const candidates = [
|
|
11549
|
-
|
|
11550
|
-
|
|
11865
|
+
join29(homeDir, ".opencode", "bin", "opencode"),
|
|
11866
|
+
join29(homeDir, "bin", "opencode"),
|
|
11551
11867
|
"/usr/local/bin/opencode"
|
|
11552
11868
|
];
|
|
11553
11869
|
for (const p of candidates) {
|
|
@@ -11808,7 +12124,7 @@ var init_opencode = __esm({
|
|
|
11808
12124
|
// packages/execution/dist/tools/factory.js
|
|
11809
12125
|
import { execSync as execSync20, spawn as spawn11 } from "node:child_process";
|
|
11810
12126
|
import { existsSync as existsSync22 } from "node:fs";
|
|
11811
|
-
import { join as
|
|
12127
|
+
import { join as join30 } from "node:path";
|
|
11812
12128
|
function findDroid() {
|
|
11813
12129
|
for (const cmd of ["droid"]) {
|
|
11814
12130
|
try {
|
|
@@ -11820,8 +12136,8 @@ function findDroid() {
|
|
|
11820
12136
|
}
|
|
11821
12137
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
11822
12138
|
const candidates = [
|
|
11823
|
-
|
|
11824
|
-
|
|
12139
|
+
join30(homeDir, ".factory", "bin", "droid"),
|
|
12140
|
+
join30(homeDir, "bin", "droid"),
|
|
11825
12141
|
"/usr/local/bin/droid"
|
|
11826
12142
|
];
|
|
11827
12143
|
for (const p of candidates) {
|
|
@@ -12116,8 +12432,8 @@ var init_factory = __esm({
|
|
|
12116
12432
|
|
|
12117
12433
|
// packages/execution/dist/tools/cron-agent.js
|
|
12118
12434
|
import { execSync as execSync21 } from "node:child_process";
|
|
12119
|
-
import { readFile as
|
|
12120
|
-
import { resolve as resolve25, join as
|
|
12435
|
+
import { readFile as readFile13, writeFile as writeFile12, mkdir as mkdir8 } from "node:fs/promises";
|
|
12436
|
+
import { resolve as resolve25, join as join31 } from "node:path";
|
|
12121
12437
|
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
12122
12438
|
function isValidCron2(expr) {
|
|
12123
12439
|
const parts = expr.trim().split(/\s+/);
|
|
@@ -12203,7 +12519,7 @@ function installCronAgentJob(job, workingDir) {
|
|
|
12203
12519
|
const lines = getCurrentCrontab2();
|
|
12204
12520
|
const oaBin = findOaBinary2();
|
|
12205
12521
|
const logDir = resolve25(workingDir, ".oa", "cron-agents", "logs");
|
|
12206
|
-
const logFile =
|
|
12522
|
+
const logFile = join31(logDir, `${job.id}.log`);
|
|
12207
12523
|
const storeFile = resolve25(workingDir, ".oa", "cron-agents", "store.json");
|
|
12208
12524
|
const taskEscaped = job.task.replace(/'/g, "'\\''");
|
|
12209
12525
|
const jobId = job.id;
|
|
@@ -12233,7 +12549,7 @@ function removeCronAgentJob(jobId) {
|
|
|
12233
12549
|
async function loadStore2(workingDir) {
|
|
12234
12550
|
const storePath = resolve25(workingDir, ".oa", "cron-agents", "store.json");
|
|
12235
12551
|
try {
|
|
12236
|
-
const raw = await
|
|
12552
|
+
const raw = await readFile13(storePath, "utf-8");
|
|
12237
12553
|
return JSON.parse(raw);
|
|
12238
12554
|
} catch {
|
|
12239
12555
|
return { jobs: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -12241,10 +12557,10 @@ async function loadStore2(workingDir) {
|
|
|
12241
12557
|
}
|
|
12242
12558
|
async function saveStore2(workingDir, store) {
|
|
12243
12559
|
const dir = resolve25(workingDir, ".oa", "cron-agents");
|
|
12244
|
-
await
|
|
12245
|
-
await
|
|
12560
|
+
await mkdir8(dir, { recursive: true });
|
|
12561
|
+
await mkdir8(join31(dir, "logs"), { recursive: true });
|
|
12246
12562
|
store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12247
|
-
await
|
|
12563
|
+
await writeFile12(join31(dir, "store.json"), JSON.stringify(store, null, 2), "utf-8");
|
|
12248
12564
|
}
|
|
12249
12565
|
var LONG_HORIZON_PRESETS, CRON_AGENT_MARKER, CronAgentTool;
|
|
12250
12566
|
var init_cron_agent = __esm({
|
|
@@ -12509,7 +12825,7 @@ var init_cron_agent = __esm({
|
|
|
12509
12825
|
return { success: false, output: "", error: "id is required", durationMs: performance.now() - start };
|
|
12510
12826
|
const logFile = resolve25(this.workingDir, ".oa", "cron-agents", "logs", `${id}.log`);
|
|
12511
12827
|
try {
|
|
12512
|
-
const raw = await
|
|
12828
|
+
const raw = await readFile13(logFile, "utf-8");
|
|
12513
12829
|
const truncated = raw.length > 2e4 ? "...(truncated)\n" + raw.slice(-2e4) : raw;
|
|
12514
12830
|
return { success: true, output: `Logs for ${id}:
|
|
12515
12831
|
${truncated}`, durationMs: performance.now() - start };
|
|
@@ -12580,9 +12896,9 @@ ${truncated}`, durationMs: performance.now() - start };
|
|
|
12580
12896
|
});
|
|
12581
12897
|
|
|
12582
12898
|
// packages/execution/dist/tools/nexus.js
|
|
12583
|
-
import { readFile as
|
|
12899
|
+
import { readFile as readFile14, writeFile as writeFile13, mkdir as mkdir9, chmod, unlink, readdir as readdir3, open as fsOpen } from "node:fs/promises";
|
|
12584
12900
|
import { existsSync as existsSync23, readFileSync as readFileSync16, watch as fsWatchLocal } from "node:fs";
|
|
12585
|
-
import { resolve as resolve26, join as
|
|
12901
|
+
import { resolve as resolve26, join as join32 } from "node:path";
|
|
12586
12902
|
import { randomBytes as randomBytes7, createCipheriv, createDecipheriv, scryptSync, createHash } from "node:crypto";
|
|
12587
12903
|
import { execSync as execSync22, spawn as spawn12 } from "node:child_process";
|
|
12588
12904
|
import { hostname, userInfo } from "node:os";
|
|
@@ -14555,7 +14871,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14555
14871
|
}
|
|
14556
14872
|
async ensureDir() {
|
|
14557
14873
|
if (!existsSync23(this.nexusDir)) {
|
|
14558
|
-
await
|
|
14874
|
+
await mkdir9(this.nexusDir, { recursive: true });
|
|
14559
14875
|
}
|
|
14560
14876
|
}
|
|
14561
14877
|
async execute(args) {
|
|
@@ -14675,7 +14991,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14675
14991
|
// Daemon management
|
|
14676
14992
|
// =========================================================================
|
|
14677
14993
|
getDaemonPid() {
|
|
14678
|
-
const pidFile =
|
|
14994
|
+
const pidFile = join32(this.nexusDir, "daemon.pid");
|
|
14679
14995
|
if (!existsSync23(pidFile))
|
|
14680
14996
|
return null;
|
|
14681
14997
|
try {
|
|
@@ -14701,12 +15017,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14701
15017
|
throw new Error("Nexus daemon not running. Use action 'connect' first.");
|
|
14702
15018
|
}
|
|
14703
15019
|
const cmdId = randomBytes7(8).toString("hex");
|
|
14704
|
-
const cmdFile =
|
|
14705
|
-
const respFile =
|
|
15020
|
+
const cmdFile = join32(this.nexusDir, "cmd.json");
|
|
15021
|
+
const respFile = join32(this.nexusDir, "resp.json");
|
|
14706
15022
|
if (existsSync23(respFile))
|
|
14707
15023
|
await unlink(respFile).catch(() => {
|
|
14708
15024
|
});
|
|
14709
|
-
await
|
|
15025
|
+
await writeFile13(cmdFile, JSON.stringify({ id: cmdId, action, args }, null, 2));
|
|
14710
15026
|
const pollMs = 50;
|
|
14711
15027
|
const polls = Math.ceil(timeoutMs / pollMs);
|
|
14712
15028
|
let resolved = false;
|
|
@@ -14738,7 +15054,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14738
15054
|
if (!existsSync23(respFile))
|
|
14739
15055
|
continue;
|
|
14740
15056
|
try {
|
|
14741
|
-
const resp = JSON.parse(await
|
|
15057
|
+
const resp = JSON.parse(await readFile14(respFile, "utf8"));
|
|
14742
15058
|
if (resp.id === cmdId) {
|
|
14743
15059
|
resolved = true;
|
|
14744
15060
|
return resp.output || (resp.ok ? "OK" : "Failed");
|
|
@@ -14761,7 +15077,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14761
15077
|
}
|
|
14762
15078
|
if (existsSync23(respFile)) {
|
|
14763
15079
|
try {
|
|
14764
|
-
const resp = JSON.parse(await
|
|
15080
|
+
const resp = JSON.parse(await readFile14(respFile, "utf8"));
|
|
14765
15081
|
if (resp.id === cmdId) {
|
|
14766
15082
|
return resp.output || (resp.ok ? "OK" : "Failed");
|
|
14767
15083
|
}
|
|
@@ -14786,7 +15102,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14786
15102
|
const currentScriptHash = createHash("sha256").update(DAEMON_SCRIPT).digest("hex").slice(0, 16);
|
|
14787
15103
|
const existingPid = this.getDaemonPid();
|
|
14788
15104
|
if (existingPid) {
|
|
14789
|
-
const daemonPath2 =
|
|
15105
|
+
const daemonPath2 = join32(this.nexusDir, "nexus-daemon.mjs");
|
|
14790
15106
|
let needsRestart = true;
|
|
14791
15107
|
if (existsSync23(daemonPath2)) {
|
|
14792
15108
|
try {
|
|
@@ -14810,16 +15126,16 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14810
15126
|
} catch {
|
|
14811
15127
|
}
|
|
14812
15128
|
for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
|
|
14813
|
-
const p =
|
|
15129
|
+
const p = join32(this.nexusDir, f);
|
|
14814
15130
|
if (existsSync23(p))
|
|
14815
15131
|
await unlink(p).catch(() => {
|
|
14816
15132
|
});
|
|
14817
15133
|
}
|
|
14818
15134
|
} else {
|
|
14819
|
-
const statusFile2 =
|
|
15135
|
+
const statusFile2 = join32(this.nexusDir, "status.json");
|
|
14820
15136
|
if (existsSync23(statusFile2)) {
|
|
14821
15137
|
try {
|
|
14822
|
-
const status = JSON.parse(await
|
|
15138
|
+
const status = JSON.parse(await readFile14(statusFile2, "utf8"));
|
|
14823
15139
|
if (status.connected && status.peerId) {
|
|
14824
15140
|
await this.ensureWallet();
|
|
14825
15141
|
return `Already connected (pid: ${existingPid}, peerId: ${status.peerId})`;
|
|
@@ -14835,7 +15151,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14835
15151
|
}
|
|
14836
15152
|
}
|
|
14837
15153
|
for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
|
|
14838
|
-
const p =
|
|
15154
|
+
const p = join32(this.nexusDir, f);
|
|
14839
15155
|
if (existsSync23(p))
|
|
14840
15156
|
await unlink(p).catch(() => {
|
|
14841
15157
|
});
|
|
@@ -14853,7 +15169,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14853
15169
|
});
|
|
14854
15170
|
});
|
|
14855
15171
|
try {
|
|
14856
|
-
const nexusPkg =
|
|
15172
|
+
const nexusPkg = join32(nodeModulesDir, "open-agents-nexus", "package.json");
|
|
14857
15173
|
if (existsSync23(nexusPkg)) {
|
|
14858
15174
|
nexusResolved = true;
|
|
14859
15175
|
try {
|
|
@@ -14864,7 +15180,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14864
15180
|
} else {
|
|
14865
15181
|
try {
|
|
14866
15182
|
const globalDir = await execAsync2("npm root -g", { timeout: 5e3 });
|
|
14867
|
-
const globalPkg =
|
|
15183
|
+
const globalPkg = join32(globalDir, "open-agents-nexus", "package.json");
|
|
14868
15184
|
if (existsSync23(globalPkg)) {
|
|
14869
15185
|
nexusResolved = true;
|
|
14870
15186
|
try {
|
|
@@ -14909,8 +15225,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14909
15225
|
}
|
|
14910
15226
|
}
|
|
14911
15227
|
await this.ensureWallet();
|
|
14912
|
-
const daemonPath =
|
|
14913
|
-
await
|
|
15228
|
+
const daemonPath = join32(this.nexusDir, "nexus-daemon.mjs");
|
|
15229
|
+
await writeFile13(daemonPath, DAEMON_SCRIPT);
|
|
14914
15230
|
const agentName = args.agent_name || "open-agents-node";
|
|
14915
15231
|
const agentType = args.agent_type || "general";
|
|
14916
15232
|
const nodePaths = [nodeModulesDir];
|
|
@@ -14920,8 +15236,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14920
15236
|
} catch {
|
|
14921
15237
|
}
|
|
14922
15238
|
const { openSync: openSync2, closeSync: closeSync2 } = await import("node:fs");
|
|
14923
|
-
const daemonLogPath =
|
|
14924
|
-
const daemonErrPath =
|
|
15239
|
+
const daemonLogPath = join32(this.nexusDir, "daemon.log");
|
|
15240
|
+
const daemonErrPath = join32(this.nexusDir, "daemon.err");
|
|
14925
15241
|
const outFd = openSync2(daemonLogPath, "w");
|
|
14926
15242
|
const errFd = openSync2(daemonErrPath, "w");
|
|
14927
15243
|
const child = spawn12("node", [daemonPath, this.nexusDir, agentName, agentType], {
|
|
@@ -14939,16 +15255,16 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14939
15255
|
closeSync2(errFd);
|
|
14940
15256
|
} catch {
|
|
14941
15257
|
}
|
|
14942
|
-
const statusFile =
|
|
15258
|
+
const statusFile = join32(this.nexusDir, "status.json");
|
|
14943
15259
|
for (let i = 0; i < 40; i++) {
|
|
14944
15260
|
await new Promise((r) => setTimeout(r, 500));
|
|
14945
15261
|
if (existsSync23(statusFile)) {
|
|
14946
15262
|
try {
|
|
14947
|
-
const status = JSON.parse(await
|
|
15263
|
+
const status = JSON.parse(await readFile14(statusFile, "utf8"));
|
|
14948
15264
|
if (status.error) {
|
|
14949
15265
|
let errTail = "";
|
|
14950
15266
|
try {
|
|
14951
|
-
errTail = (await
|
|
15267
|
+
errTail = (await readFile14(daemonErrPath, "utf8")).slice(-300);
|
|
14952
15268
|
} catch {
|
|
14953
15269
|
}
|
|
14954
15270
|
return `Nexus daemon failed to connect: ${status.error}${errTail ? "\n" + errTail : ""}`;
|
|
@@ -14970,12 +15286,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14970
15286
|
const pid = this.getDaemonPid();
|
|
14971
15287
|
let earlyError = "";
|
|
14972
15288
|
try {
|
|
14973
|
-
earlyError = (await
|
|
15289
|
+
earlyError = (await readFile14(daemonErrPath, "utf8")).slice(-500);
|
|
14974
15290
|
} catch {
|
|
14975
15291
|
}
|
|
14976
15292
|
let earlyOutput = "";
|
|
14977
15293
|
try {
|
|
14978
|
-
earlyOutput = (await
|
|
15294
|
+
earlyOutput = (await readFile14(daemonLogPath, "utf8")).slice(-500);
|
|
14979
15295
|
} catch {
|
|
14980
15296
|
}
|
|
14981
15297
|
if (pid) {
|
|
@@ -14998,7 +15314,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
14998
15314
|
} catch {
|
|
14999
15315
|
}
|
|
15000
15316
|
for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
|
|
15001
|
-
const p =
|
|
15317
|
+
const p = join32(this.nexusDir, f);
|
|
15002
15318
|
if (existsSync23(p))
|
|
15003
15319
|
await unlink(p).catch(() => {
|
|
15004
15320
|
});
|
|
@@ -15009,11 +15325,11 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15009
15325
|
const pid = this.getDaemonPid();
|
|
15010
15326
|
if (!pid)
|
|
15011
15327
|
return "Nexus daemon not running. Use action 'connect' to start.";
|
|
15012
|
-
const statusFile =
|
|
15328
|
+
const statusFile = join32(this.nexusDir, "status.json");
|
|
15013
15329
|
if (!existsSync23(statusFile))
|
|
15014
15330
|
return `Daemon running (pid: ${pid}) but no status yet.`;
|
|
15015
15331
|
try {
|
|
15016
|
-
const status = JSON.parse(await
|
|
15332
|
+
const status = JSON.parse(await readFile14(statusFile, "utf8"));
|
|
15017
15333
|
const lines = [
|
|
15018
15334
|
`Nexus Status (v1.5.0)`,
|
|
15019
15335
|
` Connected: ${status.connected}`,
|
|
@@ -15024,10 +15340,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15024
15340
|
` Capabilities: ${(status.capabilities || []).length ? (status.capabilities || []).join(", ") : "none"}`,
|
|
15025
15341
|
` Blocked peers: ${(status.blockedPeers || []).length || 0}`
|
|
15026
15342
|
];
|
|
15027
|
-
const walletPath =
|
|
15343
|
+
const walletPath = join32(this.nexusDir, "wallet.enc");
|
|
15028
15344
|
if (existsSync23(walletPath)) {
|
|
15029
15345
|
try {
|
|
15030
|
-
const w = JSON.parse(await
|
|
15346
|
+
const w = JSON.parse(await readFile14(walletPath, "utf8"));
|
|
15031
15347
|
lines.push(` Wallet: ${w.address}`);
|
|
15032
15348
|
} catch {
|
|
15033
15349
|
lines.push(` Wallet: corrupt`);
|
|
@@ -15035,14 +15351,14 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15035
15351
|
} else {
|
|
15036
15352
|
lines.push(` Wallet: not configured`);
|
|
15037
15353
|
}
|
|
15038
|
-
const inboxDir =
|
|
15354
|
+
const inboxDir = join32(this.nexusDir, "inbox");
|
|
15039
15355
|
if (existsSync23(inboxDir)) {
|
|
15040
15356
|
try {
|
|
15041
15357
|
const roomDirs = await readdir3(inboxDir);
|
|
15042
15358
|
let totalMsgs = 0;
|
|
15043
15359
|
for (const rd of roomDirs) {
|
|
15044
15360
|
try {
|
|
15045
|
-
totalMsgs += (await readdir3(
|
|
15361
|
+
totalMsgs += (await readdir3(join32(inboxDir, rd))).length;
|
|
15046
15362
|
} catch {
|
|
15047
15363
|
}
|
|
15048
15364
|
}
|
|
@@ -15089,9 +15405,9 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15089
15405
|
}
|
|
15090
15406
|
async doReadMessages(args) {
|
|
15091
15407
|
const roomId = args.room_id;
|
|
15092
|
-
const inboxDir =
|
|
15408
|
+
const inboxDir = join32(this.nexusDir, "inbox");
|
|
15093
15409
|
if (roomId) {
|
|
15094
|
-
const roomInbox =
|
|
15410
|
+
const roomInbox = join32(inboxDir, roomId);
|
|
15095
15411
|
if (!existsSync23(roomInbox))
|
|
15096
15412
|
return `No messages in room: ${roomId}`;
|
|
15097
15413
|
const files = (await readdir3(roomInbox)).sort().slice(-20);
|
|
@@ -15100,7 +15416,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15100
15416
|
const messages = [`Messages in ${roomId} (last ${files.length}):`];
|
|
15101
15417
|
for (const f of files) {
|
|
15102
15418
|
try {
|
|
15103
|
-
const msg = JSON.parse(await
|
|
15419
|
+
const msg = JSON.parse(await readFile14(join32(roomInbox, f), "utf8"));
|
|
15104
15420
|
const sender = (msg.sender || "unknown").slice(0, 12);
|
|
15105
15421
|
messages.push(` [${new Date(msg.timestamp).toLocaleTimeString()}] ${sender}...: ${msg.content}`);
|
|
15106
15422
|
} catch {
|
|
@@ -15116,7 +15432,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15116
15432
|
const lines = ["Inbox:"];
|
|
15117
15433
|
for (const rd of roomDirs) {
|
|
15118
15434
|
try {
|
|
15119
|
-
const count = (await readdir3(
|
|
15435
|
+
const count = (await readdir3(join32(inboxDir, rd))).length;
|
|
15120
15436
|
lines.push(` ${rd}: ${count} message(s)`);
|
|
15121
15437
|
} catch {
|
|
15122
15438
|
}
|
|
@@ -15128,12 +15444,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15128
15444
|
// ---------------------------------------------------------------------------
|
|
15129
15445
|
async doWalletStatus() {
|
|
15130
15446
|
await this.ensureDir();
|
|
15131
|
-
const walletPath =
|
|
15447
|
+
const walletPath = join32(this.nexusDir, "wallet.enc");
|
|
15132
15448
|
if (!existsSync23(walletPath)) {
|
|
15133
15449
|
return "No wallet configured. Use wallet_create to set one up.";
|
|
15134
15450
|
}
|
|
15135
15451
|
try {
|
|
15136
|
-
const w = JSON.parse(await
|
|
15452
|
+
const w = JSON.parse(await readFile14(walletPath, "utf8"));
|
|
15137
15453
|
const lines = [
|
|
15138
15454
|
`Wallet Status:`,
|
|
15139
15455
|
` Address: ${w.address}`,
|
|
@@ -15167,7 +15483,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15167
15483
|
}
|
|
15168
15484
|
async doWalletCreate(args) {
|
|
15169
15485
|
await this.ensureDir();
|
|
15170
|
-
const walletPath =
|
|
15486
|
+
const walletPath = join32(this.nexusDir, "wallet.enc");
|
|
15171
15487
|
if (existsSync23(walletPath))
|
|
15172
15488
|
return "Wallet already exists. Delete wallet.enc to create a new one.";
|
|
15173
15489
|
const userAddress = args.wallet_address;
|
|
@@ -15213,7 +15529,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15213
15529
|
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
15214
15530
|
let enc = cipher.update(privKeyHex, "utf8", "hex");
|
|
15215
15531
|
enc += cipher.final("hex");
|
|
15216
|
-
const x402KeyPath =
|
|
15532
|
+
const x402KeyPath = join32(this.nexusDir, "x402-wallet.key");
|
|
15217
15533
|
const x402Fh = await fsOpen(x402KeyPath, "w", 384);
|
|
15218
15534
|
await x402Fh.writeFile("0x" + privKeyHex);
|
|
15219
15535
|
await x402Fh.close();
|
|
@@ -15251,7 +15567,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15251
15567
|
* Silent — no user output, just ensures the files exist.
|
|
15252
15568
|
*/
|
|
15253
15569
|
async ensureWallet() {
|
|
15254
|
-
const walletPath =
|
|
15570
|
+
const walletPath = join32(this.nexusDir, "wallet.enc");
|
|
15255
15571
|
if (existsSync23(walletPath))
|
|
15256
15572
|
return;
|
|
15257
15573
|
let address;
|
|
@@ -15275,7 +15591,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15275
15591
|
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
15276
15592
|
let enc = cipher.update(privKeyHex, "utf8", "hex");
|
|
15277
15593
|
enc += cipher.final("hex");
|
|
15278
|
-
const x402KeyPath =
|
|
15594
|
+
const x402KeyPath = join32(this.nexusDir, "x402-wallet.key");
|
|
15279
15595
|
const x402Fh = await fsOpen(x402KeyPath, "w", 384);
|
|
15280
15596
|
await x402Fh.writeFile("0x" + privKeyHex);
|
|
15281
15597
|
await x402Fh.close();
|
|
@@ -15335,12 +15651,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15335
15651
|
// ---------------------------------------------------------------------------
|
|
15336
15652
|
async doLedgerStatus() {
|
|
15337
15653
|
await this.ensureDir();
|
|
15338
|
-
const ledgerPath =
|
|
15654
|
+
const ledgerPath = join32(this.nexusDir, "ledger.jsonl");
|
|
15339
15655
|
if (!existsSync23(ledgerPath)) {
|
|
15340
15656
|
return "No ledger entries. Earnings and spending will be tracked here after x402 transactions.";
|
|
15341
15657
|
}
|
|
15342
15658
|
try {
|
|
15343
|
-
const raw = await
|
|
15659
|
+
const raw = await readFile14(ledgerPath, "utf8");
|
|
15344
15660
|
const entries = raw.trim().split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
|
|
15345
15661
|
if (entries.length === 0) {
|
|
15346
15662
|
return "Ledger is empty. No transactions recorded.";
|
|
@@ -15377,11 +15693,11 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15377
15693
|
}
|
|
15378
15694
|
}
|
|
15379
15695
|
async getLedgerSummary() {
|
|
15380
|
-
const ledgerPath =
|
|
15696
|
+
const ledgerPath = join32(this.nexusDir, "ledger.jsonl");
|
|
15381
15697
|
if (!existsSync23(ledgerPath))
|
|
15382
15698
|
return null;
|
|
15383
15699
|
try {
|
|
15384
|
-
const raw = await
|
|
15700
|
+
const raw = await readFile14(ledgerPath, "utf8");
|
|
15385
15701
|
const entries = raw.trim().split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
|
|
15386
15702
|
let totalEarned = 0n, totalSpent = 0n;
|
|
15387
15703
|
for (const e of entries) {
|
|
@@ -15402,25 +15718,25 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15402
15718
|
}
|
|
15403
15719
|
async appendLedger(entry) {
|
|
15404
15720
|
await this.ensureDir();
|
|
15405
|
-
const ledgerPath =
|
|
15721
|
+
const ledgerPath = join32(this.nexusDir, "ledger.jsonl");
|
|
15406
15722
|
const line = JSON.stringify(entry) + "\n";
|
|
15407
|
-
await
|
|
15723
|
+
await writeFile13(ledgerPath, existsSync23(ledgerPath) ? await readFile14(ledgerPath, "utf8") + line : line);
|
|
15408
15724
|
}
|
|
15409
15725
|
// ---------------------------------------------------------------------------
|
|
15410
15726
|
// Step 4: Budget Policy — Spending limits and auto-approve thresholds
|
|
15411
15727
|
// ---------------------------------------------------------------------------
|
|
15412
15728
|
async loadBudget() {
|
|
15413
|
-
const budgetPath =
|
|
15729
|
+
const budgetPath = join32(this.nexusDir, "budget.json");
|
|
15414
15730
|
if (!existsSync23(budgetPath))
|
|
15415
15731
|
return null;
|
|
15416
15732
|
try {
|
|
15417
|
-
return JSON.parse(await
|
|
15733
|
+
return JSON.parse(await readFile14(budgetPath, "utf8"));
|
|
15418
15734
|
} catch {
|
|
15419
15735
|
return null;
|
|
15420
15736
|
}
|
|
15421
15737
|
}
|
|
15422
15738
|
async ensureDefaultBudget() {
|
|
15423
|
-
const budgetPath =
|
|
15739
|
+
const budgetPath = join32(this.nexusDir, "budget.json");
|
|
15424
15740
|
if (existsSync23(budgetPath))
|
|
15425
15741
|
return;
|
|
15426
15742
|
const defaultBudget = {
|
|
@@ -15441,7 +15757,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15441
15757
|
deniedPeers: []
|
|
15442
15758
|
};
|
|
15443
15759
|
await this.ensureDir();
|
|
15444
|
-
await
|
|
15760
|
+
await writeFile13(budgetPath, JSON.stringify(defaultBudget, null, 2));
|
|
15445
15761
|
}
|
|
15446
15762
|
async doBudgetStatus() {
|
|
15447
15763
|
await this.ensureDir();
|
|
@@ -15490,17 +15806,17 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15490
15806
|
if (changes.length === 0) {
|
|
15491
15807
|
return "No budget parameters provided. Use daily_limit, per_invoke_max, or auto_approve_below.";
|
|
15492
15808
|
}
|
|
15493
|
-
const budgetPath =
|
|
15494
|
-
await
|
|
15809
|
+
const budgetPath = join32(this.nexusDir, "budget.json");
|
|
15810
|
+
await writeFile13(budgetPath, JSON.stringify(budget, null, 2));
|
|
15495
15811
|
return `Budget updated: ${changes.join(", ")}`;
|
|
15496
15812
|
}
|
|
15497
15813
|
async getTodaySpending() {
|
|
15498
|
-
const ledgerPath =
|
|
15814
|
+
const ledgerPath = join32(this.nexusDir, "ledger.jsonl");
|
|
15499
15815
|
if (!existsSync23(ledgerPath))
|
|
15500
15816
|
return 0;
|
|
15501
15817
|
try {
|
|
15502
15818
|
const todayPrefix = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
15503
|
-
const raw = await
|
|
15819
|
+
const raw = await readFile14(ledgerPath, "utf8");
|
|
15504
15820
|
let total = 0;
|
|
15505
15821
|
for (const line of raw.trim().split("\n")) {
|
|
15506
15822
|
if (!line.trim())
|
|
@@ -15539,10 +15855,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15539
15855
|
if (todaySpent + amountUsdc > budget.dailyLimitUsdc) {
|
|
15540
15856
|
return { allowed: false, reason: `Would exceed daily limit ($${((todaySpent + amountUsdc) / 1e6).toFixed(6)} > $${(budget.dailyLimitUsdc / 1e6).toFixed(6)})` };
|
|
15541
15857
|
}
|
|
15542
|
-
const walletPath =
|
|
15858
|
+
const walletPath = join32(this.nexusDir, "wallet.enc");
|
|
15543
15859
|
if (existsSync23(walletPath)) {
|
|
15544
15860
|
try {
|
|
15545
|
-
const w = JSON.parse(await
|
|
15861
|
+
const w = JSON.parse(await readFile14(walletPath, "utf8"));
|
|
15546
15862
|
if (w.version === 2 && w.address) {
|
|
15547
15863
|
const balance = await this.queryUsdcBalance(w.address, w.chainId || 8453);
|
|
15548
15864
|
if (balance !== null && Number(balance) < budget.circuitBreakerUsdc) {
|
|
@@ -15570,10 +15886,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15570
15886
|
const budgetResult = await this.checkBudget(amountSmallest, "transfer:direct", targetAddress);
|
|
15571
15887
|
if (!budgetResult.allowed)
|
|
15572
15888
|
return `BLOCKED by budget policy: ${budgetResult.reason}`;
|
|
15573
|
-
const walletPath =
|
|
15889
|
+
const walletPath = join32(this.nexusDir, "wallet.enc");
|
|
15574
15890
|
if (!existsSync23(walletPath))
|
|
15575
15891
|
throw new Error("No wallet. Use wallet_create first.");
|
|
15576
|
-
const w = JSON.parse(await
|
|
15892
|
+
const w = JSON.parse(await readFile14(walletPath, "utf8"));
|
|
15577
15893
|
if (!w.encryptedKey)
|
|
15578
15894
|
throw new Error("User-managed wallet cannot spend (no private key)");
|
|
15579
15895
|
const salt = Buffer.from(w.salt, "hex");
|
|
@@ -15631,7 +15947,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15631
15947
|
capability: "transfer:direct",
|
|
15632
15948
|
note: "signed, awaiting submission"
|
|
15633
15949
|
});
|
|
15634
|
-
const proofFile =
|
|
15950
|
+
const proofFile = join32(this.nexusDir, "pending-transfer.json");
|
|
15635
15951
|
const proof = {
|
|
15636
15952
|
from: account.address,
|
|
15637
15953
|
to: targetAddress,
|
|
@@ -15644,7 +15960,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15644
15960
|
usdcContract: USDC_ADDRESS,
|
|
15645
15961
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
15646
15962
|
};
|
|
15647
|
-
await
|
|
15963
|
+
await writeFile13(proofFile, JSON.stringify(proof, null, 2));
|
|
15648
15964
|
return [
|
|
15649
15965
|
`Transfer signed (EIP-3009 TransferWithAuthorization):`,
|
|
15650
15966
|
` From: ${account.address}`,
|
|
@@ -15673,10 +15989,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15673
15989
|
throw new Error("prompt is required");
|
|
15674
15990
|
const estimatedTokens = Math.ceil(prompt.length / 4) + 1e3;
|
|
15675
15991
|
let estimatedCostSmallest = 0;
|
|
15676
|
-
const pricingPath =
|
|
15992
|
+
const pricingPath = join32(this.nexusDir, "pricing.json");
|
|
15677
15993
|
if (existsSync23(pricingPath)) {
|
|
15678
15994
|
try {
|
|
15679
|
-
const pricing = JSON.parse(await
|
|
15995
|
+
const pricing = JSON.parse(await readFile14(pricingPath, "utf8"));
|
|
15680
15996
|
const modelPricing = (pricing.models || []).find((m) => m.model === model || m.model.startsWith(model.split(":")[0]));
|
|
15681
15997
|
if (modelPricing?.pricing?.input_per_1m_tokens > 0) {
|
|
15682
15998
|
estimatedCostSmallest = Math.ceil(estimatedTokens / 1e6 * modelPricing.pricing.input_per_1m_tokens * 1e6);
|
|
@@ -15793,7 +16109,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
|
|
|
15793
16109
|
const bar = (s) => "\u2588".repeat(Math.round(s / 5)) + "\u2591".repeat(20 - Math.round(s / 5));
|
|
15794
16110
|
const mem = vramMb > 24e3 ? 95 : vramMb > 16e3 ? 80 : vramMb > 8e3 ? 60 : vramMb > 0 ? 40 : 20;
|
|
15795
16111
|
await this.ensureDir();
|
|
15796
|
-
await
|
|
16112
|
+
await writeFile13(join32(this.nexusDir, "inference-proof.json"), JSON.stringify({
|
|
15797
16113
|
modelName,
|
|
15798
16114
|
gpuName,
|
|
15799
16115
|
vramMb,
|
|
@@ -16446,6 +16762,7 @@ __export(dist_exports, {
|
|
|
16446
16762
|
ImageReadTool: () => ImageReadTool,
|
|
16447
16763
|
ListDirectoryTool: () => ListDirectoryTool,
|
|
16448
16764
|
ManageToolsTool: () => ManageToolsTool,
|
|
16765
|
+
MemoryMetabolismTool: () => MemoryMetabolismTool,
|
|
16449
16766
|
MemoryReadTool: () => MemoryReadTool,
|
|
16450
16767
|
MemorySearchTool: () => MemorySearchTool,
|
|
16451
16768
|
MemoryWriteTool: () => MemoryWriteTool,
|
|
@@ -16542,6 +16859,7 @@ var init_dist2 = __esm({
|
|
|
16542
16859
|
init_structured_file();
|
|
16543
16860
|
init_code_sandbox();
|
|
16544
16861
|
init_repl();
|
|
16862
|
+
init_memory_metabolism();
|
|
16545
16863
|
init_structured_read();
|
|
16546
16864
|
init_vision();
|
|
16547
16865
|
init_desktop_click();
|
|
@@ -17242,12 +17560,12 @@ var init_dist3 = __esm({
|
|
|
17242
17560
|
|
|
17243
17561
|
// packages/orchestrator/dist/promptLoader.js
|
|
17244
17562
|
import { readFileSync as readFileSync18, existsSync as existsSync25 } from "node:fs";
|
|
17245
|
-
import { join as
|
|
17563
|
+
import { join as join33, dirname as dirname12 } from "node:path";
|
|
17246
17564
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
17247
17565
|
function loadPrompt(promptPath, vars) {
|
|
17248
17566
|
let content = cache.get(promptPath);
|
|
17249
17567
|
if (content === void 0) {
|
|
17250
|
-
const fullPath =
|
|
17568
|
+
const fullPath = join33(PROMPTS_DIR, promptPath);
|
|
17251
17569
|
if (!existsSync25(fullPath)) {
|
|
17252
17570
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
17253
17571
|
}
|
|
@@ -17264,7 +17582,7 @@ var init_promptLoader = __esm({
|
|
|
17264
17582
|
"use strict";
|
|
17265
17583
|
__filename = fileURLToPath7(import.meta.url);
|
|
17266
17584
|
__dirname4 = dirname12(__filename);
|
|
17267
|
-
PROMPTS_DIR =
|
|
17585
|
+
PROMPTS_DIR = join33(__dirname4, "..", "prompts");
|
|
17268
17586
|
cache = /* @__PURE__ */ new Map();
|
|
17269
17587
|
}
|
|
17270
17588
|
});
|
|
@@ -17627,8 +17945,8 @@ var init_code_retriever = __esm({
|
|
|
17627
17945
|
});
|
|
17628
17946
|
}
|
|
17629
17947
|
async getFileContent(filePath, startLine, endLine) {
|
|
17630
|
-
const { readFile:
|
|
17631
|
-
const content = await
|
|
17948
|
+
const { readFile: readFile19 } = await import("node:fs/promises");
|
|
17949
|
+
const content = await readFile19(filePath, "utf-8");
|
|
17632
17950
|
if (startLine === void 0)
|
|
17633
17951
|
return content;
|
|
17634
17952
|
const lines = content.split("\n");
|
|
@@ -17643,8 +17961,8 @@ var init_code_retriever = __esm({
|
|
|
17643
17961
|
// packages/retrieval/dist/lexicalSearch.js
|
|
17644
17962
|
import { execFile as execFile5 } from "node:child_process";
|
|
17645
17963
|
import { promisify as promisify4 } from "node:util";
|
|
17646
|
-
import { readFile as
|
|
17647
|
-
import { join as
|
|
17964
|
+
import { readFile as readFile15, readdir as readdir4, stat as stat3 } from "node:fs/promises";
|
|
17965
|
+
import { join as join34, extname as extname7 } from "node:path";
|
|
17648
17966
|
async function searchByPath(pathPattern, options) {
|
|
17649
17967
|
const allFiles = await collectFiles(options.rootDir, options.includeGlobs ?? DEFAULT_INCLUDE_GLOBS, options.excludeGlobs ?? DEFAULT_EXCLUDE_GLOBS);
|
|
17650
17968
|
const pattern = options.caseInsensitive ? pathPattern.toLowerCase() : pathPattern;
|
|
@@ -17749,7 +18067,7 @@ async function searchWithNodeFallback(pattern, kind, options) {
|
|
|
17749
18067
|
if (results.length >= maxMatches)
|
|
17750
18068
|
break;
|
|
17751
18069
|
try {
|
|
17752
|
-
const content = await
|
|
18070
|
+
const content = await readFile15(filePath, "utf-8");
|
|
17753
18071
|
const contentLines = content.split("\n");
|
|
17754
18072
|
for (let i = 0; i < contentLines.length; i++) {
|
|
17755
18073
|
if (results.length >= maxMatches)
|
|
@@ -17786,7 +18104,7 @@ async function walkForFiles(rootDir, dir, excludeGlobs, results) {
|
|
|
17786
18104
|
continue;
|
|
17787
18105
|
if (excludeGlobs.some((g) => entry.name === g || matchesGlob(entry.name, g)))
|
|
17788
18106
|
continue;
|
|
17789
|
-
const absPath =
|
|
18107
|
+
const absPath = join34(dir, entry.name);
|
|
17790
18108
|
if (entry.isDirectory()) {
|
|
17791
18109
|
await walkForFiles(rootDir, absPath, excludeGlobs, results);
|
|
17792
18110
|
} else if (entry.isFile()) {
|
|
@@ -18092,8 +18410,8 @@ var init_graphExpand = __esm({
|
|
|
18092
18410
|
});
|
|
18093
18411
|
|
|
18094
18412
|
// packages/retrieval/dist/snippetPacker.js
|
|
18095
|
-
import { readFile as
|
|
18096
|
-
import { join as
|
|
18413
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
18414
|
+
import { join as join35 } from "node:path";
|
|
18097
18415
|
async function packSnippets(requests, opts = {}) {
|
|
18098
18416
|
const maxTokens = opts.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
18099
18417
|
const contextLines = opts.contextLines ?? DEFAULT_CONTEXT_LINES;
|
|
@@ -18119,10 +18437,10 @@ async function packSnippets(requests, opts = {}) {
|
|
|
18119
18437
|
return { packed, dropped, totalTokens };
|
|
18120
18438
|
}
|
|
18121
18439
|
async function extractSnippet(req, repoRoot, contextLines = DEFAULT_CONTEXT_LINES) {
|
|
18122
|
-
const absPath = req.filePath.startsWith("/") ? req.filePath :
|
|
18440
|
+
const absPath = req.filePath.startsWith("/") ? req.filePath : join35(repoRoot, req.filePath);
|
|
18123
18441
|
let content;
|
|
18124
18442
|
try {
|
|
18125
|
-
content = await
|
|
18443
|
+
content = await readFile16(absPath, "utf-8");
|
|
18126
18444
|
} catch {
|
|
18127
18445
|
return null;
|
|
18128
18446
|
}
|
|
@@ -20713,8 +21031,8 @@ ${marker}` : marker);
|
|
|
20713
21031
|
return;
|
|
20714
21032
|
try {
|
|
20715
21033
|
const { mkdirSync: mkdirSync21, writeFileSync: writeFileSync20 } = __require("node:fs");
|
|
20716
|
-
const { join:
|
|
20717
|
-
const sessionDir =
|
|
21034
|
+
const { join: join59 } = __require("node:path");
|
|
21035
|
+
const sessionDir = join59(this._workingDirectory, ".oa", "session", this._sessionId);
|
|
20718
21036
|
mkdirSync21(sessionDir, { recursive: true });
|
|
20719
21037
|
const checkpoint = {
|
|
20720
21038
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -20727,7 +21045,7 @@ ${marker}` : marker);
|
|
|
20727
21045
|
memexEntryCount: this._memexArchive.size,
|
|
20728
21046
|
fileRegistrySize: this._fileRegistry.size
|
|
20729
21047
|
};
|
|
20730
|
-
writeFileSync20(
|
|
21048
|
+
writeFileSync20(join59(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
20731
21049
|
} catch {
|
|
20732
21050
|
}
|
|
20733
21051
|
}
|
|
@@ -21995,7 +22313,7 @@ ${transcript}`
|
|
|
21995
22313
|
// packages/orchestrator/dist/nexusBackend.js
|
|
21996
22314
|
import { existsSync as existsSync26, statSync as statSync9, openSync, readSync, closeSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "node:fs";
|
|
21997
22315
|
import { watch as fsWatch } from "node:fs";
|
|
21998
|
-
import { join as
|
|
22316
|
+
import { join as join36 } from "node:path";
|
|
21999
22317
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
22000
22318
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
22001
22319
|
var NexusAgenticBackend;
|
|
@@ -22145,7 +22463,7 @@ var init_nexusBackend = __esm({
|
|
|
22145
22463
|
* Falls back to unary + word-split if streaming setup fails.
|
|
22146
22464
|
*/
|
|
22147
22465
|
async *chatCompletionStream(request) {
|
|
22148
|
-
const streamFile =
|
|
22466
|
+
const streamFile = join36(tmpdir7(), `nexus-stream-${randomBytes8(6).toString("hex")}.jsonl`);
|
|
22149
22467
|
writeFileSync8(streamFile, "", "utf8");
|
|
22150
22468
|
const daemonArgs = {
|
|
22151
22469
|
model: this.model,
|
|
@@ -23182,7 +23500,7 @@ __export(listen_exports, {
|
|
|
23182
23500
|
});
|
|
23183
23501
|
import { spawn as spawn15, execSync as execSync23 } from "node:child_process";
|
|
23184
23502
|
import { existsSync as existsSync27, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readdirSync as readdirSync6 } from "node:fs";
|
|
23185
|
-
import { join as
|
|
23503
|
+
import { join as join37, dirname as dirname13 } from "node:path";
|
|
23186
23504
|
import { homedir as homedir8 } from "node:os";
|
|
23187
23505
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
23188
23506
|
import { EventEmitter } from "node:events";
|
|
@@ -23268,12 +23586,12 @@ function findMicCaptureCommand() {
|
|
|
23268
23586
|
function findLiveWhisperScript() {
|
|
23269
23587
|
const thisDir = dirname13(fileURLToPath8(import.meta.url));
|
|
23270
23588
|
const candidates = [
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23589
|
+
join37(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
|
|
23590
|
+
join37(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
|
|
23591
|
+
join37(thisDir, "../../execution/scripts/live-whisper.py"),
|
|
23274
23592
|
// npm install layout — scripts bundled alongside dist
|
|
23275
|
-
|
|
23276
|
-
|
|
23593
|
+
join37(thisDir, "../scripts/live-whisper.py"),
|
|
23594
|
+
join37(thisDir, "../../scripts/live-whisper.py")
|
|
23277
23595
|
];
|
|
23278
23596
|
for (const p of candidates) {
|
|
23279
23597
|
if (existsSync27(p))
|
|
@@ -23286,8 +23604,8 @@ function findLiveWhisperScript() {
|
|
|
23286
23604
|
stdio: ["pipe", "pipe", "pipe"]
|
|
23287
23605
|
}).trim();
|
|
23288
23606
|
const candidates2 = [
|
|
23289
|
-
|
|
23290
|
-
|
|
23607
|
+
join37(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
|
|
23608
|
+
join37(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
|
|
23291
23609
|
];
|
|
23292
23610
|
for (const p of candidates2) {
|
|
23293
23611
|
if (existsSync27(p))
|
|
@@ -23295,11 +23613,11 @@ function findLiveWhisperScript() {
|
|
|
23295
23613
|
}
|
|
23296
23614
|
} catch {
|
|
23297
23615
|
}
|
|
23298
|
-
const nvmBase =
|
|
23616
|
+
const nvmBase = join37(homedir8(), ".nvm", "versions", "node");
|
|
23299
23617
|
if (existsSync27(nvmBase)) {
|
|
23300
23618
|
try {
|
|
23301
23619
|
for (const ver of readdirSync6(nvmBase)) {
|
|
23302
|
-
const p =
|
|
23620
|
+
const p = join37(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
|
|
23303
23621
|
if (existsSync27(p))
|
|
23304
23622
|
return p;
|
|
23305
23623
|
}
|
|
@@ -23318,7 +23636,7 @@ function ensureTranscribeCliBackground() {
|
|
|
23318
23636
|
timeout: 5e3,
|
|
23319
23637
|
stdio: ["pipe", "pipe", "pipe"]
|
|
23320
23638
|
}).trim();
|
|
23321
|
-
if (existsSync27(
|
|
23639
|
+
if (existsSync27(join37(globalRoot, "transcribe-cli", "dist", "index.js"))) {
|
|
23322
23640
|
return true;
|
|
23323
23641
|
}
|
|
23324
23642
|
} catch {
|
|
@@ -23541,24 +23859,24 @@ var init_listen = __esm({
|
|
|
23541
23859
|
timeout: 5e3,
|
|
23542
23860
|
stdio: ["pipe", "pipe", "pipe"]
|
|
23543
23861
|
}).trim();
|
|
23544
|
-
const tcPath =
|
|
23545
|
-
if (existsSync27(
|
|
23862
|
+
const tcPath = join37(globalRoot, "transcribe-cli");
|
|
23863
|
+
if (existsSync27(join37(tcPath, "dist", "index.js"))) {
|
|
23546
23864
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
23547
23865
|
const req = createRequire4(import.meta.url);
|
|
23548
|
-
return req(
|
|
23866
|
+
return req(join37(tcPath, "dist", "index.js"));
|
|
23549
23867
|
}
|
|
23550
23868
|
} catch {
|
|
23551
23869
|
}
|
|
23552
|
-
const nvmBase =
|
|
23870
|
+
const nvmBase = join37(homedir8(), ".nvm", "versions", "node");
|
|
23553
23871
|
if (existsSync27(nvmBase)) {
|
|
23554
23872
|
try {
|
|
23555
23873
|
const { readdirSync: readdirSync17 } = await import("node:fs");
|
|
23556
23874
|
for (const ver of readdirSync17(nvmBase)) {
|
|
23557
|
-
const tcPath =
|
|
23558
|
-
if (existsSync27(
|
|
23875
|
+
const tcPath = join37(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
|
|
23876
|
+
if (existsSync27(join37(tcPath, "dist", "index.js"))) {
|
|
23559
23877
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
23560
23878
|
const req = createRequire4(import.meta.url);
|
|
23561
|
-
return req(
|
|
23879
|
+
return req(join37(tcPath, "dist", "index.js"));
|
|
23562
23880
|
}
|
|
23563
23881
|
}
|
|
23564
23882
|
} catch {
|
|
@@ -23840,9 +24158,9 @@ transcribe-cli error: ${transcribeCliError}` : "";
|
|
|
23840
24158
|
});
|
|
23841
24159
|
if (outputDir) {
|
|
23842
24160
|
const { basename: basename16 } = await import("node:path");
|
|
23843
|
-
const transcriptDir =
|
|
24161
|
+
const transcriptDir = join37(outputDir, ".oa", "transcripts");
|
|
23844
24162
|
mkdirSync8(transcriptDir, { recursive: true });
|
|
23845
|
-
const outFile =
|
|
24163
|
+
const outFile = join37(transcriptDir, `${basename16(filePath)}.txt`);
|
|
23846
24164
|
writeFileSync9(outFile, result.text, "utf-8");
|
|
23847
24165
|
}
|
|
23848
24166
|
return {
|
|
@@ -29200,7 +29518,7 @@ import { randomBytes as randomBytes9 } from "node:crypto";
|
|
|
29200
29518
|
import { URL as URL2 } from "node:url";
|
|
29201
29519
|
import { loadavg, cpus, totalmem, freemem } from "node:os";
|
|
29202
29520
|
import { existsSync as existsSync28, readFileSync as readFileSync19, writeFileSync as writeFileSync10, unlinkSync as unlinkSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync7, statSync as statSync10 } from "node:fs";
|
|
29203
|
-
import { join as
|
|
29521
|
+
import { join as join38 } from "node:path";
|
|
29204
29522
|
function cleanForwardHeaders(raw, targetHost) {
|
|
29205
29523
|
const out = {};
|
|
29206
29524
|
for (const [key, value] of Object.entries(raw)) {
|
|
@@ -29228,7 +29546,7 @@ function fmtTokens(n) {
|
|
|
29228
29546
|
}
|
|
29229
29547
|
function readExposeState(stateDir) {
|
|
29230
29548
|
try {
|
|
29231
|
-
const path =
|
|
29549
|
+
const path = join38(stateDir, STATE_FILE_NAME);
|
|
29232
29550
|
if (!existsSync28(path))
|
|
29233
29551
|
return null;
|
|
29234
29552
|
const raw = readFileSync19(path, "utf8");
|
|
@@ -29243,13 +29561,13 @@ function readExposeState(stateDir) {
|
|
|
29243
29561
|
function writeExposeState(stateDir, state) {
|
|
29244
29562
|
try {
|
|
29245
29563
|
mkdirSync9(stateDir, { recursive: true });
|
|
29246
|
-
writeFileSync10(
|
|
29564
|
+
writeFileSync10(join38(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
29247
29565
|
} catch {
|
|
29248
29566
|
}
|
|
29249
29567
|
}
|
|
29250
29568
|
function removeExposeState(stateDir) {
|
|
29251
29569
|
try {
|
|
29252
|
-
unlinkSync5(
|
|
29570
|
+
unlinkSync5(join38(stateDir, STATE_FILE_NAME));
|
|
29253
29571
|
} catch {
|
|
29254
29572
|
}
|
|
29255
29573
|
}
|
|
@@ -29338,7 +29656,7 @@ async function collectSystemMetricsAsync() {
|
|
|
29338
29656
|
}
|
|
29339
29657
|
function readP2PExposeState(stateDir) {
|
|
29340
29658
|
try {
|
|
29341
|
-
const path =
|
|
29659
|
+
const path = join38(stateDir, P2P_STATE_FILE_NAME);
|
|
29342
29660
|
if (!existsSync28(path))
|
|
29343
29661
|
return null;
|
|
29344
29662
|
const raw = readFileSync19(path, "utf8");
|
|
@@ -29353,13 +29671,13 @@ function readP2PExposeState(stateDir) {
|
|
|
29353
29671
|
function writeP2PExposeState(stateDir, state) {
|
|
29354
29672
|
try {
|
|
29355
29673
|
mkdirSync9(stateDir, { recursive: true });
|
|
29356
|
-
writeFileSync10(
|
|
29674
|
+
writeFileSync10(join38(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
|
|
29357
29675
|
} catch {
|
|
29358
29676
|
}
|
|
29359
29677
|
}
|
|
29360
29678
|
function removeP2PExposeState(stateDir) {
|
|
29361
29679
|
try {
|
|
29362
|
-
unlinkSync5(
|
|
29680
|
+
unlinkSync5(join38(stateDir, P2P_STATE_FILE_NAME));
|
|
29363
29681
|
} catch {
|
|
29364
29682
|
}
|
|
29365
29683
|
}
|
|
@@ -30189,7 +30507,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30189
30507
|
throw new Error(`Expose failed: ${exposeResult.error}`);
|
|
30190
30508
|
}
|
|
30191
30509
|
const nexusDir = this._nexusTool.getNexusDir();
|
|
30192
|
-
const statusPath =
|
|
30510
|
+
const statusPath = join38(nexusDir, "status.json");
|
|
30193
30511
|
for (let i = 0; i < 80; i++) {
|
|
30194
30512
|
try {
|
|
30195
30513
|
const raw = readFileSync19(statusPath, "utf8");
|
|
@@ -30223,7 +30541,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30223
30541
|
});
|
|
30224
30542
|
}
|
|
30225
30543
|
try {
|
|
30226
|
-
const invocDir =
|
|
30544
|
+
const invocDir = join38(nexusDir, "invocations");
|
|
30227
30545
|
if (existsSync28(invocDir)) {
|
|
30228
30546
|
this._prevInvocCount = readdirSync7(invocDir).filter((f) => f.endsWith(".json")).length;
|
|
30229
30547
|
this._stats.totalRequests = this._prevInvocCount;
|
|
@@ -30253,7 +30571,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30253
30571
|
if (!state)
|
|
30254
30572
|
return null;
|
|
30255
30573
|
const nexusDir = nexusTool.getNexusDir();
|
|
30256
|
-
const statusPath =
|
|
30574
|
+
const statusPath = join38(nexusDir, "status.json");
|
|
30257
30575
|
try {
|
|
30258
30576
|
if (!existsSync28(statusPath)) {
|
|
30259
30577
|
removeP2PExposeState(stateDir);
|
|
@@ -30312,7 +30630,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30312
30630
|
let lastMeteringLineCount = 0;
|
|
30313
30631
|
this._activityPollTimer = setInterval(() => {
|
|
30314
30632
|
try {
|
|
30315
|
-
const invocDir =
|
|
30633
|
+
const invocDir = join38(nexusDir, "invocations");
|
|
30316
30634
|
if (!existsSync28(invocDir))
|
|
30317
30635
|
return;
|
|
30318
30636
|
const files = readdirSync7(invocDir).filter((f) => f.endsWith(".json"));
|
|
@@ -30328,13 +30646,13 @@ ${this.formatConnectionInfo()}`);
|
|
|
30328
30646
|
let recentActive = 0;
|
|
30329
30647
|
for (const f of files.slice(-10)) {
|
|
30330
30648
|
try {
|
|
30331
|
-
const st = statSync10(
|
|
30649
|
+
const st = statSync10(join38(invocDir, f));
|
|
30332
30650
|
if (now - st.mtimeMs < 1e4)
|
|
30333
30651
|
recentActive++;
|
|
30334
30652
|
} catch {
|
|
30335
30653
|
}
|
|
30336
30654
|
}
|
|
30337
|
-
const meteringFile =
|
|
30655
|
+
const meteringFile = join38(nexusDir, "metering.jsonl");
|
|
30338
30656
|
let meteringLines = lastMeteringLineCount;
|
|
30339
30657
|
try {
|
|
30340
30658
|
if (existsSync28(meteringFile)) {
|
|
@@ -30364,7 +30682,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30364
30682
|
this._activityPollTimer.unref();
|
|
30365
30683
|
this._pollTimer = setInterval(() => {
|
|
30366
30684
|
try {
|
|
30367
|
-
const statusPath =
|
|
30685
|
+
const statusPath = join38(nexusDir, "status.json");
|
|
30368
30686
|
if (existsSync28(statusPath)) {
|
|
30369
30687
|
const status = JSON.parse(readFileSync19(statusPath, "utf8"));
|
|
30370
30688
|
if (status.peerId && !this._peerId) {
|
|
@@ -30375,7 +30693,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30375
30693
|
} catch {
|
|
30376
30694
|
}
|
|
30377
30695
|
try {
|
|
30378
|
-
const invocDir =
|
|
30696
|
+
const invocDir = join38(nexusDir, "invocations");
|
|
30379
30697
|
if (existsSync28(invocDir)) {
|
|
30380
30698
|
const files = readdirSync7(invocDir);
|
|
30381
30699
|
const invocCount = files.filter((f) => f.endsWith(".json")).length;
|
|
@@ -30387,7 +30705,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
30387
30705
|
} catch {
|
|
30388
30706
|
}
|
|
30389
30707
|
try {
|
|
30390
|
-
const meteringFile =
|
|
30708
|
+
const meteringFile = join38(nexusDir, "metering.jsonl");
|
|
30391
30709
|
if (existsSync28(meteringFile)) {
|
|
30392
30710
|
const content = readFileSync19(meteringFile, "utf8");
|
|
30393
30711
|
if (content.length > lastMeteringSize) {
|
|
@@ -30599,7 +30917,7 @@ var init_types = __esm({
|
|
|
30599
30917
|
// packages/cli/dist/tui/p2p/secret-vault.js
|
|
30600
30918
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes10, scryptSync as scryptSync2, createHash as createHash2 } from "node:crypto";
|
|
30601
30919
|
import { readFileSync as readFileSync20, writeFileSync as writeFileSync11, existsSync as existsSync29, mkdirSync as mkdirSync10 } from "node:fs";
|
|
30602
|
-
import { join as
|
|
30920
|
+
import { join as join39, dirname as dirname14 } from "node:path";
|
|
30603
30921
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
30604
30922
|
var init_secret_vault = __esm({
|
|
30605
30923
|
"packages/cli/dist/tui/p2p/secret-vault.js"() {
|
|
@@ -31936,13 +32254,13 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
31936
32254
|
try {
|
|
31937
32255
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
31938
32256
|
const { existsSync: existsSync45, readFileSync: readFileSync33 } = await import("node:fs");
|
|
31939
|
-
const { join:
|
|
32257
|
+
const { join: join59 } = await import("node:path");
|
|
31940
32258
|
const cwd4 = process.cwd();
|
|
31941
32259
|
const nexusTool = new NexusTool2(cwd4);
|
|
31942
32260
|
const nexusDir = nexusTool.getNexusDir();
|
|
31943
32261
|
let isLocalPeer = false;
|
|
31944
32262
|
try {
|
|
31945
|
-
const statusPath =
|
|
32263
|
+
const statusPath = join59(nexusDir, "status.json");
|
|
31946
32264
|
if (existsSync45(statusPath)) {
|
|
31947
32265
|
const status = JSON.parse(readFileSync33(statusPath, "utf8"));
|
|
31948
32266
|
if (status.peerId === peerId)
|
|
@@ -31951,7 +32269,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
31951
32269
|
} catch {
|
|
31952
32270
|
}
|
|
31953
32271
|
if (isLocalPeer) {
|
|
31954
|
-
const pricingPath =
|
|
32272
|
+
const pricingPath = join59(nexusDir, "pricing.json");
|
|
31955
32273
|
if (existsSync45(pricingPath)) {
|
|
31956
32274
|
try {
|
|
31957
32275
|
const pricing = JSON.parse(readFileSync33(pricingPath, "utf8"));
|
|
@@ -31968,7 +32286,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
31968
32286
|
}
|
|
31969
32287
|
}
|
|
31970
32288
|
}
|
|
31971
|
-
const cachePath =
|
|
32289
|
+
const cachePath = join59(nexusDir, "peer-models-cache.json");
|
|
31972
32290
|
if (existsSync45(cachePath)) {
|
|
31973
32291
|
try {
|
|
31974
32292
|
const cache4 = JSON.parse(readFileSync33(cachePath, "utf8"));
|
|
@@ -32086,7 +32404,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
32086
32404
|
} catch {
|
|
32087
32405
|
}
|
|
32088
32406
|
if (isLocalPeer) {
|
|
32089
|
-
const pricingPath =
|
|
32407
|
+
const pricingPath = join59(nexusDir, "pricing.json");
|
|
32090
32408
|
if (existsSync45(pricingPath)) {
|
|
32091
32409
|
try {
|
|
32092
32410
|
const pricing = JSON.parse(readFileSync33(pricingPath, "utf8"));
|
|
@@ -32359,12 +32677,12 @@ var init_render2 = __esm({
|
|
|
32359
32677
|
|
|
32360
32678
|
// packages/prompts/dist/promptLoader.js
|
|
32361
32679
|
import { readFileSync as readFileSync21, existsSync as existsSync30 } from "node:fs";
|
|
32362
|
-
import { join as
|
|
32680
|
+
import { join as join40, dirname as dirname15 } from "node:path";
|
|
32363
32681
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
32364
32682
|
function loadPrompt2(promptPath, vars) {
|
|
32365
32683
|
let content = cache2.get(promptPath);
|
|
32366
32684
|
if (content === void 0) {
|
|
32367
|
-
const fullPath =
|
|
32685
|
+
const fullPath = join40(PROMPTS_DIR2, promptPath);
|
|
32368
32686
|
if (!existsSync30(fullPath)) {
|
|
32369
32687
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
32370
32688
|
}
|
|
@@ -32381,8 +32699,8 @@ var init_promptLoader2 = __esm({
|
|
|
32381
32699
|
"use strict";
|
|
32382
32700
|
__filename2 = fileURLToPath9(import.meta.url);
|
|
32383
32701
|
__dirname5 = dirname15(__filename2);
|
|
32384
|
-
devPath =
|
|
32385
|
-
publishedPath =
|
|
32702
|
+
devPath = join40(__dirname5, "..", "templates");
|
|
32703
|
+
publishedPath = join40(__dirname5, "..", "prompts", "templates");
|
|
32386
32704
|
PROMPTS_DIR2 = existsSync30(devPath) ? devPath : publishedPath;
|
|
32387
32705
|
cache2 = /* @__PURE__ */ new Map();
|
|
32388
32706
|
}
|
|
@@ -32494,7 +32812,7 @@ var init_task_templates = __esm({
|
|
|
32494
32812
|
});
|
|
32495
32813
|
|
|
32496
32814
|
// packages/prompts/dist/index.js
|
|
32497
|
-
import { join as
|
|
32815
|
+
import { join as join41, dirname as dirname16 } from "node:path";
|
|
32498
32816
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
32499
32817
|
var _dir, _packageRoot;
|
|
32500
32818
|
var init_dist6 = __esm({
|
|
@@ -32505,21 +32823,21 @@ var init_dist6 = __esm({
|
|
|
32505
32823
|
init_task_templates();
|
|
32506
32824
|
init_render2();
|
|
32507
32825
|
_dir = dirname16(fileURLToPath10(import.meta.url));
|
|
32508
|
-
_packageRoot =
|
|
32826
|
+
_packageRoot = join41(_dir, "..");
|
|
32509
32827
|
}
|
|
32510
32828
|
});
|
|
32511
32829
|
|
|
32512
32830
|
// packages/cli/dist/tui/oa-directory.js
|
|
32513
32831
|
import { existsSync as existsSync31, mkdirSync as mkdirSync11, readFileSync as readFileSync22, writeFileSync as writeFileSync12, readdirSync as readdirSync8, statSync as statSync11, unlinkSync as unlinkSync6 } from "node:fs";
|
|
32514
|
-
import { join as
|
|
32832
|
+
import { join as join42, relative as relative2, basename as basename9, extname as extname8 } from "node:path";
|
|
32515
32833
|
import { homedir as homedir9 } from "node:os";
|
|
32516
32834
|
function initOaDirectory(repoRoot) {
|
|
32517
|
-
const oaPath =
|
|
32835
|
+
const oaPath = join42(repoRoot, OA_DIR);
|
|
32518
32836
|
for (const sub of SUBDIRS) {
|
|
32519
|
-
mkdirSync11(
|
|
32837
|
+
mkdirSync11(join42(oaPath, sub), { recursive: true });
|
|
32520
32838
|
}
|
|
32521
32839
|
try {
|
|
32522
|
-
const gitignorePath =
|
|
32840
|
+
const gitignorePath = join42(repoRoot, ".gitignore");
|
|
32523
32841
|
const settingsPattern = ".oa/settings.json";
|
|
32524
32842
|
if (existsSync31(gitignorePath)) {
|
|
32525
32843
|
const content = readFileSync22(gitignorePath, "utf-8");
|
|
@@ -32532,10 +32850,10 @@ function initOaDirectory(repoRoot) {
|
|
|
32532
32850
|
return oaPath;
|
|
32533
32851
|
}
|
|
32534
32852
|
function hasOaDirectory(repoRoot) {
|
|
32535
|
-
return existsSync31(
|
|
32853
|
+
return existsSync31(join42(repoRoot, OA_DIR, "index"));
|
|
32536
32854
|
}
|
|
32537
32855
|
function loadProjectSettings(repoRoot) {
|
|
32538
|
-
const settingsPath =
|
|
32856
|
+
const settingsPath = join42(repoRoot, OA_DIR, "settings.json");
|
|
32539
32857
|
try {
|
|
32540
32858
|
if (existsSync31(settingsPath)) {
|
|
32541
32859
|
return JSON.parse(readFileSync22(settingsPath, "utf-8"));
|
|
@@ -32545,14 +32863,14 @@ function loadProjectSettings(repoRoot) {
|
|
|
32545
32863
|
return {};
|
|
32546
32864
|
}
|
|
32547
32865
|
function saveProjectSettings(repoRoot, settings) {
|
|
32548
|
-
const oaPath =
|
|
32866
|
+
const oaPath = join42(repoRoot, OA_DIR);
|
|
32549
32867
|
mkdirSync11(oaPath, { recursive: true });
|
|
32550
32868
|
const existing = loadProjectSettings(repoRoot);
|
|
32551
32869
|
const merged = { ...existing, ...settings };
|
|
32552
|
-
writeFileSync12(
|
|
32870
|
+
writeFileSync12(join42(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
32553
32871
|
}
|
|
32554
32872
|
function loadGlobalSettings() {
|
|
32555
|
-
const settingsPath =
|
|
32873
|
+
const settingsPath = join42(homedir9(), ".open-agents", "settings.json");
|
|
32556
32874
|
try {
|
|
32557
32875
|
if (existsSync31(settingsPath)) {
|
|
32558
32876
|
return JSON.parse(readFileSync22(settingsPath, "utf-8"));
|
|
@@ -32562,11 +32880,11 @@ function loadGlobalSettings() {
|
|
|
32562
32880
|
return {};
|
|
32563
32881
|
}
|
|
32564
32882
|
function saveGlobalSettings(settings) {
|
|
32565
|
-
const dir =
|
|
32883
|
+
const dir = join42(homedir9(), ".open-agents");
|
|
32566
32884
|
mkdirSync11(dir, { recursive: true });
|
|
32567
32885
|
const existing = loadGlobalSettings();
|
|
32568
32886
|
const merged = { ...existing, ...settings };
|
|
32569
|
-
writeFileSync12(
|
|
32887
|
+
writeFileSync12(join42(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
32570
32888
|
}
|
|
32571
32889
|
function resolveSettings(repoRoot) {
|
|
32572
32890
|
const global = loadGlobalSettings();
|
|
@@ -32581,7 +32899,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
32581
32899
|
while (dir && !visited.has(dir)) {
|
|
32582
32900
|
visited.add(dir);
|
|
32583
32901
|
for (const name of CONTEXT_FILES) {
|
|
32584
|
-
const filePath =
|
|
32902
|
+
const filePath = join42(dir, name);
|
|
32585
32903
|
const normalizedName = name.toLowerCase();
|
|
32586
32904
|
if (existsSync31(filePath) && !seen.has(filePath)) {
|
|
32587
32905
|
seen.add(filePath);
|
|
@@ -32600,7 +32918,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
32600
32918
|
}
|
|
32601
32919
|
}
|
|
32602
32920
|
}
|
|
32603
|
-
const projectMap =
|
|
32921
|
+
const projectMap = join42(dir, OA_DIR, "context", "project-map.md");
|
|
32604
32922
|
if (existsSync31(projectMap) && !seen.has(projectMap)) {
|
|
32605
32923
|
seen.add(projectMap);
|
|
32606
32924
|
try {
|
|
@@ -32616,7 +32934,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
32616
32934
|
} catch {
|
|
32617
32935
|
}
|
|
32618
32936
|
}
|
|
32619
|
-
const parent =
|
|
32937
|
+
const parent = join42(dir, "..");
|
|
32620
32938
|
if (parent === dir)
|
|
32621
32939
|
break;
|
|
32622
32940
|
dir = parent;
|
|
@@ -32634,7 +32952,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
32634
32952
|
return found;
|
|
32635
32953
|
}
|
|
32636
32954
|
function readIndexMeta(repoRoot) {
|
|
32637
|
-
const metaPath =
|
|
32955
|
+
const metaPath = join42(repoRoot, OA_DIR, "index", "meta.json");
|
|
32638
32956
|
try {
|
|
32639
32957
|
return JSON.parse(readFileSync22(metaPath, "utf-8"));
|
|
32640
32958
|
} catch {
|
|
@@ -32687,28 +33005,28 @@ ${tree}\`\`\`
|
|
|
32687
33005
|
sections.push("");
|
|
32688
33006
|
}
|
|
32689
33007
|
const content = sections.join("\n");
|
|
32690
|
-
const contextDir =
|
|
33008
|
+
const contextDir = join42(repoRoot, OA_DIR, "context");
|
|
32691
33009
|
mkdirSync11(contextDir, { recursive: true });
|
|
32692
|
-
writeFileSync12(
|
|
33010
|
+
writeFileSync12(join42(contextDir, "project-map.md"), content, "utf-8");
|
|
32693
33011
|
return content;
|
|
32694
33012
|
}
|
|
32695
33013
|
function saveSession(repoRoot, session) {
|
|
32696
|
-
const historyDir =
|
|
33014
|
+
const historyDir = join42(repoRoot, OA_DIR, "history");
|
|
32697
33015
|
mkdirSync11(historyDir, { recursive: true });
|
|
32698
|
-
writeFileSync12(
|
|
33016
|
+
writeFileSync12(join42(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
|
|
32699
33017
|
}
|
|
32700
33018
|
function loadRecentSessions(repoRoot, limit = 5) {
|
|
32701
|
-
const historyDir =
|
|
33019
|
+
const historyDir = join42(repoRoot, OA_DIR, "history");
|
|
32702
33020
|
if (!existsSync31(historyDir))
|
|
32703
33021
|
return [];
|
|
32704
33022
|
try {
|
|
32705
33023
|
const files = readdirSync8(historyDir).filter((f) => f.endsWith(".json") && f !== "pending-task.json").map((f) => {
|
|
32706
|
-
const stat5 = statSync11(
|
|
33024
|
+
const stat5 = statSync11(join42(historyDir, f));
|
|
32707
33025
|
return { file: f, mtime: stat5.mtimeMs };
|
|
32708
33026
|
}).sort((a, b) => b.mtime - a.mtime).slice(0, limit);
|
|
32709
33027
|
return files.map((f) => {
|
|
32710
33028
|
try {
|
|
32711
|
-
return JSON.parse(readFileSync22(
|
|
33029
|
+
return JSON.parse(readFileSync22(join42(historyDir, f.file), "utf-8"));
|
|
32712
33030
|
} catch {
|
|
32713
33031
|
return null;
|
|
32714
33032
|
}
|
|
@@ -32718,12 +33036,12 @@ function loadRecentSessions(repoRoot, limit = 5) {
|
|
|
32718
33036
|
}
|
|
32719
33037
|
}
|
|
32720
33038
|
function savePendingTask(repoRoot, task) {
|
|
32721
|
-
const historyDir =
|
|
33039
|
+
const historyDir = join42(repoRoot, OA_DIR, "history");
|
|
32722
33040
|
mkdirSync11(historyDir, { recursive: true });
|
|
32723
|
-
writeFileSync12(
|
|
33041
|
+
writeFileSync12(join42(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
|
|
32724
33042
|
}
|
|
32725
33043
|
function loadPendingTask(repoRoot) {
|
|
32726
|
-
const filePath =
|
|
33044
|
+
const filePath = join42(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
|
|
32727
33045
|
try {
|
|
32728
33046
|
if (!existsSync31(filePath))
|
|
32729
33047
|
return null;
|
|
@@ -32738,9 +33056,9 @@ function loadPendingTask(repoRoot) {
|
|
|
32738
33056
|
}
|
|
32739
33057
|
}
|
|
32740
33058
|
function saveSessionContext(repoRoot, entry) {
|
|
32741
|
-
const contextDir =
|
|
33059
|
+
const contextDir = join42(repoRoot, OA_DIR, "context");
|
|
32742
33060
|
mkdirSync11(contextDir, { recursive: true });
|
|
32743
|
-
const filePath =
|
|
33061
|
+
const filePath = join42(contextDir, CONTEXT_SAVE_FILE);
|
|
32744
33062
|
let ctx;
|
|
32745
33063
|
try {
|
|
32746
33064
|
if (existsSync31(filePath)) {
|
|
@@ -32759,7 +33077,7 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
32759
33077
|
writeFileSync12(filePath, JSON.stringify(ctx, null, 2) + "\n", "utf-8");
|
|
32760
33078
|
}
|
|
32761
33079
|
function loadSessionContext(repoRoot) {
|
|
32762
|
-
const filePath =
|
|
33080
|
+
const filePath = join42(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
|
|
32763
33081
|
try {
|
|
32764
33082
|
if (!existsSync31(filePath))
|
|
32765
33083
|
return null;
|
|
@@ -32810,7 +33128,7 @@ function detectManifests(repoRoot) {
|
|
|
32810
33128
|
{ file: "docker-compose.yaml", type: "Docker Compose" }
|
|
32811
33129
|
];
|
|
32812
33130
|
for (const check of checks) {
|
|
32813
|
-
const filePath =
|
|
33131
|
+
const filePath = join42(repoRoot, check.file);
|
|
32814
33132
|
if (existsSync31(filePath)) {
|
|
32815
33133
|
let name;
|
|
32816
33134
|
if (check.nameField) {
|
|
@@ -32844,7 +33162,7 @@ function findKeyFiles(repoRoot) {
|
|
|
32844
33162
|
{ pattern: "CLAUDE.md", description: "Claude Code context" }
|
|
32845
33163
|
];
|
|
32846
33164
|
for (const check of checks) {
|
|
32847
|
-
if (existsSync31(
|
|
33165
|
+
if (existsSync31(join42(repoRoot, check.pattern))) {
|
|
32848
33166
|
keyFiles.push({ path: check.pattern, description: check.description });
|
|
32849
33167
|
}
|
|
32850
33168
|
}
|
|
@@ -32870,12 +33188,12 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
32870
33188
|
if (entry.isDirectory()) {
|
|
32871
33189
|
let fileCount = 0;
|
|
32872
33190
|
try {
|
|
32873
|
-
fileCount = readdirSync8(
|
|
33191
|
+
fileCount = readdirSync8(join42(root, entry.name)).filter((f) => !f.startsWith(".")).length;
|
|
32874
33192
|
} catch {
|
|
32875
33193
|
}
|
|
32876
33194
|
result += `${prefix}${connector}${entry.name}/ (${fileCount})
|
|
32877
33195
|
`;
|
|
32878
|
-
result += buildDirTree(
|
|
33196
|
+
result += buildDirTree(join42(root, entry.name), maxDepth, childPrefix, depth + 1);
|
|
32879
33197
|
} else if (depth < maxDepth) {
|
|
32880
33198
|
result += `${prefix}${connector}${entry.name}
|
|
32881
33199
|
`;
|
|
@@ -32895,7 +33213,7 @@ function loadUsageFile(filePath) {
|
|
|
32895
33213
|
return { records: [] };
|
|
32896
33214
|
}
|
|
32897
33215
|
function saveUsageFile(filePath, data) {
|
|
32898
|
-
const dir =
|
|
33216
|
+
const dir = join42(filePath, "..");
|
|
32899
33217
|
mkdirSync11(dir, { recursive: true });
|
|
32900
33218
|
writeFileSync12(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
32901
33219
|
}
|
|
@@ -32925,15 +33243,15 @@ function recordUsage(kind, value, opts) {
|
|
|
32925
33243
|
}
|
|
32926
33244
|
saveUsageFile(filePath, data);
|
|
32927
33245
|
};
|
|
32928
|
-
update(
|
|
33246
|
+
update(join42(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
|
|
32929
33247
|
if (opts?.repoRoot) {
|
|
32930
|
-
update(
|
|
33248
|
+
update(join42(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
32931
33249
|
}
|
|
32932
33250
|
}
|
|
32933
33251
|
function loadUsageHistory(kind, repoRoot) {
|
|
32934
|
-
const globalPath =
|
|
33252
|
+
const globalPath = join42(homedir9(), ".open-agents", USAGE_HISTORY_FILE);
|
|
32935
33253
|
const globalData = loadUsageFile(globalPath);
|
|
32936
|
-
const localData = repoRoot ? loadUsageFile(
|
|
33254
|
+
const localData = repoRoot ? loadUsageFile(join42(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
|
|
32937
33255
|
const map = /* @__PURE__ */ new Map();
|
|
32938
33256
|
for (const r of globalData.records) {
|
|
32939
33257
|
if (r.kind !== kind)
|
|
@@ -32964,9 +33282,9 @@ function deleteUsageRecord(kind, value, repoRoot) {
|
|
|
32964
33282
|
saveUsageFile(filePath, data);
|
|
32965
33283
|
}
|
|
32966
33284
|
};
|
|
32967
|
-
remove(
|
|
33285
|
+
remove(join42(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
|
|
32968
33286
|
if (repoRoot) {
|
|
32969
|
-
remove(
|
|
33287
|
+
remove(join42(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
|
|
32970
33288
|
}
|
|
32971
33289
|
}
|
|
32972
33290
|
var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
@@ -33017,7 +33335,7 @@ import * as readline from "node:readline";
|
|
|
33017
33335
|
import { execSync as execSync25, spawn as spawn18, exec as exec2 } from "node:child_process";
|
|
33018
33336
|
import { promisify as promisify5 } from "node:util";
|
|
33019
33337
|
import { existsSync as existsSync32, writeFileSync as writeFileSync13, readFileSync as readFileSync23, appendFileSync as appendFileSync2, mkdirSync as mkdirSync12 } from "node:fs";
|
|
33020
|
-
import { join as
|
|
33338
|
+
import { join as join43 } from "node:path";
|
|
33021
33339
|
import { homedir as homedir10, platform } from "node:os";
|
|
33022
33340
|
function detectSystemSpecs() {
|
|
33023
33341
|
let totalRamGB = 0;
|
|
@@ -34058,9 +34376,9 @@ async function doSetup(config, rl) {
|
|
|
34058
34376
|
`PARAMETER num_predict ${numPredict}`,
|
|
34059
34377
|
`PARAMETER stop "<|endoftext|>"`
|
|
34060
34378
|
].join("\n");
|
|
34061
|
-
const modelDir2 =
|
|
34379
|
+
const modelDir2 = join43(homedir10(), ".open-agents", "models");
|
|
34062
34380
|
mkdirSync12(modelDir2, { recursive: true });
|
|
34063
|
-
const modelfilePath =
|
|
34381
|
+
const modelfilePath = join43(modelDir2, `Modelfile.${customName}`);
|
|
34064
34382
|
writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
|
|
34065
34383
|
process.stdout.write(` ${c2.dim("Creating model...")} `);
|
|
34066
34384
|
execSync25(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
@@ -34106,7 +34424,7 @@ async function isModelAvailable(config) {
|
|
|
34106
34424
|
}
|
|
34107
34425
|
function isFirstRun() {
|
|
34108
34426
|
try {
|
|
34109
|
-
return !existsSync32(
|
|
34427
|
+
return !existsSync32(join43(homedir10(), ".open-agents", "config.json"));
|
|
34110
34428
|
} catch {
|
|
34111
34429
|
return true;
|
|
34112
34430
|
}
|
|
@@ -34143,7 +34461,7 @@ function detectPkgManager() {
|
|
|
34143
34461
|
return null;
|
|
34144
34462
|
}
|
|
34145
34463
|
function getVenvDir() {
|
|
34146
|
-
return
|
|
34464
|
+
return join43(homedir10(), ".open-agents", "venv");
|
|
34147
34465
|
}
|
|
34148
34466
|
function hasVenvModule() {
|
|
34149
34467
|
try {
|
|
@@ -34155,7 +34473,7 @@ function hasVenvModule() {
|
|
|
34155
34473
|
}
|
|
34156
34474
|
function ensureVenv(log) {
|
|
34157
34475
|
const venvDir = getVenvDir();
|
|
34158
|
-
const venvPip =
|
|
34476
|
+
const venvPip = join43(venvDir, "bin", "pip");
|
|
34159
34477
|
if (existsSync32(venvPip))
|
|
34160
34478
|
return venvDir;
|
|
34161
34479
|
log("Creating Python venv for vision deps...");
|
|
@@ -34168,9 +34486,9 @@ function ensureVenv(log) {
|
|
|
34168
34486
|
return null;
|
|
34169
34487
|
}
|
|
34170
34488
|
try {
|
|
34171
|
-
mkdirSync12(
|
|
34489
|
+
mkdirSync12(join43(homedir10(), ".open-agents"), { recursive: true });
|
|
34172
34490
|
execSync25(`python3 -m venv "${venvDir}"`, { stdio: "pipe", timeout: 3e4 });
|
|
34173
|
-
execSync25(`"${
|
|
34491
|
+
execSync25(`"${join43(venvDir, "bin", "pip")}" install --upgrade pip`, {
|
|
34174
34492
|
stdio: "pipe",
|
|
34175
34493
|
timeout: 6e4
|
|
34176
34494
|
});
|
|
@@ -34361,11 +34679,11 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
34361
34679
|
}
|
|
34362
34680
|
}
|
|
34363
34681
|
const venvDir = getVenvDir();
|
|
34364
|
-
const venvBin =
|
|
34365
|
-
const venvMoondream =
|
|
34682
|
+
const venvBin = join43(venvDir, "bin");
|
|
34683
|
+
const venvMoondream = join43(venvBin, "moondream-station");
|
|
34366
34684
|
const venv = ensureVenv(log);
|
|
34367
34685
|
if (venv && !hasCmd("moondream-station") && !existsSync32(venvMoondream)) {
|
|
34368
|
-
const venvPip =
|
|
34686
|
+
const venvPip = join43(venvBin, "pip");
|
|
34369
34687
|
log("Installing moondream-station in ~/.open-agents/venv...");
|
|
34370
34688
|
try {
|
|
34371
34689
|
execSync25(`"${venvPip}" install moondream-station`, { stdio: "pipe", timeout: 3e5 });
|
|
@@ -34386,8 +34704,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
34386
34704
|
}
|
|
34387
34705
|
}
|
|
34388
34706
|
if (venv) {
|
|
34389
|
-
const venvPython =
|
|
34390
|
-
const venvPip2 =
|
|
34707
|
+
const venvPython = join43(venvBin, "python");
|
|
34708
|
+
const venvPip2 = join43(venvBin, "pip");
|
|
34391
34709
|
let ocrStackInstalled = false;
|
|
34392
34710
|
try {
|
|
34393
34711
|
execSync25(`"${venvPython}" -c "import cv2, pytesseract, numpy, PIL"`, { stdio: "pipe", timeout: 1e4 });
|
|
@@ -34531,9 +34849,9 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
|
|
|
34531
34849
|
`PARAMETER num_predict ${numPredict}`,
|
|
34532
34850
|
`PARAMETER stop "<|endoftext|>"`
|
|
34533
34851
|
].join("\n");
|
|
34534
|
-
const modelDir2 =
|
|
34852
|
+
const modelDir2 = join43(homedir10(), ".open-agents", "models");
|
|
34535
34853
|
mkdirSync12(modelDir2, { recursive: true });
|
|
34536
|
-
const modelfilePath =
|
|
34854
|
+
const modelfilePath = join43(modelDir2, `Modelfile.${customName}`);
|
|
34537
34855
|
writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
|
|
34538
34856
|
await execAsync(`ollama create ${customName} -f ${modelfilePath}`, {
|
|
34539
34857
|
timeout: 12e4
|
|
@@ -34608,8 +34926,8 @@ async function ensureNeovim() {
|
|
|
34608
34926
|
const platform5 = process.platform;
|
|
34609
34927
|
const arch = process.arch;
|
|
34610
34928
|
if (platform5 === "linux") {
|
|
34611
|
-
const binDir =
|
|
34612
|
-
const nvimDest =
|
|
34929
|
+
const binDir = join43(homedir10(), ".local", "bin");
|
|
34930
|
+
const nvimDest = join43(binDir, "nvim");
|
|
34613
34931
|
try {
|
|
34614
34932
|
mkdirSync12(binDir, { recursive: true });
|
|
34615
34933
|
} catch {
|
|
@@ -34680,7 +34998,7 @@ async function ensureNeovim() {
|
|
|
34680
34998
|
}
|
|
34681
34999
|
function ensurePathInShellRc(binDir) {
|
|
34682
35000
|
const shell = process.env.SHELL ?? "";
|
|
34683
|
-
const rcFile = shell.includes("zsh") ?
|
|
35001
|
+
const rcFile = shell.includes("zsh") ? join43(homedir10(), ".zshrc") : join43(homedir10(), ".bashrc");
|
|
34684
35002
|
try {
|
|
34685
35003
|
const rcContent = existsSync32(rcFile) ? readFileSync23(rcFile, "utf8") : "";
|
|
34686
35004
|
if (rcContent.includes(binDir))
|
|
@@ -35452,7 +35770,7 @@ var init_drop_panel = __esm({
|
|
|
35452
35770
|
// packages/cli/dist/tui/neovim-mode.js
|
|
35453
35771
|
import { existsSync as existsSync34, unlinkSync as unlinkSync7 } from "node:fs";
|
|
35454
35772
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
35455
|
-
import { join as
|
|
35773
|
+
import { join as join44 } from "node:path";
|
|
35456
35774
|
import { execSync as execSync26 } from "node:child_process";
|
|
35457
35775
|
function isNeovimActive() {
|
|
35458
35776
|
return _state !== null && !_state.cleanedUp;
|
|
@@ -35500,7 +35818,7 @@ async function startNeovimMode(opts) {
|
|
|
35500
35818
|
);
|
|
35501
35819
|
} catch {
|
|
35502
35820
|
}
|
|
35503
|
-
const socketPath =
|
|
35821
|
+
const socketPath = join44(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
|
|
35504
35822
|
try {
|
|
35505
35823
|
if (existsSync34(socketPath))
|
|
35506
35824
|
unlinkSync7(socketPath);
|
|
@@ -35852,7 +36170,7 @@ __export(voice_exports, {
|
|
|
35852
36170
|
resetNarrationContext: () => resetNarrationContext
|
|
35853
36171
|
});
|
|
35854
36172
|
import { existsSync as existsSync35, mkdirSync as mkdirSync13, writeFileSync as writeFileSync14, readFileSync as readFileSync24, unlinkSync as unlinkSync8, readdirSync as readdirSync9, renameSync, statSync as statSync12 } from "node:fs";
|
|
35855
|
-
import { join as
|
|
36173
|
+
import { join as join45 } from "node:path";
|
|
35856
36174
|
import { homedir as homedir11, tmpdir as tmpdir9, platform as platform2 } from "node:os";
|
|
35857
36175
|
import { execSync as execSync27, spawn as nodeSpawn } from "node:child_process";
|
|
35858
36176
|
import { createRequire } from "node:module";
|
|
@@ -35874,34 +36192,34 @@ function listVoiceModels() {
|
|
|
35874
36192
|
}));
|
|
35875
36193
|
}
|
|
35876
36194
|
function voiceDir() {
|
|
35877
|
-
return
|
|
36195
|
+
return join45(homedir11(), ".open-agents", "voice");
|
|
35878
36196
|
}
|
|
35879
36197
|
function modelsDir() {
|
|
35880
|
-
return
|
|
36198
|
+
return join45(voiceDir(), "models");
|
|
35881
36199
|
}
|
|
35882
36200
|
function modelDir(id) {
|
|
35883
|
-
return
|
|
36201
|
+
return join45(modelsDir(), id);
|
|
35884
36202
|
}
|
|
35885
36203
|
function modelOnnxPath(id) {
|
|
35886
|
-
return
|
|
36204
|
+
return join45(modelDir(id), "model.onnx");
|
|
35887
36205
|
}
|
|
35888
36206
|
function modelConfigPath(id) {
|
|
35889
|
-
return
|
|
36207
|
+
return join45(modelDir(id), "config.json");
|
|
35890
36208
|
}
|
|
35891
36209
|
function luxttsVenvDir() {
|
|
35892
|
-
return
|
|
36210
|
+
return join45(voiceDir(), "luxtts-venv");
|
|
35893
36211
|
}
|
|
35894
36212
|
function luxttsVenvPy() {
|
|
35895
|
-
return platform2() === "win32" ?
|
|
36213
|
+
return platform2() === "win32" ? join45(luxttsVenvDir(), "Scripts", "python.exe") : join45(luxttsVenvDir(), "bin", "python3");
|
|
35896
36214
|
}
|
|
35897
36215
|
function luxttsRepoDir() {
|
|
35898
|
-
return
|
|
36216
|
+
return join45(voiceDir(), "LuxTTS");
|
|
35899
36217
|
}
|
|
35900
36218
|
function luxttsCloneRefsDir() {
|
|
35901
|
-
return
|
|
36219
|
+
return join45(voiceDir(), "clone-refs");
|
|
35902
36220
|
}
|
|
35903
36221
|
function luxttsInferScript() {
|
|
35904
|
-
return
|
|
36222
|
+
return join45(voiceDir(), "luxtts-infer.py");
|
|
35905
36223
|
}
|
|
35906
36224
|
function emotionToPitchBias(emotion, stark = false, autist = false) {
|
|
35907
36225
|
if (autist)
|
|
@@ -36709,7 +37027,7 @@ var init_voice = __esm({
|
|
|
36709
37027
|
const refsDir = luxttsCloneRefsDir();
|
|
36710
37028
|
const targets = ["glados", "overwatch"];
|
|
36711
37029
|
for (const modelId of targets) {
|
|
36712
|
-
const refFile =
|
|
37030
|
+
const refFile = join45(refsDir, `${modelId}-ref.wav`);
|
|
36713
37031
|
if (existsSync35(refFile))
|
|
36714
37032
|
continue;
|
|
36715
37033
|
try {
|
|
@@ -36789,7 +37107,7 @@ var init_voice = __esm({
|
|
|
36789
37107
|
}
|
|
36790
37108
|
p = p.replace(/\\ /g, " ");
|
|
36791
37109
|
if (p.startsWith("~/") || p === "~") {
|
|
36792
|
-
p =
|
|
37110
|
+
p = join45(homedir11(), p.slice(1));
|
|
36793
37111
|
}
|
|
36794
37112
|
if (!existsSync35(p)) {
|
|
36795
37113
|
return `File not found: ${p}
|
|
@@ -36803,7 +37121,7 @@ var init_voice = __esm({
|
|
|
36803
37121
|
const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
36804
37122
|
const ts = Date.now().toString(36);
|
|
36805
37123
|
const destFilename = `clone-${srcName}-${ts}.${ext}`;
|
|
36806
|
-
const destPath =
|
|
37124
|
+
const destPath = join45(refsDir, destFilename);
|
|
36807
37125
|
try {
|
|
36808
37126
|
const data = readFileSync24(audioPath);
|
|
36809
37127
|
writeFileSync14(destPath, data);
|
|
@@ -36848,7 +37166,7 @@ var init_voice = __esm({
|
|
|
36848
37166
|
const refsDir = luxttsCloneRefsDir();
|
|
36849
37167
|
if (!existsSync35(refsDir))
|
|
36850
37168
|
mkdirSync13(refsDir, { recursive: true });
|
|
36851
|
-
const destPath =
|
|
37169
|
+
const destPath = join45(refsDir, `${sourceModelId}-ref.wav`);
|
|
36852
37170
|
const sampleRate = this.config?.audio?.sample_rate ?? 22050;
|
|
36853
37171
|
this.writeWav(audioData, sampleRate, destPath);
|
|
36854
37172
|
this.luxttsCloneRef = destPath;
|
|
@@ -36864,7 +37182,7 @@ var init_voice = __esm({
|
|
|
36864
37182
|
// -------------------------------------------------------------------------
|
|
36865
37183
|
/** Metadata file for friendly names of clone refs */
|
|
36866
37184
|
static cloneMetaFile() {
|
|
36867
|
-
return
|
|
37185
|
+
return join45(luxttsCloneRefsDir(), "meta.json");
|
|
36868
37186
|
}
|
|
36869
37187
|
loadCloneMeta() {
|
|
36870
37188
|
const p = _VoiceEngine.cloneMetaFile();
|
|
@@ -36898,7 +37216,7 @@ var init_voice = __esm({
|
|
|
36898
37216
|
return _VoiceEngine.AUDIO_EXTS.has(ext);
|
|
36899
37217
|
});
|
|
36900
37218
|
return files.map((f) => {
|
|
36901
|
-
const p =
|
|
37219
|
+
const p = join45(dir, f);
|
|
36902
37220
|
let size = 0;
|
|
36903
37221
|
try {
|
|
36904
37222
|
size = statSync12(p).size;
|
|
@@ -36915,7 +37233,7 @@ var init_voice = __esm({
|
|
|
36915
37233
|
}
|
|
36916
37234
|
/** Delete a clone reference file by filename. Returns true if deleted. */
|
|
36917
37235
|
deleteCloneRef(filename) {
|
|
36918
|
-
const p =
|
|
37236
|
+
const p = join45(luxttsCloneRefsDir(), filename);
|
|
36919
37237
|
if (!existsSync35(p))
|
|
36920
37238
|
return false;
|
|
36921
37239
|
try {
|
|
@@ -36940,7 +37258,7 @@ var init_voice = __esm({
|
|
|
36940
37258
|
}
|
|
36941
37259
|
/** Set the active clone reference by filename. */
|
|
36942
37260
|
setActiveCloneRef(filename) {
|
|
36943
|
-
const p =
|
|
37261
|
+
const p = join45(luxttsCloneRefsDir(), filename);
|
|
36944
37262
|
if (!existsSync35(p))
|
|
36945
37263
|
return `File not found: ${filename}`;
|
|
36946
37264
|
this.luxttsCloneRef = p;
|
|
@@ -37226,7 +37544,7 @@ var init_voice = __esm({
|
|
|
37226
37544
|
}
|
|
37227
37545
|
this.onPCMOutput(Buffer.from(int16.buffer), sampleRate);
|
|
37228
37546
|
}
|
|
37229
|
-
const wavPath =
|
|
37547
|
+
const wavPath = join45(tmpdir9(), `oa-voice-${Date.now()}.wav`);
|
|
37230
37548
|
this.writeWav(audioData, sampleRate, wavPath);
|
|
37231
37549
|
await this.playWav(wavPath);
|
|
37232
37550
|
try {
|
|
@@ -37569,7 +37887,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
37569
37887
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
37570
37888
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
37571
37889
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
37572
|
-
const wavPath =
|
|
37890
|
+
const wavPath = join45(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
|
|
37573
37891
|
const pyScript = [
|
|
37574
37892
|
"import sys, json",
|
|
37575
37893
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -37637,7 +37955,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
37637
37955
|
const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
|
|
37638
37956
|
const mlxVoice = model.mlxVoice ?? "af_heart";
|
|
37639
37957
|
const mlxLangCode = model.mlxLangCode ?? "a";
|
|
37640
|
-
const wavPath =
|
|
37958
|
+
const wavPath = join45(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
|
|
37641
37959
|
const pyScript = [
|
|
37642
37960
|
"import sys, json",
|
|
37643
37961
|
"from mlx_audio.tts import generate as tts_gen",
|
|
@@ -37748,7 +38066,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
37748
38066
|
}
|
|
37749
38067
|
}
|
|
37750
38068
|
const repoDir = luxttsRepoDir();
|
|
37751
|
-
if (!existsSync35(
|
|
38069
|
+
if (!existsSync35(join45(repoDir, "zipvoice", "luxvoice.py"))) {
|
|
37752
38070
|
renderInfo(" Cloning LuxTTS repository...");
|
|
37753
38071
|
try {
|
|
37754
38072
|
if (existsSync35(repoDir)) {
|
|
@@ -37797,7 +38115,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
|
37797
38115
|
if (!existsSync35(refsDir))
|
|
37798
38116
|
return;
|
|
37799
38117
|
for (const name of ["custom-clone.wav", "custom-clone.mp3", "glados-ref.wav", "overwatch-ref.wav"]) {
|
|
37800
|
-
const p =
|
|
38118
|
+
const p = join45(refsDir, name);
|
|
37801
38119
|
if (existsSync35(p)) {
|
|
37802
38120
|
this.luxttsCloneRef = p;
|
|
37803
38121
|
return;
|
|
@@ -37994,7 +38312,7 @@ if __name__ == '__main__':
|
|
|
37994
38312
|
const ready = await this.ensureLuxttsDaemon();
|
|
37995
38313
|
if (!ready)
|
|
37996
38314
|
return;
|
|
37997
|
-
const wavPath =
|
|
38315
|
+
const wavPath = join45(tmpdir9(), `oa-luxtts-${Date.now()}.wav`);
|
|
37998
38316
|
try {
|
|
37999
38317
|
await this.luxttsRequest({
|
|
38000
38318
|
action: "synthesize",
|
|
@@ -38068,7 +38386,7 @@ if __name__ == '__main__':
|
|
|
38068
38386
|
const ready = await this.ensureLuxttsDaemon();
|
|
38069
38387
|
if (!ready)
|
|
38070
38388
|
return null;
|
|
38071
|
-
const wavPath =
|
|
38389
|
+
const wavPath = join45(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
|
|
38072
38390
|
try {
|
|
38073
38391
|
await this.luxttsRequest({
|
|
38074
38392
|
action: "synthesize",
|
|
@@ -38098,7 +38416,7 @@ if __name__ == '__main__':
|
|
|
38098
38416
|
return;
|
|
38099
38417
|
const arch = process.arch;
|
|
38100
38418
|
mkdirSync13(voiceDir(), { recursive: true });
|
|
38101
|
-
const pkgPath =
|
|
38419
|
+
const pkgPath = join45(voiceDir(), "package.json");
|
|
38102
38420
|
const expectedDeps = {
|
|
38103
38421
|
"onnxruntime-node": "^1.21.0",
|
|
38104
38422
|
"phonemizer": "^1.2.1"
|
|
@@ -38120,17 +38438,17 @@ if __name__ == '__main__':
|
|
|
38120
38438
|
dependencies: expectedDeps
|
|
38121
38439
|
}, null, 2));
|
|
38122
38440
|
}
|
|
38123
|
-
const voiceRequire = createRequire(
|
|
38441
|
+
const voiceRequire = createRequire(join45(voiceDir(), "index.js"));
|
|
38124
38442
|
const probeOnnx = () => {
|
|
38125
38443
|
try {
|
|
38126
|
-
const result = execSync27(`node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, { cwd: voiceDir(), stdio: "pipe", timeout: 15e3, env: { ...process.env, NODE_PATH:
|
|
38444
|
+
const result = execSync27(`node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, { cwd: voiceDir(), stdio: "pipe", timeout: 15e3, env: { ...process.env, NODE_PATH: join45(voiceDir(), "node_modules") } });
|
|
38127
38445
|
const output = result.toString().trim();
|
|
38128
38446
|
return output === "OK";
|
|
38129
38447
|
} catch {
|
|
38130
38448
|
return false;
|
|
38131
38449
|
}
|
|
38132
38450
|
};
|
|
38133
|
-
const onnxNodeModules =
|
|
38451
|
+
const onnxNodeModules = join45(voiceDir(), "node_modules", "onnxruntime-node");
|
|
38134
38452
|
const onnxInstalled = existsSync35(onnxNodeModules);
|
|
38135
38453
|
if (onnxInstalled && !probeOnnx()) {
|
|
38136
38454
|
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.`);
|
|
@@ -40474,8 +40792,8 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
|
|
|
40474
40792
|
if (models.length > 0) {
|
|
40475
40793
|
try {
|
|
40476
40794
|
const { writeFileSync: writeFileSync20, mkdirSync: mkdirSync21 } = await import("node:fs");
|
|
40477
|
-
const { join:
|
|
40478
|
-
const cachePath =
|
|
40795
|
+
const { join: join59, dirname: dirname20 } = await import("node:path");
|
|
40796
|
+
const cachePath = join59(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
|
|
40479
40797
|
mkdirSync21(dirname20(cachePath), { recursive: true });
|
|
40480
40798
|
writeFileSync20(cachePath, JSON.stringify({
|
|
40481
40799
|
peerId,
|
|
@@ -40676,14 +40994,14 @@ async function handleUpdate(subcommand, ctx) {
|
|
|
40676
40994
|
try {
|
|
40677
40995
|
const { createRequire: createRequire4 } = await import("node:module");
|
|
40678
40996
|
const { fileURLToPath: fileURLToPath14 } = await import("node:url");
|
|
40679
|
-
const { dirname: dirname20, join:
|
|
40997
|
+
const { dirname: dirname20, join: join59 } = await import("node:path");
|
|
40680
40998
|
const { existsSync: existsSync45 } = await import("node:fs");
|
|
40681
40999
|
const req = createRequire4(import.meta.url);
|
|
40682
41000
|
const thisDir = dirname20(fileURLToPath14(import.meta.url));
|
|
40683
41001
|
const candidates = [
|
|
40684
|
-
|
|
40685
|
-
|
|
40686
|
-
|
|
41002
|
+
join59(thisDir, "..", "package.json"),
|
|
41003
|
+
join59(thisDir, "..", "..", "package.json"),
|
|
41004
|
+
join59(thisDir, "..", "..", "..", "package.json")
|
|
40687
41005
|
];
|
|
40688
41006
|
for (const pkgPath of candidates) {
|
|
40689
41007
|
if (existsSync45(pkgPath)) {
|
|
@@ -41401,7 +41719,7 @@ var init_commands = __esm({
|
|
|
41401
41719
|
|
|
41402
41720
|
// packages/cli/dist/tui/project-context.js
|
|
41403
41721
|
import { existsSync as existsSync36, readFileSync as readFileSync25, readdirSync as readdirSync10 } from "node:fs";
|
|
41404
|
-
import { join as
|
|
41722
|
+
import { join as join46, basename as basename10 } from "node:path";
|
|
41405
41723
|
import { execSync as execSync28 } from "node:child_process";
|
|
41406
41724
|
import { homedir as homedir12, platform as platform3, release } from "node:os";
|
|
41407
41725
|
function getModelTier(modelName) {
|
|
@@ -41436,7 +41754,7 @@ function loadProjectMap(repoRoot) {
|
|
|
41436
41754
|
if (!hasOaDirectory(repoRoot)) {
|
|
41437
41755
|
initOaDirectory(repoRoot);
|
|
41438
41756
|
}
|
|
41439
|
-
const mapPath =
|
|
41757
|
+
const mapPath = join46(repoRoot, OA_DIR, "context", "project-map.md");
|
|
41440
41758
|
if (existsSync36(mapPath)) {
|
|
41441
41759
|
try {
|
|
41442
41760
|
const content = readFileSync25(mapPath, "utf-8");
|
|
@@ -41480,17 +41798,17 @@ ${log}`);
|
|
|
41480
41798
|
}
|
|
41481
41799
|
function loadMemoryContext(repoRoot) {
|
|
41482
41800
|
const sections = [];
|
|
41483
|
-
const oaMemDir =
|
|
41801
|
+
const oaMemDir = join46(repoRoot, OA_DIR, "memory");
|
|
41484
41802
|
const oaEntries = loadMemoryDir(oaMemDir, "project");
|
|
41485
41803
|
if (oaEntries)
|
|
41486
41804
|
sections.push(oaEntries);
|
|
41487
|
-
const legacyMemDir =
|
|
41805
|
+
const legacyMemDir = join46(repoRoot, ".open-agents", "memory");
|
|
41488
41806
|
if (legacyMemDir !== oaMemDir && existsSync36(legacyMemDir)) {
|
|
41489
41807
|
const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
|
|
41490
41808
|
if (legacyEntries)
|
|
41491
41809
|
sections.push(legacyEntries);
|
|
41492
41810
|
}
|
|
41493
|
-
const globalMemDir =
|
|
41811
|
+
const globalMemDir = join46(homedir12(), ".open-agents", "memory");
|
|
41494
41812
|
const globalEntries = loadMemoryDir(globalMemDir, "global");
|
|
41495
41813
|
if (globalEntries)
|
|
41496
41814
|
sections.push(globalEntries);
|
|
@@ -41504,7 +41822,7 @@ function loadMemoryDir(memDir, scope) {
|
|
|
41504
41822
|
const files = readdirSync10(memDir).filter((f) => f.endsWith(".json"));
|
|
41505
41823
|
for (const file of files.slice(0, 10)) {
|
|
41506
41824
|
try {
|
|
41507
|
-
const raw = readFileSync25(
|
|
41825
|
+
const raw = readFileSync25(join46(memDir, file), "utf-8");
|
|
41508
41826
|
const entries = JSON.parse(raw);
|
|
41509
41827
|
const topic = basename10(file, ".json");
|
|
41510
41828
|
const keys = Object.keys(entries);
|
|
@@ -42528,9 +42846,9 @@ var init_carousel = __esm({
|
|
|
42528
42846
|
|
|
42529
42847
|
// packages/cli/dist/tui/carousel-descriptors.js
|
|
42530
42848
|
import { existsSync as existsSync37, readFileSync as readFileSync26, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, readdirSync as readdirSync11 } from "node:fs";
|
|
42531
|
-
import { join as
|
|
42849
|
+
import { join as join47, basename as basename11 } from "node:path";
|
|
42532
42850
|
function loadToolProfile(repoRoot) {
|
|
42533
|
-
const filePath =
|
|
42851
|
+
const filePath = join47(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
|
|
42534
42852
|
try {
|
|
42535
42853
|
if (!existsSync37(filePath))
|
|
42536
42854
|
return null;
|
|
@@ -42540,9 +42858,9 @@ function loadToolProfile(repoRoot) {
|
|
|
42540
42858
|
}
|
|
42541
42859
|
}
|
|
42542
42860
|
function saveToolProfile(repoRoot, profile) {
|
|
42543
|
-
const contextDir =
|
|
42861
|
+
const contextDir = join47(repoRoot, OA_DIR, "context");
|
|
42544
42862
|
mkdirSync14(contextDir, { recursive: true });
|
|
42545
|
-
writeFileSync15(
|
|
42863
|
+
writeFileSync15(join47(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
|
|
42546
42864
|
}
|
|
42547
42865
|
function categorizeToolCall(toolName) {
|
|
42548
42866
|
for (const cat of TOOL_CATEGORIES) {
|
|
@@ -42600,7 +42918,7 @@ function weightedColor(profile) {
|
|
|
42600
42918
|
return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
|
|
42601
42919
|
}
|
|
42602
42920
|
function loadCachedDescriptors(repoRoot) {
|
|
42603
|
-
const filePath =
|
|
42921
|
+
const filePath = join47(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
|
|
42604
42922
|
try {
|
|
42605
42923
|
if (!existsSync37(filePath))
|
|
42606
42924
|
return null;
|
|
@@ -42611,14 +42929,14 @@ function loadCachedDescriptors(repoRoot) {
|
|
|
42611
42929
|
}
|
|
42612
42930
|
}
|
|
42613
42931
|
function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
|
|
42614
|
-
const contextDir =
|
|
42932
|
+
const contextDir = join47(repoRoot, OA_DIR, "context");
|
|
42615
42933
|
mkdirSync14(contextDir, { recursive: true });
|
|
42616
42934
|
const cached = {
|
|
42617
42935
|
phrases,
|
|
42618
42936
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
42619
42937
|
sourceHash
|
|
42620
42938
|
};
|
|
42621
|
-
writeFileSync15(
|
|
42939
|
+
writeFileSync15(join47(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
|
|
42622
42940
|
}
|
|
42623
42941
|
function generateDescriptors(repoRoot) {
|
|
42624
42942
|
const profile = loadToolProfile(repoRoot);
|
|
@@ -42666,7 +42984,7 @@ function generateDescriptors(repoRoot) {
|
|
|
42666
42984
|
return phrases;
|
|
42667
42985
|
}
|
|
42668
42986
|
function extractFromPackageJson(repoRoot, tags) {
|
|
42669
|
-
const pkgPath =
|
|
42987
|
+
const pkgPath = join47(repoRoot, "package.json");
|
|
42670
42988
|
try {
|
|
42671
42989
|
if (!existsSync37(pkgPath))
|
|
42672
42990
|
return;
|
|
@@ -42714,7 +43032,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
42714
43032
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
42715
43033
|
];
|
|
42716
43034
|
for (const check of manifestChecks) {
|
|
42717
|
-
if (existsSync37(
|
|
43035
|
+
if (existsSync37(join47(repoRoot, check.file))) {
|
|
42718
43036
|
tags.push(check.tag);
|
|
42719
43037
|
}
|
|
42720
43038
|
}
|
|
@@ -42736,7 +43054,7 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
42736
43054
|
}
|
|
42737
43055
|
}
|
|
42738
43056
|
function extractFromMemory(repoRoot, tags) {
|
|
42739
|
-
const memoryDir =
|
|
43057
|
+
const memoryDir = join47(repoRoot, OA_DIR, "memory");
|
|
42740
43058
|
try {
|
|
42741
43059
|
if (!existsSync37(memoryDir))
|
|
42742
43060
|
return;
|
|
@@ -42745,7 +43063,7 @@ function extractFromMemory(repoRoot, tags) {
|
|
|
42745
43063
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
42746
43064
|
tags.push(topic);
|
|
42747
43065
|
try {
|
|
42748
|
-
const data = JSON.parse(readFileSync26(
|
|
43066
|
+
const data = JSON.parse(readFileSync26(join47(memoryDir, file), "utf-8"));
|
|
42749
43067
|
if (data && typeof data === "object") {
|
|
42750
43068
|
const keys = Object.keys(data).slice(0, 3);
|
|
42751
43069
|
for (const key of keys) {
|
|
@@ -43368,10 +43686,10 @@ var init_stream_renderer = __esm({
|
|
|
43368
43686
|
|
|
43369
43687
|
// packages/cli/dist/tui/edit-history.js
|
|
43370
43688
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync15 } from "node:fs";
|
|
43371
|
-
import { join as
|
|
43689
|
+
import { join as join48 } from "node:path";
|
|
43372
43690
|
function createEditHistoryLogger(repoRoot, sessionId) {
|
|
43373
|
-
const historyDir =
|
|
43374
|
-
const logPath =
|
|
43691
|
+
const historyDir = join48(repoRoot, ".oa", "history");
|
|
43692
|
+
const logPath = join48(historyDir, "edits.jsonl");
|
|
43375
43693
|
try {
|
|
43376
43694
|
mkdirSync15(historyDir, { recursive: true });
|
|
43377
43695
|
} catch {
|
|
@@ -43483,12 +43801,12 @@ var init_edit_history = __esm({
|
|
|
43483
43801
|
|
|
43484
43802
|
// packages/cli/dist/tui/promptLoader.js
|
|
43485
43803
|
import { readFileSync as readFileSync27, existsSync as existsSync38 } from "node:fs";
|
|
43486
|
-
import { join as
|
|
43804
|
+
import { join as join49, dirname as dirname17 } from "node:path";
|
|
43487
43805
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
43488
43806
|
function loadPrompt3(promptPath, vars) {
|
|
43489
43807
|
let content = cache3.get(promptPath);
|
|
43490
43808
|
if (content === void 0) {
|
|
43491
|
-
const fullPath =
|
|
43809
|
+
const fullPath = join49(PROMPTS_DIR3, promptPath);
|
|
43492
43810
|
if (!existsSync38(fullPath)) {
|
|
43493
43811
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
43494
43812
|
}
|
|
@@ -43505,8 +43823,8 @@ var init_promptLoader3 = __esm({
|
|
|
43505
43823
|
"use strict";
|
|
43506
43824
|
__filename3 = fileURLToPath11(import.meta.url);
|
|
43507
43825
|
__dirname6 = dirname17(__filename3);
|
|
43508
|
-
devPath2 =
|
|
43509
|
-
publishedPath2 =
|
|
43826
|
+
devPath2 = join49(__dirname6, "..", "..", "prompts");
|
|
43827
|
+
publishedPath2 = join49(__dirname6, "..", "prompts");
|
|
43510
43828
|
PROMPTS_DIR3 = existsSync38(devPath2) ? devPath2 : publishedPath2;
|
|
43511
43829
|
cache3 = /* @__PURE__ */ new Map();
|
|
43512
43830
|
}
|
|
@@ -43514,10 +43832,10 @@ var init_promptLoader3 = __esm({
|
|
|
43514
43832
|
|
|
43515
43833
|
// packages/cli/dist/tui/dream-engine.js
|
|
43516
43834
|
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync16, readFileSync as readFileSync28, existsSync as existsSync39, cpSync, rmSync, readdirSync as readdirSync12 } from "node:fs";
|
|
43517
|
-
import { join as
|
|
43835
|
+
import { join as join50, basename as basename12 } from "node:path";
|
|
43518
43836
|
import { execSync as execSync29 } from "node:child_process";
|
|
43519
43837
|
function loadAutoresearchMemory(repoRoot) {
|
|
43520
|
-
const memoryPath =
|
|
43838
|
+
const memoryPath = join50(repoRoot, ".oa", "memory", "autoresearch.json");
|
|
43521
43839
|
if (!existsSync39(memoryPath))
|
|
43522
43840
|
return "";
|
|
43523
43841
|
try {
|
|
@@ -43711,12 +44029,12 @@ var init_dream_engine = __esm({
|
|
|
43711
44029
|
const content = String(args["content"] ?? "");
|
|
43712
44030
|
if (!rawPath)
|
|
43713
44031
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
43714
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
44032
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join50(this.autoresearchDir, basename12(rawPath)) : join50(this.autoresearchDir, rawPath);
|
|
43715
44033
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
43716
44034
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
43717
44035
|
}
|
|
43718
44036
|
try {
|
|
43719
|
-
const dir =
|
|
44037
|
+
const dir = join50(targetPath, "..");
|
|
43720
44038
|
mkdirSync16(dir, { recursive: true });
|
|
43721
44039
|
writeFileSync16(targetPath, content, "utf-8");
|
|
43722
44040
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
@@ -43746,7 +44064,7 @@ var init_dream_engine = __esm({
|
|
|
43746
44064
|
const rawPath = String(args["path"] ?? "");
|
|
43747
44065
|
const oldStr = String(args["old_string"] ?? "");
|
|
43748
44066
|
const newStr = String(args["new_string"] ?? "");
|
|
43749
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ?
|
|
44067
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join50(this.autoresearchDir, basename12(rawPath)) : join50(this.autoresearchDir, rawPath);
|
|
43750
44068
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
43751
44069
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start };
|
|
43752
44070
|
}
|
|
@@ -43800,12 +44118,12 @@ var init_dream_engine = __esm({
|
|
|
43800
44118
|
const content = String(args["content"] ?? "");
|
|
43801
44119
|
if (!rawPath)
|
|
43802
44120
|
return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
|
|
43803
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
44121
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join50(this.dreamsDir, basename12(rawPath)) : join50(this.dreamsDir, rawPath);
|
|
43804
44122
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
43805
44123
|
return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
43806
44124
|
}
|
|
43807
44125
|
try {
|
|
43808
|
-
const dir =
|
|
44126
|
+
const dir = join50(targetPath, "..");
|
|
43809
44127
|
mkdirSync16(dir, { recursive: true });
|
|
43810
44128
|
writeFileSync16(targetPath, content, "utf-8");
|
|
43811
44129
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
|
|
@@ -43835,7 +44153,7 @@ var init_dream_engine = __esm({
|
|
|
43835
44153
|
const rawPath = String(args["path"] ?? "");
|
|
43836
44154
|
const oldStr = String(args["old_string"] ?? "");
|
|
43837
44155
|
const newStr = String(args["new_string"] ?? "");
|
|
43838
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ?
|
|
44156
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join50(this.dreamsDir, basename12(rawPath)) : join50(this.dreamsDir, rawPath);
|
|
43839
44157
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
43840
44158
|
return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start };
|
|
43841
44159
|
}
|
|
@@ -43902,7 +44220,7 @@ var init_dream_engine = __esm({
|
|
|
43902
44220
|
constructor(config, repoRoot) {
|
|
43903
44221
|
this.config = config;
|
|
43904
44222
|
this.repoRoot = repoRoot;
|
|
43905
|
-
this.dreamsDir =
|
|
44223
|
+
this.dreamsDir = join50(repoRoot, ".oa", "dreams");
|
|
43906
44224
|
this.state = {
|
|
43907
44225
|
mode: "default",
|
|
43908
44226
|
active: false,
|
|
@@ -43986,7 +44304,7 @@ ${result.summary}`;
|
|
|
43986
44304
|
if (mode !== "default" || cycle === totalCycles) {
|
|
43987
44305
|
renderDreamContraction(cycle);
|
|
43988
44306
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
43989
|
-
const summaryPath =
|
|
44307
|
+
const summaryPath = join50(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
43990
44308
|
writeFileSync16(summaryPath, cycleSummary, "utf-8");
|
|
43991
44309
|
}
|
|
43992
44310
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
@@ -44199,7 +44517,7 @@ After synthesis, call task_complete with the final prioritized summary.`, toolMo
|
|
|
44199
44517
|
}
|
|
44200
44518
|
/** Build role-specific tool sets for swarm agents */
|
|
44201
44519
|
buildSwarmTools(role, _workspace) {
|
|
44202
|
-
const autoresearchDir =
|
|
44520
|
+
const autoresearchDir = join50(this.repoRoot, ".oa", "autoresearch");
|
|
44203
44521
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
44204
44522
|
switch (role) {
|
|
44205
44523
|
case "researcher": {
|
|
@@ -44563,7 +44881,7 @@ INSTRUCTIONS:
|
|
|
44563
44881
|
2. Summarize the key learnings and next steps
|
|
44564
44882
|
|
|
44565
44883
|
Call task_complete with a human-readable summary of the autoresearch session.`, workspace, onEvent);
|
|
44566
|
-
const reportPath =
|
|
44884
|
+
const reportPath = join50(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
44567
44885
|
const report = `# Autoresearch Swarm Report \u2014 Cycle ${cycleNum}
|
|
44568
44886
|
|
|
44569
44887
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -44652,7 +44970,7 @@ ${summaryResult}
|
|
|
44652
44970
|
}
|
|
44653
44971
|
/** Save workspace backup for lucid mode */
|
|
44654
44972
|
saveVersionCheckpoint(cycle) {
|
|
44655
|
-
const checkpointDir =
|
|
44973
|
+
const checkpointDir = join50(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
44656
44974
|
try {
|
|
44657
44975
|
mkdirSync16(checkpointDir, { recursive: true });
|
|
44658
44976
|
try {
|
|
@@ -44671,10 +44989,10 @@ ${summaryResult}
|
|
|
44671
44989
|
encoding: "utf-8",
|
|
44672
44990
|
timeout: 5e3
|
|
44673
44991
|
}).trim();
|
|
44674
|
-
writeFileSync16(
|
|
44675
|
-
writeFileSync16(
|
|
44676
|
-
writeFileSync16(
|
|
44677
|
-
writeFileSync16(
|
|
44992
|
+
writeFileSync16(join50(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
|
|
44993
|
+
writeFileSync16(join50(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
|
|
44994
|
+
writeFileSync16(join50(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
|
|
44995
|
+
writeFileSync16(join50(checkpointDir, "checkpoint.json"), JSON.stringify({
|
|
44678
44996
|
cycle,
|
|
44679
44997
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
44680
44998
|
gitHash,
|
|
@@ -44682,7 +45000,7 @@ ${summaryResult}
|
|
|
44682
45000
|
}, null, 2), "utf-8");
|
|
44683
45001
|
renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
44684
45002
|
} catch {
|
|
44685
|
-
writeFileSync16(
|
|
45003
|
+
writeFileSync16(join50(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
|
|
44686
45004
|
renderInfo(`Checkpoint saved: cycle ${cycle} (no git)`);
|
|
44687
45005
|
}
|
|
44688
45006
|
} catch (err) {
|
|
@@ -44740,14 +45058,14 @@ ${files.map((f) => `- [\`${f}\`](./${f})`).join("\n")}
|
|
|
44740
45058
|
---
|
|
44741
45059
|
*Auto-generated by open-agents dream engine*
|
|
44742
45060
|
`;
|
|
44743
|
-
writeFileSync16(
|
|
45061
|
+
writeFileSync16(join50(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
44744
45062
|
} catch {
|
|
44745
45063
|
}
|
|
44746
45064
|
}
|
|
44747
45065
|
/** Save dream state for resume/inspection */
|
|
44748
45066
|
saveDreamState() {
|
|
44749
45067
|
try {
|
|
44750
|
-
writeFileSync16(
|
|
45068
|
+
writeFileSync16(join50(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
44751
45069
|
} catch {
|
|
44752
45070
|
}
|
|
44753
45071
|
}
|
|
@@ -45122,7 +45440,7 @@ var init_bless_engine = __esm({
|
|
|
45122
45440
|
|
|
45123
45441
|
// packages/cli/dist/tui/dmn-engine.js
|
|
45124
45442
|
import { existsSync as existsSync40, readFileSync as readFileSync29, writeFileSync as writeFileSync17, mkdirSync as mkdirSync17, readdirSync as readdirSync13, unlinkSync as unlinkSync9 } from "node:fs";
|
|
45125
|
-
import { join as
|
|
45443
|
+
import { join as join51, basename as basename13 } from "node:path";
|
|
45126
45444
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
45127
45445
|
const competenceReport = competence.length > 0 ? competence.map((c3) => {
|
|
45128
45446
|
const rate = c3.attempts > 0 ? Math.round(c3.successes / c3.attempts * 100) : 0;
|
|
@@ -45235,8 +45553,8 @@ var init_dmn_engine = __esm({
|
|
|
45235
45553
|
constructor(config, repoRoot) {
|
|
45236
45554
|
this.config = config;
|
|
45237
45555
|
this.repoRoot = repoRoot;
|
|
45238
|
-
this.stateDir =
|
|
45239
|
-
this.historyDir =
|
|
45556
|
+
this.stateDir = join51(repoRoot, ".oa", "dmn");
|
|
45557
|
+
this.historyDir = join51(repoRoot, ".oa", "dmn", "cycles");
|
|
45240
45558
|
mkdirSync17(this.historyDir, { recursive: true });
|
|
45241
45559
|
this.loadState();
|
|
45242
45560
|
}
|
|
@@ -45826,8 +46144,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
45826
46144
|
async gatherMemoryTopics() {
|
|
45827
46145
|
const topics = [];
|
|
45828
46146
|
const dirs = [
|
|
45829
|
-
|
|
45830
|
-
|
|
46147
|
+
join51(this.repoRoot, ".oa", "memory"),
|
|
46148
|
+
join51(this.repoRoot, ".open-agents", "memory")
|
|
45831
46149
|
];
|
|
45832
46150
|
for (const dir of dirs) {
|
|
45833
46151
|
if (!existsSync40(dir))
|
|
@@ -45846,7 +46164,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
45846
46164
|
}
|
|
45847
46165
|
// ── State persistence ─────────────────────────────────────────────────
|
|
45848
46166
|
loadState() {
|
|
45849
|
-
const path =
|
|
46167
|
+
const path = join51(this.stateDir, "state.json");
|
|
45850
46168
|
if (existsSync40(path)) {
|
|
45851
46169
|
try {
|
|
45852
46170
|
this.state = JSON.parse(readFileSync29(path, "utf-8"));
|
|
@@ -45856,19 +46174,19 @@ OUTPUT: Call task_complete with JSON:
|
|
|
45856
46174
|
}
|
|
45857
46175
|
saveState() {
|
|
45858
46176
|
try {
|
|
45859
|
-
writeFileSync17(
|
|
46177
|
+
writeFileSync17(join51(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
|
|
45860
46178
|
} catch {
|
|
45861
46179
|
}
|
|
45862
46180
|
}
|
|
45863
46181
|
saveCycleResult(result) {
|
|
45864
46182
|
try {
|
|
45865
46183
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
45866
|
-
writeFileSync17(
|
|
46184
|
+
writeFileSync17(join51(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
|
|
45867
46185
|
const files = readdirSync13(this.historyDir).filter((f) => f.startsWith("cycle-") && f.endsWith(".json")).sort();
|
|
45868
46186
|
if (files.length > 50) {
|
|
45869
46187
|
for (const old of files.slice(0, files.length - 50)) {
|
|
45870
46188
|
try {
|
|
45871
|
-
unlinkSync9(
|
|
46189
|
+
unlinkSync9(join51(this.historyDir, old));
|
|
45872
46190
|
} catch {
|
|
45873
46191
|
}
|
|
45874
46192
|
}
|
|
@@ -45882,7 +46200,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
45882
46200
|
|
|
45883
46201
|
// packages/cli/dist/tui/snr-engine.js
|
|
45884
46202
|
import { existsSync as existsSync41, readdirSync as readdirSync14, readFileSync as readFileSync30 } from "node:fs";
|
|
45885
|
-
import { join as
|
|
46203
|
+
import { join as join52, basename as basename14 } from "node:path";
|
|
45886
46204
|
function computeDPrime(signalScores, noiseScores) {
|
|
45887
46205
|
if (signalScores.length === 0 || noiseScores.length === 0)
|
|
45888
46206
|
return 0;
|
|
@@ -46122,8 +46440,8 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
46122
46440
|
loadMemoryEntries(topics) {
|
|
46123
46441
|
const entries = [];
|
|
46124
46442
|
const dirs = [
|
|
46125
|
-
|
|
46126
|
-
|
|
46443
|
+
join52(this.repoRoot, ".oa", "memory"),
|
|
46444
|
+
join52(this.repoRoot, ".open-agents", "memory")
|
|
46127
46445
|
];
|
|
46128
46446
|
for (const dir of dirs) {
|
|
46129
46447
|
if (!existsSync41(dir))
|
|
@@ -46135,7 +46453,7 @@ Call task_complete with the JSON array when done.`, onEvent)
|
|
|
46135
46453
|
if (topics.length > 0 && !topics.includes(topic))
|
|
46136
46454
|
continue;
|
|
46137
46455
|
try {
|
|
46138
|
-
const data = JSON.parse(readFileSync30(
|
|
46456
|
+
const data = JSON.parse(readFileSync30(join52(dir, f), "utf-8"));
|
|
46139
46457
|
for (const [key, val] of Object.entries(data)) {
|
|
46140
46458
|
const value = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
46141
46459
|
entries.push({ topic, key, value });
|
|
@@ -46703,7 +47021,7 @@ var init_tool_policy = __esm({
|
|
|
46703
47021
|
|
|
46704
47022
|
// packages/cli/dist/tui/telegram-bridge.js
|
|
46705
47023
|
import { mkdirSync as mkdirSync18, existsSync as existsSync42, unlinkSync as unlinkSync10, readdirSync as readdirSync15, statSync as statSync13 } from "node:fs";
|
|
46706
|
-
import { join as
|
|
47024
|
+
import { join as join53, resolve as resolve28 } from "node:path";
|
|
46707
47025
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
46708
47026
|
function convertMarkdownToTelegramHTML(md) {
|
|
46709
47027
|
let html = md;
|
|
@@ -47468,7 +47786,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
|
|
|
47468
47786
|
return null;
|
|
47469
47787
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
47470
47788
|
const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension}`;
|
|
47471
|
-
const localPath =
|
|
47789
|
+
const localPath = join53(this.mediaCacheDir, fileName);
|
|
47472
47790
|
await writeFileAsync(localPath, buffer);
|
|
47473
47791
|
return localPath;
|
|
47474
47792
|
} catch {
|
|
@@ -48119,7 +48437,7 @@ var init_braille_spinner = __esm({
|
|
|
48119
48437
|
// packages/cli/dist/tui/system-metrics.js
|
|
48120
48438
|
import { loadavg as loadavg3, cpus as cpus3, totalmem as totalmem4, freemem as freemem3, platform as platform4 } from "node:os";
|
|
48121
48439
|
import { exec as exec3 } from "node:child_process";
|
|
48122
|
-
import { readFile as
|
|
48440
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
48123
48441
|
function formatRate(bytesPerSec) {
|
|
48124
48442
|
if (bytesPerSec < 1024)
|
|
48125
48443
|
return `${Math.round(bytesPerSec)}B`;
|
|
@@ -48131,7 +48449,7 @@ function formatRate(bytesPerSec) {
|
|
|
48131
48449
|
}
|
|
48132
48450
|
async function readProcNetDev() {
|
|
48133
48451
|
try {
|
|
48134
|
-
const data = await
|
|
48452
|
+
const data = await readFile17("/proc/net/dev", "utf8");
|
|
48135
48453
|
let rxTotal = 0;
|
|
48136
48454
|
let txTotal = 0;
|
|
48137
48455
|
for (const line of data.split("\n")) {
|
|
@@ -49906,7 +50224,7 @@ var init_status_bar = __esm({
|
|
|
49906
50224
|
import * as readline2 from "node:readline";
|
|
49907
50225
|
import { Writable } from "node:stream";
|
|
49908
50226
|
import { cwd } from "node:process";
|
|
49909
|
-
import { resolve as resolve29, join as
|
|
50227
|
+
import { resolve as resolve29, join as join54, dirname as dirname18, extname as extname10 } from "node:path";
|
|
49910
50228
|
import { createRequire as createRequire2 } from "node:module";
|
|
49911
50229
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
49912
50230
|
import { readFileSync as readFileSync32, writeFileSync as writeFileSync18, appendFileSync as appendFileSync4, rmSync as rmSync2, readdirSync as readdirSync16, mkdirSync as mkdirSync19 } from "node:fs";
|
|
@@ -49930,9 +50248,9 @@ function getVersion3() {
|
|
|
49930
50248
|
const require2 = createRequire2(import.meta.url);
|
|
49931
50249
|
const thisDir = dirname18(fileURLToPath12(import.meta.url));
|
|
49932
50250
|
const candidates = [
|
|
49933
|
-
|
|
49934
|
-
|
|
49935
|
-
|
|
50251
|
+
join54(thisDir, "..", "package.json"),
|
|
50252
|
+
join54(thisDir, "..", "..", "package.json"),
|
|
50253
|
+
join54(thisDir, "..", "..", "..", "package.json")
|
|
49936
50254
|
];
|
|
49937
50255
|
for (const pkgPath of candidates) {
|
|
49938
50256
|
if (existsSync43(pkgPath)) {
|
|
@@ -50025,6 +50343,8 @@ function buildTools(repoRoot, config, contextWindowSize) {
|
|
|
50025
50343
|
new CodeSandboxTool(repoRoot),
|
|
50026
50344
|
// Persistent Python REPL — RLM (arxiv:2512.24601)
|
|
50027
50345
|
new ReplTool(repoRoot),
|
|
50346
|
+
// Memory Metabolism — COHERE Layer 5 (arxiv:2512.13564)
|
|
50347
|
+
new MemoryMetabolismTool(repoRoot),
|
|
50028
50348
|
// Structured file reading (CSV, JSON, Markdown, binary detection)
|
|
50029
50349
|
new StructuredReadTool(repoRoot),
|
|
50030
50350
|
// Vision tools (Moondream — desktop awareness + point-and-click)
|
|
@@ -50144,15 +50464,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
|
|
|
50144
50464
|
function gatherMemorySnippets(root) {
|
|
50145
50465
|
const snippets = [];
|
|
50146
50466
|
const dirs = [
|
|
50147
|
-
|
|
50148
|
-
|
|
50467
|
+
join54(root, ".oa", "memory"),
|
|
50468
|
+
join54(root, ".open-agents", "memory")
|
|
50149
50469
|
];
|
|
50150
50470
|
for (const dir of dirs) {
|
|
50151
50471
|
if (!existsSync43(dir))
|
|
50152
50472
|
continue;
|
|
50153
50473
|
try {
|
|
50154
50474
|
for (const f of readdirSync16(dir).filter((f2) => f2.endsWith(".json"))) {
|
|
50155
|
-
const data = JSON.parse(readFileSync32(
|
|
50475
|
+
const data = JSON.parse(readFileSync32(join54(dir, f), "utf-8"));
|
|
50156
50476
|
for (const val of Object.values(data)) {
|
|
50157
50477
|
const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
50158
50478
|
if (v.length > 10)
|
|
@@ -51174,7 +51494,7 @@ async function startInteractive(config, repoPath) {
|
|
|
51174
51494
|
let p2pGateway = null;
|
|
51175
51495
|
let peerMesh = null;
|
|
51176
51496
|
let inferenceRouter = null;
|
|
51177
|
-
const secretVault = new SecretVault(
|
|
51497
|
+
const secretVault = new SecretVault(join54(repoRoot, ".oa", "vault.enc"));
|
|
51178
51498
|
let adminSessionKey = null;
|
|
51179
51499
|
const callSubAgents = /* @__PURE__ */ new Map();
|
|
51180
51500
|
const streamRenderer = new StreamRenderer();
|
|
@@ -51383,8 +51703,8 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
51383
51703
|
const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
|
|
51384
51704
|
return [hits, line];
|
|
51385
51705
|
}
|
|
51386
|
-
const HISTORY_DIR =
|
|
51387
|
-
const HISTORY_FILE =
|
|
51706
|
+
const HISTORY_DIR = join54(homedir13(), ".open-agents");
|
|
51707
|
+
const HISTORY_FILE = join54(HISTORY_DIR, "repl-history");
|
|
51388
51708
|
const MAX_HISTORY_LINES = 500;
|
|
51389
51709
|
let savedHistory = [];
|
|
51390
51710
|
try {
|
|
@@ -51594,7 +51914,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
51594
51914
|
} catch {
|
|
51595
51915
|
}
|
|
51596
51916
|
try {
|
|
51597
|
-
const oaDir =
|
|
51917
|
+
const oaDir = join54(repoRoot, ".oa");
|
|
51598
51918
|
const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
|
|
51599
51919
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
51600
51920
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -51617,7 +51937,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
51617
51937
|
} catch {
|
|
51618
51938
|
}
|
|
51619
51939
|
try {
|
|
51620
|
-
const oaDir =
|
|
51940
|
+
const oaDir = join54(repoRoot, ".oa");
|
|
51621
51941
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
|
|
51622
51942
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
51623
51943
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -52436,7 +52756,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
52436
52756
|
kind,
|
|
52437
52757
|
targetUrl,
|
|
52438
52758
|
authKey,
|
|
52439
|
-
stateDir:
|
|
52759
|
+
stateDir: join54(repoRoot, ".oa"),
|
|
52440
52760
|
passthrough: passthrough ?? false,
|
|
52441
52761
|
loadbalance: loadbalance ?? false,
|
|
52442
52762
|
endpointAuth: passthrough ? currentConfig.apiKey : void 0,
|
|
@@ -52484,7 +52804,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
52484
52804
|
await tunnelGateway.stop();
|
|
52485
52805
|
tunnelGateway = null;
|
|
52486
52806
|
}
|
|
52487
|
-
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir:
|
|
52807
|
+
const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join54(repoRoot, ".oa") });
|
|
52488
52808
|
newTunnel.on("stats", (stats) => {
|
|
52489
52809
|
statusBar.setExposeStatus({
|
|
52490
52810
|
status: stats.status,
|
|
@@ -52746,7 +53066,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
52746
53066
|
}
|
|
52747
53067
|
},
|
|
52748
53068
|
destroyProject() {
|
|
52749
|
-
const oaPath =
|
|
53069
|
+
const oaPath = join54(repoRoot, OA_DIR);
|
|
52750
53070
|
if (existsSync43(oaPath)) {
|
|
52751
53071
|
try {
|
|
52752
53072
|
rmSync2(oaPath, { recursive: true, force: true });
|
|
@@ -53679,9 +53999,9 @@ var init_run = __esm({
|
|
|
53679
53999
|
// packages/indexer/dist/codebase-indexer.js
|
|
53680
54000
|
import { glob } from "glob";
|
|
53681
54001
|
import ignore from "ignore";
|
|
53682
|
-
import { readFile as
|
|
54002
|
+
import { readFile as readFile18, stat as stat4 } from "node:fs/promises";
|
|
53683
54003
|
import { createHash as createHash4 } from "node:crypto";
|
|
53684
|
-
import { join as
|
|
54004
|
+
import { join as join55, relative as relative3, extname as extname11, basename as basename15 } from "node:path";
|
|
53685
54005
|
var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
|
|
53686
54006
|
var init_codebase_indexer = __esm({
|
|
53687
54007
|
"packages/indexer/dist/codebase-indexer.js"() {
|
|
@@ -53725,7 +54045,7 @@ var init_codebase_indexer = __esm({
|
|
|
53725
54045
|
const ig = ignore.default();
|
|
53726
54046
|
if (this.config.respectGitignore) {
|
|
53727
54047
|
try {
|
|
53728
|
-
const gitignoreContent = await
|
|
54048
|
+
const gitignoreContent = await readFile18(join55(this.config.rootDir, ".gitignore"), "utf-8");
|
|
53729
54049
|
ig.add(gitignoreContent);
|
|
53730
54050
|
} catch {
|
|
53731
54051
|
}
|
|
@@ -53740,12 +54060,12 @@ var init_codebase_indexer = __esm({
|
|
|
53740
54060
|
for (const relativePath of files) {
|
|
53741
54061
|
if (ig.ignores(relativePath))
|
|
53742
54062
|
continue;
|
|
53743
|
-
const fullPath =
|
|
54063
|
+
const fullPath = join55(this.config.rootDir, relativePath);
|
|
53744
54064
|
try {
|
|
53745
54065
|
const fileStat = await stat4(fullPath);
|
|
53746
54066
|
if (fileStat.size > this.config.maxFileSize)
|
|
53747
54067
|
continue;
|
|
53748
|
-
const content = await
|
|
54068
|
+
const content = await readFile18(fullPath);
|
|
53749
54069
|
const hash = createHash4("sha256").update(content).digest("hex");
|
|
53750
54070
|
const ext = extname11(relativePath);
|
|
53751
54071
|
indexed.push({
|
|
@@ -53786,7 +54106,7 @@ var init_codebase_indexer = __esm({
|
|
|
53786
54106
|
if (!child) {
|
|
53787
54107
|
child = {
|
|
53788
54108
|
name: part,
|
|
53789
|
-
path:
|
|
54109
|
+
path: join55(current.path, part),
|
|
53790
54110
|
type: "directory",
|
|
53791
54111
|
children: []
|
|
53792
54112
|
};
|
|
@@ -54127,7 +54447,7 @@ var config_exports = {};
|
|
|
54127
54447
|
__export(config_exports, {
|
|
54128
54448
|
configCommand: () => configCommand
|
|
54129
54449
|
});
|
|
54130
|
-
import { join as
|
|
54450
|
+
import { join as join56, resolve as resolve31 } from "node:path";
|
|
54131
54451
|
import { homedir as homedir14 } from "node:os";
|
|
54132
54452
|
import { cwd as cwd3 } from "node:process";
|
|
54133
54453
|
function redactIfSensitive(key, value) {
|
|
@@ -54210,7 +54530,7 @@ function handleShow(opts, config) {
|
|
|
54210
54530
|
}
|
|
54211
54531
|
}
|
|
54212
54532
|
printSection("Config File");
|
|
54213
|
-
printInfo(`~/.open-agents/config.json (${
|
|
54533
|
+
printInfo(`~/.open-agents/config.json (${join56(homedir14(), ".open-agents", "config.json")})`);
|
|
54214
54534
|
printSection("Priority Chain");
|
|
54215
54535
|
printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
|
|
54216
54536
|
printInfo(" 2. Project .oa/settings.json (--local)");
|
|
@@ -54249,7 +54569,7 @@ function handleSet(opts, _config) {
|
|
|
54249
54569
|
const coerced = coerceForSettings(key, value);
|
|
54250
54570
|
saveProjectSettings(repoRoot, { [key]: coerced });
|
|
54251
54571
|
printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value)}`);
|
|
54252
|
-
printInfo(`Saved to ${
|
|
54572
|
+
printInfo(`Saved to ${join56(repoRoot, ".oa", "settings.json")}`);
|
|
54253
54573
|
printInfo("This override applies only when running in this workspace.");
|
|
54254
54574
|
} catch (err) {
|
|
54255
54575
|
printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -54508,7 +54828,7 @@ __export(eval_exports, {
|
|
|
54508
54828
|
});
|
|
54509
54829
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
54510
54830
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync19 } from "node:fs";
|
|
54511
|
-
import { join as
|
|
54831
|
+
import { join as join57 } from "node:path";
|
|
54512
54832
|
async function evalCommand(opts, config) {
|
|
54513
54833
|
const suiteName = opts.suite ?? "basic";
|
|
54514
54834
|
const suite = SUITES[suiteName];
|
|
@@ -54633,9 +54953,9 @@ async function evalCommand(opts, config) {
|
|
|
54633
54953
|
process.exit(failed > 0 ? 1 : 0);
|
|
54634
54954
|
}
|
|
54635
54955
|
function createTempEvalRepo() {
|
|
54636
|
-
const dir =
|
|
54956
|
+
const dir = join57(tmpdir10(), `open-agents-eval-${Date.now()}`);
|
|
54637
54957
|
mkdirSync20(dir, { recursive: true });
|
|
54638
|
-
writeFileSync19(
|
|
54958
|
+
writeFileSync19(join57(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
|
|
54639
54959
|
return dir;
|
|
54640
54960
|
}
|
|
54641
54961
|
var BASIC_SUITE, FULL_SUITE, SUITES;
|
|
@@ -54695,7 +55015,7 @@ init_updater();
|
|
|
54695
55015
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
54696
55016
|
import { createRequire as createRequire3 } from "node:module";
|
|
54697
55017
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
54698
|
-
import { dirname as dirname19, join as
|
|
55018
|
+
import { dirname as dirname19, join as join58 } from "node:path";
|
|
54699
55019
|
|
|
54700
55020
|
// packages/cli/dist/cli.js
|
|
54701
55021
|
import { createInterface } from "node:readline";
|
|
@@ -54802,7 +55122,7 @@ init_output();
|
|
|
54802
55122
|
function getVersion4() {
|
|
54803
55123
|
try {
|
|
54804
55124
|
const require2 = createRequire3(import.meta.url);
|
|
54805
|
-
const pkgPath =
|
|
55125
|
+
const pkgPath = join58(dirname19(fileURLToPath13(import.meta.url)), "..", "package.json");
|
|
54806
55126
|
const pkg = require2(pkgPath);
|
|
54807
55127
|
return pkg.version;
|
|
54808
55128
|
} catch {
|