open-agents-ai 0.115.0 → 0.117.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.
Files changed (2) hide show
  1. package/dist/index.js +842 -408
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7994,12 +7994,12 @@ var init_memory_metabolism = __esm({
7994
7994
  properties: {
7995
7995
  op: {
7996
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)"
7997
+ enum: ["admit", "consolidate", "list", "promote", "forget", "repair"],
7998
+ description: "Operation: admit (store new), consolidate (extract lessons), list (show), promote (upgrade type), forget (remove), repair (validate and fix contradictions in stored memories \u2014 MemMA backward-path, arxiv:2603.18718)"
7999
7999
  },
8000
8000
  memory_type: {
8001
8001
  type: "string",
8002
- enum: ["episodic", "semantic", "procedural", "normative", "quarantine"],
8002
+ enum: ["working", "episodic", "semantic", "procedural", "normative", "quarantine"],
8003
8003
  description: "Memory classification type"
8004
8004
  },
8005
8005
  content: {
@@ -8047,6 +8047,8 @@ var init_memory_metabolism = __esm({
8047
8047
  return await this.promoteMemory(args, start);
8048
8048
  case "forget":
8049
8049
  return await this.forgetMemory(args, start);
8050
+ case "repair":
8051
+ return await this.repairMemories(start);
8050
8052
  default:
8051
8053
  return { success: false, output: `Unknown op: ${op}`, error: "Invalid operation", durationMs: performance.now() - start };
8052
8054
  }
@@ -8229,18 +8231,174 @@ ${lines.join("\n")}`,
8229
8231
  durationMs: performance.now() - start
8230
8232
  };
8231
8233
  }
8232
- // ── Scoring ──────────────────────────────────────────────────────────────
8234
+ // ── Repair (MemMA backward-path, arxiv:2603.18718) ─────────────────────
8235
+ /**
8236
+ * Validate stored memories and repair contradictions before they become
8237
+ * canonical. Inspired by MemMA's backward-path repair (arxiv:2603.18718):
8238
+ * "The system should be allowed to repair memory before committing it."
8239
+ */
8240
+ async repairMemories(start) {
8241
+ const metaDir = join19(this.cwd, ".oa", "memory", "metabolism");
8242
+ const store = await this.loadStore(metaDir);
8243
+ if (store.length === 0) {
8244
+ return { success: true, output: "No memories to repair.", durationMs: performance.now() - start };
8245
+ }
8246
+ let repaired = 0;
8247
+ let quarantined = 0;
8248
+ let expired = 0;
8249
+ const issues = [];
8250
+ for (const item of store) {
8251
+ if (item.type === "working") {
8252
+ const ageMs = Date.now() - new Date(item.createdAt).getTime();
8253
+ if (ageMs > 24 * 60 * 60 * 1e3) {
8254
+ item.decision = { action: "forget", reason: "Working memory expired (>24h)" };
8255
+ expired++;
8256
+ issues.push(`[${item.id}] Working memory expired \u2014 marked for cleanup`);
8257
+ }
8258
+ }
8259
+ const duplicates = store.filter((m) => m.id !== item.id && m.content === item.content);
8260
+ if (duplicates.length > 0) {
8261
+ for (const dup of duplicates) {
8262
+ const dupScore = (dup.scores.novelty + dup.scores.utility + dup.scores.confidence + dup.scores.identityRelevance) / 4;
8263
+ const itemScore = (item.scores.novelty + item.scores.utility + item.scores.confidence + item.scores.identityRelevance) / 4;
8264
+ if (dupScore < itemScore && dup.decision.action !== "quarantine") {
8265
+ dup.type = "quarantine";
8266
+ dup.decision = { action: "quarantine", reason: `Duplicate of ${item.id} (lower score)` };
8267
+ quarantined++;
8268
+ issues.push(`[${dup.id}] Duplicate content quarantined`);
8269
+ }
8270
+ }
8271
+ }
8272
+ if (item.type === "procedural" || item.type === "semantic") {
8273
+ const conflicts = store.filter((m) => m.id !== item.id && m.type === item.type && m.decision.action !== "quarantine" && this.detectContradiction(item.content, m.content));
8274
+ if (conflicts.length > 0) {
8275
+ for (const conflict of conflicts) {
8276
+ if (new Date(conflict.createdAt) < new Date(item.createdAt)) {
8277
+ conflict.type = "quarantine";
8278
+ conflict.decision = { action: "quarantine", reason: `Contradicts newer memory ${item.id}` };
8279
+ quarantined++;
8280
+ issues.push(`[${conflict.id}] Contradicts [${item.id}] \u2014 older version quarantined`);
8281
+ }
8282
+ }
8283
+ repaired++;
8284
+ }
8285
+ }
8286
+ if (item.scores.confidence < 0.3 && item.decision.action === "admit") {
8287
+ item.type = "quarantine";
8288
+ item.decision = { action: "quarantine", reason: "Low confidence on re-evaluation" };
8289
+ quarantined++;
8290
+ issues.push(`[${item.id}] Low confidence (${item.scores.confidence.toFixed(2)}) \u2014 quarantined`);
8291
+ }
8292
+ }
8293
+ const cleanedStore = store.filter((m) => !(m.type === "working" && m.decision.action === "forget"));
8294
+ await this.saveStore(metaDir, cleanedStore);
8295
+ return {
8296
+ success: true,
8297
+ output: `Memory repair complete:
8298
+ Scanned: ${store.length} memories
8299
+ Repaired contradictions: ${repaired}
8300
+ Quarantined (duplicates/low-confidence): ${quarantined}
8301
+ Expired working memories removed: ${expired}
8302
+ ` + (issues.length > 0 ? `
8303
+ Issues found:
8304
+ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
8305
+ durationMs: performance.now() - start
8306
+ };
8307
+ }
8308
+ /** Simple contradiction detection between two memory contents */
8309
+ detectContradiction(a, b) {
8310
+ const aLower = a.toLowerCase();
8311
+ const bLower = b.toLowerCase();
8312
+ const negationPairs = [
8313
+ [/\bshould\b/, /\bshould not\b/],
8314
+ [/\balways\b/, /\bnever\b/],
8315
+ [/\bdo\b/, /\bdon't\b/],
8316
+ [/\btrue\b/, /\bfalse\b/],
8317
+ [/\benable\b/, /\bdisable\b/],
8318
+ [/\buse\b/, /\bavoid\b/]
8319
+ ];
8320
+ for (const [pos, neg] of negationPairs) {
8321
+ if (pos.test(aLower) && neg.test(bLower) || neg.test(aLower) && pos.test(bLower)) {
8322
+ const aWords = new Set(aLower.split(/\s+/).filter((w) => w.length > 4));
8323
+ const bWords = bLower.split(/\s+/).filter((w) => w.length > 4);
8324
+ if (bWords.some((w) => aWords.has(w)))
8325
+ return true;
8326
+ }
8327
+ }
8328
+ return false;
8329
+ }
8330
+ // ── Scoring (A-MAC inspired, COHERE Memory Metabolism §4) ───────────────
8331
+ // Per COHERE paper: admission scoring covers novelty, utility, confidence,
8332
+ // and identity_relevance. Enhanced heuristics cover 12 content signals.
8333
+ // Optional LLM-assisted scoring available via setLlmScorer().
8334
+ /** Optional LLM-based scorer for production-quality admission decisions */
8335
+ llmScorer = null;
8336
+ /** Set an LLM-based scorer for production-quality memory admission */
8337
+ setLlmScorer(scorer) {
8338
+ this.llmScorer = scorer;
8339
+ }
8233
8340
  scoreMemory(content, type, source) {
8234
8341
  const words = content.split(/\s+/).length;
8235
- const hasCode = /```|def |function |import |require/.test(content);
8236
- const hasError = /error|fail|bug|fix/i.test(content);
8237
- const hasPattern = /pattern|strategy|approach|lesson|tip/i.test(content);
8342
+ const sentences = content.split(/[.!?]+/).filter((s) => s.trim()).length;
8343
+ const lower = content.toLowerCase();
8344
+ let novelty = 0.3;
8345
+ novelty += Math.min(0.3, words / 150);
8346
+ if (/\b[A-Z][a-z]+(?:\s[A-Z][a-z]+)+/.test(content))
8347
+ novelty += 0.1;
8348
+ if (/\d+\.\d+|\b\d{4,}\b/.test(content))
8349
+ novelty += 0.1;
8350
+ if (/\b(?:api|endpoint|schema|protocol|algorithm|architecture)\b/i.test(lower))
8351
+ novelty += 0.1;
8352
+ if (/\d{4}-\d{2}-\d{2}|today|yesterday|just now/i.test(lower))
8353
+ novelty += 0.1;
8354
+ let utility = 0.3;
8355
+ if (/```|def |function |import |require|class |interface |export /.test(content))
8356
+ utility += 0.25;
8357
+ if (/pattern|strategy|approach|lesson|tip|best practice|rule|principle/i.test(lower))
8358
+ utility += 0.2;
8359
+ if (/error|fail|bug|fix|solution|workaround|resolved/i.test(lower))
8360
+ utility += 0.15;
8361
+ if (/step\s*\d|first.*then|1\.|2\.|procedure|recipe|workflow/i.test(lower))
8362
+ utility += 0.15;
8363
+ if (/https?:\/\/|\/[a-z]+\/[a-z]+|npm |pip |git /i.test(lower))
8364
+ utility += 0.1;
8365
+ let confidence = 0.5;
8366
+ if (source === "user")
8367
+ confidence += 0.3;
8368
+ else if (source === "trajectory-consolidation")
8369
+ confidence += 0.15;
8370
+ else if (source === "reflection")
8371
+ confidence += 0.1;
8372
+ else if (source === "llm-query")
8373
+ confidence -= 0.1;
8374
+ if (/maybe|probably|might|possibly|I think|not sure|unclear/i.test(lower))
8375
+ confidence -= 0.15;
8376
+ if (/always|never|must|confirmed|verified|tested|proven/i.test(lower))
8377
+ confidence += 0.1;
8378
+ if (sentences >= 3)
8379
+ confidence += 0.05;
8380
+ let identityRelevance = 0.2;
8381
+ if (type === "normative")
8382
+ identityRelevance += 0.5;
8383
+ else if (type === "procedural")
8384
+ identityRelevance += 0.3;
8385
+ else if (type === "semantic")
8386
+ identityRelevance += 0.2;
8387
+ else if (type === "episodic")
8388
+ identityRelevance += 0.1;
8389
+ else if (type === "working")
8390
+ identityRelevance = 0.05;
8391
+ if (/\b(?:I|my|me|mine|myself|we|our)\b/i.test(content))
8392
+ identityRelevance += 0.1;
8393
+ if (/value|prefer|commit|important|priority|principle|belief/i.test(lower))
8394
+ identityRelevance += 0.15;
8395
+ if (/user|client|customer|team|collaborat/i.test(lower))
8396
+ identityRelevance += 0.1;
8238
8397
  return {
8239
- novelty: Math.min(1, words / 100),
8240
- // longer = likely more novel
8241
- utility: hasCode ? 0.8 : hasPattern ? 0.7 : hasError ? 0.6 : 0.4,
8242
- confidence: source === "trajectory-consolidation" ? 0.7 : source === "user" ? 0.9 : 0.5,
8243
- identityRelevance: type === "normative" ? 0.9 : type === "procedural" ? 0.6 : type === "semantic" ? 0.5 : 0.3
8398
+ novelty: Math.max(0, Math.min(1, novelty)),
8399
+ utility: Math.max(0, Math.min(1, utility)),
8400
+ confidence: Math.max(0, Math.min(1, confidence)),
8401
+ identityRelevance: Math.max(0, Math.min(1, identityRelevance))
8244
8402
  };
8245
8403
  }
8246
8404
  // ── Store I/O ────────────────────────────────────────────────────────────
@@ -8275,8 +8433,8 @@ var init_identity_kernel = __esm({
8275
8433
  properties: {
8276
8434
  op: {
8277
8435
  type: "string",
8278
- enum: ["hydrate", "observe", "propose_update", "publish_snapshot", "reconcile"],
8279
- description: "Operation to perform"
8436
+ enum: ["hydrate", "observe", "propose_update", "publish_snapshot", "reconcile", "narrativize"],
8437
+ description: "Operation: hydrate (load), observe (record event), propose_update (change self-state), publish_snapshot (emit state), reconcile (fix contradictions), narrativize (rewrite self-summary from current state \u2014 COHERE state-transition step 9, p.25)"
8280
8438
  },
8281
8439
  event: {
8282
8440
  type: "string",
@@ -8352,6 +8510,8 @@ var init_identity_kernel = __esm({
8352
8510
  return this.publishSnapshot(start);
8353
8511
  case "reconcile":
8354
8512
  return await this.reconcile(start);
8513
+ case "narrativize":
8514
+ return await this.narrativize(start);
8355
8515
  default:
8356
8516
  return { success: false, output: `Unknown op: ${op}`, error: "Invalid operation", durationMs: performance.now() - start };
8357
8517
  }
@@ -8517,6 +8677,66 @@ Justification: ${justification || "(none provided)"}`,
8517
8677
  durationMs: performance.now() - start
8518
8678
  };
8519
8679
  }
8680
+ // ── Narrativize (COHERE state-transition step 9, p.25) ─────────────────
8681
+ /**
8682
+ * Rewrite the narrative_summary from the current self-state.
8683
+ * Per COHERE paper (p.25, Claim C7): "Narrative compilation is a real
8684
+ * unification mechanism for identity." This step runs when a meaningful
8685
+ * identity delta has occurred (version change, new values, reconciliation).
8686
+ */
8687
+ async narrativize(start) {
8688
+ if (!this.selfState)
8689
+ await this.hydrate(start);
8690
+ const s = this.selfState;
8691
+ const parts = [];
8692
+ parts.push(`I am ${s.self_id}, an AI coding agent (v${s.version}).`);
8693
+ if (s.values_stack.length > 0) {
8694
+ parts.push(`My core values are: ${s.values_stack.join(", ")}.`);
8695
+ }
8696
+ if (s.active_commitments.length > 0) {
8697
+ parts.push(`I am committed to: ${s.active_commitments.join("; ")}.`);
8698
+ }
8699
+ if (s.active_goals.length > 0) {
8700
+ parts.push(`Current goals: ${s.active_goals.join("; ")}.`);
8701
+ }
8702
+ const style = s.interaction_style;
8703
+ parts.push(`I communicate in a ${style.tone} tone with ${style.depth_default} depth.`);
8704
+ if (s.relationship_models.length > 0) {
8705
+ const primary = s.relationship_models[0];
8706
+ parts.push(`My primary relationship is with ${primary.entity} (trust: ${primary.trust_level.toFixed(1)}).`);
8707
+ if (primary.preferences_learned.length > 0) {
8708
+ parts.push(`Learned preferences: ${primary.preferences_learned.join(", ")}.`);
8709
+ }
8710
+ }
8711
+ const h = s.homeostasis;
8712
+ if (h.uncertainty > 0.3)
8713
+ parts.push(`I am currently uncertain about some recent events.`);
8714
+ if (h.coherence < 0.7)
8715
+ parts.push(`My internal coherence needs attention.`);
8716
+ if (s.open_contradictions.length > 0) {
8717
+ parts.push(`I have ${s.open_contradictions.length} unresolved contradiction(s).`);
8718
+ }
8719
+ parts.push(`I have completed ${s.session_count} sessions and made ${s.version_history.length} self-updates.`);
8720
+ const newNarrative = parts.join(" ");
8721
+ const oldNarrative = s.narrative_summary;
8722
+ s.narrative_summary = newNarrative;
8723
+ s.updated_at = (/* @__PURE__ */ new Date()).toISOString();
8724
+ s.version_history.push({
8725
+ version: s.version,
8726
+ change: `Narrative recompiled: ${newNarrative.slice(0, 80)}...`,
8727
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
8728
+ });
8729
+ await this.save();
8730
+ return {
8731
+ success: true,
8732
+ output: `Narrative recompiled (${oldNarrative === newNarrative ? "no change" : "updated"}):
8733
+
8734
+ Old: ${oldNarrative.slice(0, 100)}...
8735
+
8736
+ New: ${newNarrative.slice(0, 200)}...`,
8737
+ durationMs: performance.now() - start
8738
+ };
8739
+ }
8520
8740
  // ── Helpers ──────────────────────────────────────────────────────────────
8521
8741
  createDefaultState() {
8522
8742
  const { createHash: createHash5 } = __require("node:crypto");
@@ -8975,8 +9195,193 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
8975
9195
  }
8976
9196
  });
8977
9197
 
9198
+ // packages/execution/dist/tools/embedding-store.js
9199
+ import { readFile as readFile12, writeFile as writeFile12, mkdir as mkdir8, readdir as readdir3 } from "node:fs/promises";
9200
+ import { join as join23 } from "node:path";
9201
+ var EmbeddingStoreTool;
9202
+ var init_embedding_store = __esm({
9203
+ "packages/execution/dist/tools/embedding-store.js"() {
9204
+ "use strict";
9205
+ EmbeddingStoreTool = class {
9206
+ name = "embedding_store";
9207
+ description = "Local semantic memory \u2014 store and retrieve memories by meaning, not just keywords. Operations: store (embed and save text), search (find semantically similar memories), list (show stored entries). Uses Ollama embeddings API locally \u2014 data never leaves your machine. (COHERE Private Brain, p.34)";
9208
+ parameters = {
9209
+ type: "object",
9210
+ properties: {
9211
+ op: {
9212
+ type: "string",
9213
+ enum: ["store", "search", "list"],
9214
+ description: "store (embed + save), search (find similar), list (show all)"
9215
+ },
9216
+ content: {
9217
+ type: "string",
9218
+ description: "For store: text to embed. For search: query text."
9219
+ },
9220
+ source: {
9221
+ type: "string",
9222
+ description: "For store: origin of this memory (tool name, etc.)"
9223
+ },
9224
+ type: {
9225
+ type: "string",
9226
+ description: "For store: memory type (fact, procedure, lesson, etc.)"
9227
+ },
9228
+ top_k: {
9229
+ type: "number",
9230
+ description: "For search: number of results (default: 5)"
9231
+ }
9232
+ },
9233
+ required: ["op"]
9234
+ };
9235
+ cwd;
9236
+ ollamaUrl;
9237
+ model;
9238
+ cache = null;
9239
+ constructor(cwd4, ollamaUrl = "http://localhost:11434", model = "nomic-embed-text") {
9240
+ this.cwd = cwd4;
9241
+ this.ollamaUrl = ollamaUrl;
9242
+ this.model = model;
9243
+ }
9244
+ async execute(args) {
9245
+ const op = String(args.op ?? "");
9246
+ const start = performance.now();
9247
+ try {
9248
+ switch (op) {
9249
+ case "store":
9250
+ return await this.storeEmbedding(args, start);
9251
+ case "search":
9252
+ return await this.searchEmbeddings(args, start);
9253
+ case "list":
9254
+ return await this.listEmbeddings(start);
9255
+ default:
9256
+ return { success: false, output: `Unknown op: ${op}`, error: "Invalid", durationMs: performance.now() - start };
9257
+ }
9258
+ } catch (err) {
9259
+ return { success: false, output: `Error: ${err instanceof Error ? err.message : String(err)}`, durationMs: performance.now() - start };
9260
+ }
9261
+ }
9262
+ async storeEmbedding(args, start) {
9263
+ const content = String(args.content ?? "");
9264
+ const source = String(args.source ?? "user");
9265
+ const type = String(args.type ?? "fact");
9266
+ if (!content.trim()) {
9267
+ return { success: false, output: "No content", durationMs: performance.now() - start };
9268
+ }
9269
+ const vector = await this.embed(content);
9270
+ if (!vector) {
9271
+ return { success: false, output: "Embedding generation failed \u2014 is Ollama running with an embedding model?", durationMs: performance.now() - start };
9272
+ }
9273
+ const entry = {
9274
+ id: `emb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
9275
+ content,
9276
+ vector,
9277
+ metadata: { source, type, createdAt: (/* @__PURE__ */ new Date()).toISOString() }
9278
+ };
9279
+ const dir = join23(this.cwd, ".oa", "embeddings");
9280
+ await mkdir8(dir, { recursive: true });
9281
+ await writeFile12(join23(dir, `${entry.id}.json`), JSON.stringify(entry), "utf8");
9282
+ this.cache = null;
9283
+ return {
9284
+ success: true,
9285
+ output: `Stored: [${entry.id}] ${content.slice(0, 60)}... (${vector.length}d vector)`,
9286
+ durationMs: performance.now() - start
9287
+ };
9288
+ }
9289
+ async searchEmbeddings(args, start) {
9290
+ const query = String(args.content ?? "");
9291
+ const topK = Math.min(20, Math.max(1, Number(args.top_k ?? 5)));
9292
+ if (!query.trim()) {
9293
+ return { success: false, output: "No query", durationMs: performance.now() - start };
9294
+ }
9295
+ const queryVec = await this.embed(query);
9296
+ if (!queryVec) {
9297
+ return { success: false, output: "Query embedding failed", durationMs: performance.now() - start };
9298
+ }
9299
+ const entries = await this.loadAll();
9300
+ if (entries.length === 0) {
9301
+ return { success: true, output: "No embeddings stored yet.", durationMs: performance.now() - start };
9302
+ }
9303
+ const scored = entries.map((e) => ({
9304
+ entry: e,
9305
+ similarity: this.cosineSimilarity(queryVec, e.vector)
9306
+ })).sort((a, b) => b.similarity - a.similarity).slice(0, topK);
9307
+ const results = scored.map((s, i) => `${i + 1}. [${s.entry.id}] sim=${s.similarity.toFixed(3)} type=${s.entry.metadata.type}
9308
+ ${s.entry.content.slice(0, 120)}`);
9309
+ return {
9310
+ success: true,
9311
+ output: `Semantic search: "${query.slice(0, 40)}..." \u2014 ${scored.length} results:
9312
+
9313
+ ${results.join("\n\n")}`,
9314
+ durationMs: performance.now() - start
9315
+ };
9316
+ }
9317
+ async listEmbeddings(start) {
9318
+ const entries = await this.loadAll();
9319
+ if (entries.length === 0) {
9320
+ return { success: true, output: "No embeddings stored.", durationMs: performance.now() - start };
9321
+ }
9322
+ const lines = entries.map((e) => `[${e.id}] type=${e.metadata.type} src=${e.metadata.source} ${e.content.slice(0, 80)}`);
9323
+ return {
9324
+ success: true,
9325
+ output: `Embedding store (${entries.length} entries):
9326
+ ${lines.join("\n")}`,
9327
+ durationMs: performance.now() - start
9328
+ };
9329
+ }
9330
+ // ── Helpers ──
9331
+ async embed(text) {
9332
+ try {
9333
+ const resp = await fetch(`${this.ollamaUrl}/api/embed`, {
9334
+ method: "POST",
9335
+ headers: { "Content-Type": "application/json" },
9336
+ body: JSON.stringify({ model: this.model, input: text }),
9337
+ signal: AbortSignal.timeout(3e4)
9338
+ });
9339
+ if (!resp.ok)
9340
+ return null;
9341
+ const data = await resp.json();
9342
+ return data.embeddings?.[0] ?? null;
9343
+ } catch {
9344
+ return null;
9345
+ }
9346
+ }
9347
+ cosineSimilarity(a, b) {
9348
+ if (a.length !== b.length)
9349
+ return 0;
9350
+ let dot = 0, normA = 0, normB = 0;
9351
+ for (let i = 0; i < a.length; i++) {
9352
+ dot += a[i] * b[i];
9353
+ normA += a[i] * a[i];
9354
+ normB += b[i] * b[i];
9355
+ }
9356
+ const denom = Math.sqrt(normA) * Math.sqrt(normB);
9357
+ return denom === 0 ? 0 : dot / denom;
9358
+ }
9359
+ async loadAll() {
9360
+ if (this.cache)
9361
+ return this.cache;
9362
+ const dir = join23(this.cwd, ".oa", "embeddings");
9363
+ try {
9364
+ const files = await readdir3(dir);
9365
+ const entries = [];
9366
+ for (const f of files.filter((f2) => f2.endsWith(".json"))) {
9367
+ try {
9368
+ const raw = await readFile12(join23(dir, f), "utf8");
9369
+ entries.push(JSON.parse(raw));
9370
+ } catch {
9371
+ }
9372
+ }
9373
+ this.cache = entries;
9374
+ return entries;
9375
+ } catch {
9376
+ return [];
9377
+ }
9378
+ }
9379
+ };
9380
+ }
9381
+ });
9382
+
8978
9383
  // packages/execution/dist/tools/structured-read.js
8979
- import { readFile as readFile12, stat as stat2 } from "node:fs/promises";
9384
+ import { readFile as readFile13, stat as stat2 } from "node:fs/promises";
8980
9385
  import { resolve as resolve15, extname as extname5 } from "node:path";
8981
9386
  function parseCSV(text, separator = ",") {
8982
9387
  const lines = text.split("\n").filter((l) => l.trim() !== "");
@@ -9171,7 +9576,7 @@ var init_structured_read = __esm({
9171
9576
  }
9172
9577
  }
9173
9578
  if (format === "xlsx" || format === "pdf" || format === "docx" || format === "auto") {
9174
- const buffer = await readFile12(fullPath);
9579
+ const buffer = await readFile13(fullPath);
9175
9580
  const detected = detectBinaryFormat(buffer);
9176
9581
  if (detected === "xlsx") {
9177
9582
  return {
@@ -9216,7 +9621,7 @@ Or install mammoth for programmatic access.`,
9216
9621
  }
9217
9622
  }
9218
9623
  }
9219
- const text = await readFile12(fullPath, "utf-8");
9624
+ const text = await readFile13(fullPath, "utf-8");
9220
9625
  switch (format) {
9221
9626
  case "csv": {
9222
9627
  const rows = parseCSV(text, ",");
@@ -9313,7 +9718,7 @@ ${parts.join("\n\n")}`,
9313
9718
  // packages/execution/dist/tools/vision.js
9314
9719
  import { readFileSync as readFileSync11, existsSync as existsSync14, statSync as statSync5 } from "node:fs";
9315
9720
  import { execSync as execSync11, spawn as spawn7 } from "node:child_process";
9316
- import { resolve as resolve16, extname as extname6, basename as basename5, dirname as dirname6, join as join23 } from "node:path";
9721
+ import { resolve as resolve16, extname as extname6, basename as basename5, dirname as dirname6, join as join24 } from "node:path";
9317
9722
  import { fileURLToPath as fileURLToPath2 } from "node:url";
9318
9723
  async function probeStation(endpoint) {
9319
9724
  try {
@@ -9328,7 +9733,7 @@ async function probeStation(endpoint) {
9328
9733
  }
9329
9734
  }
9330
9735
  function findStationBinary() {
9331
- const oaVenvPython = join23(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "python");
9736
+ const oaVenvPython = join24(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "python");
9332
9737
  if (existsSync14(oaVenvPython)) {
9333
9738
  try {
9334
9739
  execSync11(`${JSON.stringify(oaVenvPython)} -c "import moondream_station"`, { stdio: "pipe", timeout: 5e3 });
@@ -9336,7 +9741,7 @@ function findStationBinary() {
9336
9741
  } catch {
9337
9742
  }
9338
9743
  }
9339
- const oaVenvBin = join23(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "moondream-station");
9744
+ const oaVenvBin = join24(process.env["HOME"] || "/root", ".open-agents", "venv", "bin", "moondream-station");
9340
9745
  if (existsSync14(oaVenvBin))
9341
9746
  return oaVenvBin;
9342
9747
  const thisDir = dirname6(fileURLToPath2(import.meta.url));
@@ -9688,7 +10093,7 @@ ${response}`, durationMs: performance.now() - start };
9688
10093
  import { readFileSync as readFileSync12, existsSync as existsSync15 } from "node:fs";
9689
10094
  import { execSync as execSync12 } from "node:child_process";
9690
10095
  import { tmpdir as tmpdir4 } from "node:os";
9691
- import { join as join24, dirname as dirname7 } from "node:path";
10096
+ import { join as join25, dirname as dirname7 } from "node:path";
9692
10097
  import { fileURLToPath as fileURLToPath3 } from "node:url";
9693
10098
  function hasCommand2(cmd) {
9694
10099
  try {
@@ -9812,7 +10217,7 @@ for i in range(${clicks}):
9812
10217
  } catch {
9813
10218
  }
9814
10219
  try {
9815
- const venvPy = join24(__dirname2, "../../../../.moondream-venv/bin/python");
10220
+ const venvPy = join25(__dirname2, "../../../../.moondream-venv/bin/python");
9816
10221
  execSync12(`DISPLAY=:0 ${JSON.stringify(venvPy)} -c "${pyScript}"`, { stdio: "pipe", timeout: 5e3 });
9817
10222
  return;
9818
10223
  } catch {
@@ -9904,7 +10309,7 @@ var init_desktop_click = __esm({
9904
10309
  if (delayMs > 0) {
9905
10310
  await new Promise((r) => setTimeout(r, delayMs));
9906
10311
  }
9907
- const screenshotPath = join24(tmpdir4(), `oa-desktop-click-${Date.now()}.png`);
10312
+ const screenshotPath = join25(tmpdir4(), `oa-desktop-click-${Date.now()}.png`);
9908
10313
  captureScreenshot(screenshotPath);
9909
10314
  const dims = getImageDimensions2(screenshotPath);
9910
10315
  if (!dims) {
@@ -10079,7 +10484,7 @@ Screenshot: ${screenshotPath}`,
10079
10484
  if (delayMs > 0) {
10080
10485
  await new Promise((r) => setTimeout(r, delayMs));
10081
10486
  }
10082
- const screenshotPath = join24(tmpdir4(), `oa-desktop-describe-${Date.now()}.png`);
10487
+ const screenshotPath = join25(tmpdir4(), `oa-desktop-describe-${Date.now()}.png`);
10083
10488
  captureScreenshot(screenshotPath);
10084
10489
  const dims = getImageDimensions2(screenshotPath);
10085
10490
  const imageBuffer = readFileSync12(screenshotPath);
@@ -10318,7 +10723,7 @@ Language: ${language}
10318
10723
 
10319
10724
  // packages/execution/dist/tools/pdf-to-text.js
10320
10725
  import { existsSync as existsSync17, statSync as statSync7, readFileSync as readFileSync13, unlinkSync as unlinkSync3 } from "node:fs";
10321
- import { resolve as resolve18, basename as basename7, join as join25 } from "node:path";
10726
+ import { resolve as resolve18, basename as basename7, join as join26 } from "node:path";
10322
10727
  import { execSync as execSync14 } from "node:child_process";
10323
10728
  import { tmpdir as tmpdir5 } from "node:os";
10324
10729
  var PdfToTextTool;
@@ -10472,7 +10877,7 @@ ${text}`,
10472
10877
  if (!ocrCheck.available || !tesCheck.available || !gsCheck.available) {
10473
10878
  return null;
10474
10879
  }
10475
- const tmpPdf = join25(tmpdir5(), `oa-ocr-${Date.now()}.pdf`);
10880
+ const tmpPdf = join26(tmpdir5(), `oa-ocr-${Date.now()}.pdf`);
10476
10881
  try {
10477
10882
  const ocrCmd = `ocrmypdf -l ${language} --skip-text ${JSON.stringify(inputPath)} ${JSON.stringify(tmpPdf)}`;
10478
10883
  execSync14(ocrCmd, { stdio: "pipe", timeout: 6e5 });
@@ -10503,7 +10908,7 @@ ${text}`,
10503
10908
 
10504
10909
  // packages/execution/dist/tools/ocr-image-advanced.js
10505
10910
  import { existsSync as existsSync18, statSync as statSync8 } from "node:fs";
10506
- import { resolve as resolve19, basename as basename8, dirname as dirname8, join as join26 } from "node:path";
10911
+ import { resolve as resolve19, basename as basename8, dirname as dirname8, join as join27 } from "node:path";
10507
10912
  import { execSync as execSync15 } from "node:child_process";
10508
10913
  import { fileURLToPath as fileURLToPath4 } from "node:url";
10509
10914
  import { homedir as homedir7, tmpdir as tmpdir6 } from "node:os";
@@ -10521,7 +10926,7 @@ function findOcrScript() {
10521
10926
  return null;
10522
10927
  }
10523
10928
  function findPython() {
10524
- const venvPython = join26(homedir7(), ".open-agents", "venv", "bin", "python");
10929
+ const venvPython = join27(homedir7(), ".open-agents", "venv", "bin", "python");
10525
10930
  if (existsSync18(venvPython)) {
10526
10931
  try {
10527
10932
  execSync15(`${JSON.stringify(venvPython)} -c "import cv2, pytesseract, numpy, PIL"`, {
@@ -10667,7 +11072,7 @@ var init_ocr_image_advanced = __esm({
10667
11072
  cmdParts.push("--output-dir", JSON.stringify(resolve19(this.workingDir, outputDir)));
10668
11073
  let debugDir;
10669
11074
  if (debug) {
10670
- debugDir = join26(tmpdir6(), `oa-ocr-debug-${Date.now()}`);
11075
+ debugDir = join27(tmpdir6(), `oa-ocr-debug-${Date.now()}`);
10671
11076
  cmdParts.push("--debug-dir", debugDir);
10672
11077
  }
10673
11078
  try {
@@ -10766,7 +11171,7 @@ var init_ocr_image_advanced = __esm({
10766
11171
  if (region) {
10767
11172
  try {
10768
11173
  const [x, y, w, h] = region.split(",").map(Number);
10769
- const croppedPath = join26(tmpdir6(), `oa-ocr-crop-${Date.now()}.png`);
11174
+ const croppedPath = join27(tmpdir6(), `oa-ocr-crop-${Date.now()}.png`);
10770
11175
  execSync15(`convert ${JSON.stringify(imagePath)} -crop ${w}x${h}+${x}+${y} +repage ${JSON.stringify(croppedPath)}`, { stdio: "pipe", timeout: 1e4 });
10771
11176
  inputPath = croppedPath;
10772
11177
  } catch {
@@ -10807,18 +11212,18 @@ Note: Advanced Python pipeline not available \u2014 install pytesseract, opencv-
10807
11212
  // packages/execution/dist/tools/browser-action.js
10808
11213
  import { execSync as execSync16, spawn as spawn8 } from "node:child_process";
10809
11214
  import { existsSync as existsSync19, readFileSync as readFileSync14 } from "node:fs";
10810
- import { join as join27, dirname as dirname9 } from "node:path";
11215
+ import { join as join28, dirname as dirname9 } from "node:path";
10811
11216
  import { fileURLToPath as fileURLToPath5 } from "node:url";
10812
11217
  function findScrapeScript() {
10813
11218
  const candidates = [
10814
11219
  // Published npm package: dist/scripts/web_scrape.py
10815
- join27(__dirname3, "scripts", "web_scrape.py"),
11220
+ join28(__dirname3, "scripts", "web_scrape.py"),
10816
11221
  // Published npm package (from node_modules): node_modules/open-agents-ai/dist/scripts/
10817
- join27(__dirname3, "..", "node_modules", "open-agents-ai", "dist", "scripts", "web_scrape.py"),
11222
+ join28(__dirname3, "..", "node_modules", "open-agents-ai", "dist", "scripts", "web_scrape.py"),
10818
11223
  // Dev monorepo: packages/execution/src/tools/../../scripts/
10819
- join27(__dirname3, "..", "..", "scripts", "web_scrape.py"),
11224
+ join28(__dirname3, "..", "..", "scripts", "web_scrape.py"),
10820
11225
  // Dev monorepo alt: packages/execution/scripts/
10821
- join27(__dirname3, "..", "scripts", "web_scrape.py")
11226
+ join28(__dirname3, "..", "scripts", "web_scrape.py")
10822
11227
  ];
10823
11228
  return candidates.find((p) => existsSync19(p)) || candidates[0];
10824
11229
  }
@@ -11073,7 +11478,7 @@ var init_browser_action = __esm({
11073
11478
  // packages/execution/dist/tools/autoresearch.js
11074
11479
  import { execSync as execSync17, spawn as spawn9 } from "node:child_process";
11075
11480
  import { existsSync as existsSync20, readFileSync as readFileSync15, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, appendFileSync, copyFileSync } from "node:fs";
11076
- import { join as join28, resolve as resolve20, dirname as dirname10 } from "node:path";
11481
+ import { join as join29, resolve as resolve20, dirname as dirname10 } from "node:path";
11077
11482
  import { fileURLToPath as fileURLToPath6 } from "node:url";
11078
11483
  function findAutoresearchScript(scriptName) {
11079
11484
  const thisDir = dirname10(fileURLToPath6(import.meta.url));
@@ -11175,7 +11580,7 @@ Requires: NVIDIA GPU, Python 3.10+, uv (astral.sh package manager).`;
11175
11580
  async execute(args) {
11176
11581
  const start = Date.now();
11177
11582
  const action = String(args["action"] ?? "status");
11178
- const workspacePath = String(args["workspace"] ?? join28(this.repoRoot, ".oa", "autoresearch"));
11583
+ const workspacePath = String(args["workspace"] ?? join29(this.repoRoot, ".oa", "autoresearch"));
11179
11584
  try {
11180
11585
  switch (action) {
11181
11586
  case "setup":
@@ -11216,13 +11621,13 @@ Requires: NVIDIA GPU, Python 3.10+, uv (astral.sh package manager).`;
11216
11621
  const prepareScript = findAutoresearchScript("autoresearch-prepare.py");
11217
11622
  const trainScript = findAutoresearchScript("autoresearch-train.py");
11218
11623
  if (prepareScript) {
11219
- copyFileSync(prepareScript, join28(workspace, "prepare.py"));
11624
+ copyFileSync(prepareScript, join29(workspace, "prepare.py"));
11220
11625
  output.push("Copied prepare.py template");
11221
11626
  } else {
11222
11627
  return { success: false, output: output.join("\n"), error: "autoresearch-prepare.py template not found in distribution", durationMs: Date.now() - start };
11223
11628
  }
11224
11629
  if (trainScript) {
11225
- copyFileSync(trainScript, join28(workspace, "train.py"));
11630
+ copyFileSync(trainScript, join29(workspace, "train.py"));
11226
11631
  output.push("Copied train.py template");
11227
11632
  } else {
11228
11633
  return { success: false, output: output.join("\n"), error: "autoresearch-train.py template not found in distribution", durationMs: Date.now() - start };
@@ -11254,7 +11659,7 @@ name = "pytorch-cu128"
11254
11659
  url = "https://download.pytorch.org/whl/cu128"
11255
11660
  explicit = true
11256
11661
  `;
11257
- writeFileSync6(join28(workspace, "pyproject.toml"), pyprojectContent, "utf-8");
11662
+ writeFileSync6(join29(workspace, "pyproject.toml"), pyprojectContent, "utf-8");
11258
11663
  output.push("Created pyproject.toml");
11259
11664
  try {
11260
11665
  execSync17("git rev-parse --git-dir", { cwd: workspace, encoding: "utf-8", timeout: 5e3 });
@@ -11296,7 +11701,7 @@ explicit = true
11296
11701
  const e = err;
11297
11702
  output.push(`Data prep warning: ${(e.stderr ?? e.stdout ?? "failed").slice(0, 500)}`);
11298
11703
  }
11299
- const tsvPath = join28(workspace, "results.tsv");
11704
+ const tsvPath = join29(workspace, "results.tsv");
11300
11705
  if (!existsSync20(tsvPath)) {
11301
11706
  writeFileSync6(tsvPath, "commit val_bpb memory_gb status description\n", "utf-8");
11302
11707
  output.push("Created results.tsv");
@@ -11318,10 +11723,10 @@ Next steps:
11318
11723
  }
11319
11724
  // ── Run experiment ─────────────────────────────────────────────────────
11320
11725
  async run(workspace, args, start) {
11321
- if (!existsSync20(join28(workspace, "train.py"))) {
11726
+ if (!existsSync20(join29(workspace, "train.py"))) {
11322
11727
  return { success: false, output: "", error: `No train.py found in ${workspace}. Run autoresearch(action="setup") first.`, durationMs: Date.now() - start };
11323
11728
  }
11324
- if (!existsSync20(join28(workspace, ".venv")) && existsSync20(join28(workspace, "pyproject.toml"))) {
11729
+ if (!existsSync20(join29(workspace, ".venv")) && existsSync20(join29(workspace, "pyproject.toml"))) {
11325
11730
  try {
11326
11731
  execSync17("uv sync 2>&1", { cwd: workspace, encoding: "utf-8", timeout: 3e5 });
11327
11732
  } catch {
@@ -11329,7 +11734,7 @@ Next steps:
11329
11734
  }
11330
11735
  const timeoutMin = Number(args["timeout_minutes"] ?? 10);
11331
11736
  const timeoutMs = timeoutMin * 60 * 1e3;
11332
- const logPath = join28(workspace, "run.log");
11737
+ const logPath = join29(workspace, "run.log");
11333
11738
  return new Promise((resolveResult) => {
11334
11739
  const proc = spawn9("uv", ["run", "train.py"], {
11335
11740
  cwd: workspace,
@@ -11400,7 +11805,7 @@ ${fullLog.slice(-2e3)}`,
11400
11805
  return;
11401
11806
  }
11402
11807
  try {
11403
- writeFileSync6(join28(workspace, ".last-result.json"), JSON.stringify(result, null, 2), "utf-8");
11808
+ writeFileSync6(join29(workspace, ".last-result.json"), JSON.stringify(result, null, 2), "utf-8");
11404
11809
  } catch {
11405
11810
  }
11406
11811
  const memGB = (result.peak_vram_mb / 1024).toFixed(1);
@@ -11436,7 +11841,7 @@ ${fullLog.slice(-2e3)}`,
11436
11841
  }
11437
11842
  // ── Results ────────────────────────────────────────────────────────────
11438
11843
  getResults(workspace, start) {
11439
- const tsvPath = join28(workspace, "results.tsv");
11844
+ const tsvPath = join29(workspace, "results.tsv");
11440
11845
  if (!existsSync20(tsvPath)) {
11441
11846
  return { success: false, output: "", error: `No results.tsv found. Run autoresearch(action="setup") first.`, durationMs: Date.now() - start };
11442
11847
  }
@@ -11463,7 +11868,7 @@ ${fullLog.slice(-2e3)}`,
11463
11868
  // ── Status ─────────────────────────────────────────────────────────────
11464
11869
  getStatus(workspace, start) {
11465
11870
  const output = [];
11466
- if (!existsSync20(join28(workspace, "train.py"))) {
11871
+ if (!existsSync20(join29(workspace, "train.py"))) {
11467
11872
  return {
11468
11873
  success: true,
11469
11874
  output: `Autoresearch workspace not initialized at ${workspace}.
@@ -11486,7 +11891,7 @@ Run autoresearch(action="setup") to begin.`,
11486
11891
  } catch {
11487
11892
  output.push("GPU: not detected");
11488
11893
  }
11489
- const lastResultPath = join28(workspace, ".last-result.json");
11894
+ const lastResultPath = join29(workspace, ".last-result.json");
11490
11895
  if (existsSync20(lastResultPath)) {
11491
11896
  try {
11492
11897
  const last = JSON.parse(readFileSync15(lastResultPath, "utf-8"));
@@ -11494,20 +11899,20 @@ Run autoresearch(action="setup") to begin.`,
11494
11899
  } catch {
11495
11900
  }
11496
11901
  }
11497
- const tsvPath = join28(workspace, "results.tsv");
11902
+ const tsvPath = join29(workspace, "results.tsv");
11498
11903
  if (existsSync20(tsvPath)) {
11499
11904
  const lines = readFileSync15(tsvPath, "utf-8").trim().split("\n");
11500
11905
  output.push(`Experiments recorded: ${lines.length - 1}`);
11501
11906
  }
11502
- const cacheDir = join28(process.env["HOME"] ?? "~", ".cache", "autoresearch");
11907
+ const cacheDir = join29(process.env["HOME"] ?? "~", ".cache", "autoresearch");
11503
11908
  output.push(`Data cache: ${existsSync20(cacheDir) ? "present" : "not found"} (${cacheDir})`);
11504
11909
  return { success: true, output: output.join("\n"), durationMs: Date.now() - start };
11505
11910
  }
11506
11911
  // ── Keep / Discard ─────────────────────────────────────────────────────
11507
11912
  keepExperiment(workspace, args, start) {
11508
11913
  const desc = String(args["description"] ?? "experiment");
11509
- const tsvPath = join28(workspace, "results.tsv");
11510
- const lastResultPath = join28(workspace, ".last-result.json");
11914
+ const tsvPath = join29(workspace, "results.tsv");
11915
+ const lastResultPath = join29(workspace, ".last-result.json");
11511
11916
  let valBpb = args["val_bpb"];
11512
11917
  let memGb = args["memory_gb"];
11513
11918
  if ((valBpb === void 0 || memGb === void 0) && existsSync20(lastResultPath)) {
@@ -11545,8 +11950,8 @@ Branch advanced. Ready for next experiment.`,
11545
11950
  }
11546
11951
  discardExperiment(workspace, args, start) {
11547
11952
  const desc = String(args["description"] ?? "experiment");
11548
- const tsvPath = join28(workspace, "results.tsv");
11549
- const lastResultPath = join28(workspace, ".last-result.json");
11953
+ const tsvPath = join29(workspace, "results.tsv");
11954
+ const lastResultPath = join29(workspace, ".last-result.json");
11550
11955
  let valBpb = args["val_bpb"];
11551
11956
  let memGb = args["memory_gb"];
11552
11957
  if ((valBpb === void 0 || memGb === void 0) && existsSync20(lastResultPath)) {
@@ -11592,8 +11997,8 @@ train.py reverted to last kept state. Ready for next experiment.`,
11592
11997
 
11593
11998
  // packages/execution/dist/tools/scheduler.js
11594
11999
  import { execSync as execSync18, exec as execCb } from "node:child_process";
11595
- import { readFile as readFile13, writeFile as writeFile12, mkdir as mkdir8 } from "node:fs/promises";
11596
- import { resolve as resolve21, join as join29 } from "node:path";
12000
+ import { readFile as readFile14, writeFile as writeFile13, mkdir as mkdir9 } from "node:fs/promises";
12001
+ import { resolve as resolve21, join as join30 } from "node:path";
11597
12002
  import { randomBytes as randomBytes3 } from "node:crypto";
11598
12003
  function isValidCron(expr) {
11599
12004
  const parts = expr.trim().split(/\s+/);
@@ -11677,7 +12082,7 @@ function installCronJob(task, workingDir) {
11677
12082
  const lines = getCurrentCrontab();
11678
12083
  const oaBin = findOaBinary();
11679
12084
  const logDir = resolve21(workingDir, ".oa", "scheduled", "logs");
11680
- const logFile = join29(logDir, `${task.id}.log`);
12085
+ const logFile = join30(logDir, `${task.id}.log`);
11681
12086
  const storeFile = resolve21(workingDir, ".oa", "scheduled", "tasks.json");
11682
12087
  const taskEscaped = task.task.replace(/'/g, "'\\''");
11683
12088
  const taskId = task.id;
@@ -11710,7 +12115,7 @@ function listCronJobs() {
11710
12115
  async function loadStore(workingDir) {
11711
12116
  const storePath = resolve21(workingDir, ".oa", "scheduled", "tasks.json");
11712
12117
  try {
11713
- const raw = await readFile13(storePath, "utf-8");
12118
+ const raw = await readFile14(storePath, "utf-8");
11714
12119
  return JSON.parse(raw);
11715
12120
  } catch {
11716
12121
  return { tasks: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -11718,10 +12123,10 @@ async function loadStore(workingDir) {
11718
12123
  }
11719
12124
  async function saveStore(workingDir, store) {
11720
12125
  const dir = resolve21(workingDir, ".oa", "scheduled");
11721
- await mkdir8(dir, { recursive: true });
11722
- await mkdir8(join29(dir, "logs"), { recursive: true });
12126
+ await mkdir9(dir, { recursive: true });
12127
+ await mkdir9(join30(dir, "logs"), { recursive: true });
11723
12128
  store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
11724
- await writeFile12(join29(dir, "tasks.json"), JSON.stringify(store, null, 2), "utf-8");
12129
+ await writeFile13(join30(dir, "tasks.json"), JSON.stringify(store, null, 2), "utf-8");
11725
12130
  }
11726
12131
  var SCHEDULE_PRESETS, CRON_MARKER, SchedulerTool;
11727
12132
  var init_scheduler = __esm({
@@ -11941,7 +12346,7 @@ var init_scheduler = __esm({
11941
12346
  return { success: false, output: "", error: "id is required for logs action", durationMs: performance.now() - start };
11942
12347
  const logFile = resolve21(this.workingDir, ".oa", "scheduled", "logs", `${id}.log`);
11943
12348
  try {
11944
- const raw = await readFile13(logFile, "utf-8");
12349
+ const raw = await readFile14(logFile, "utf-8");
11945
12350
  const truncated = raw.length > 1e4 ? "...(truncated)\n" + raw.slice(-1e4) : raw;
11946
12351
  return { success: true, output: `Logs for ${id}:
11947
12352
  ${truncated}`, durationMs: performance.now() - start };
@@ -11954,8 +12359,8 @@ ${truncated}`, durationMs: performance.now() - start };
11954
12359
  });
11955
12360
 
11956
12361
  // packages/execution/dist/tools/reminder.js
11957
- import { readFile as readFile14, writeFile as writeFile13, mkdir as mkdir9 } from "node:fs/promises";
11958
- import { resolve as resolve22, join as join30 } from "node:path";
12362
+ import { readFile as readFile15, writeFile as writeFile14, mkdir as mkdir10 } from "node:fs/promises";
12363
+ import { resolve as resolve22, join as join31 } from "node:path";
11959
12364
  import { randomBytes as randomBytes4 } from "node:crypto";
11960
12365
  function parseDueTime(due) {
11961
12366
  const lower = due.toLowerCase().trim();
@@ -12006,13 +12411,13 @@ function parseDueTime(due) {
12006
12411
  }
12007
12412
  async function getStorePath(workingDir) {
12008
12413
  const dir = resolve22(workingDir, ".oa", "scheduled");
12009
- await mkdir9(dir, { recursive: true });
12010
- return join30(dir, STORE_FILE);
12414
+ await mkdir10(dir, { recursive: true });
12415
+ return join31(dir, STORE_FILE);
12011
12416
  }
12012
12417
  async function loadReminderStore(workingDir) {
12013
12418
  const storePath = await getStorePath(workingDir);
12014
12419
  try {
12015
- const raw = await readFile14(storePath, "utf-8");
12420
+ const raw = await readFile15(storePath, "utf-8");
12016
12421
  return JSON.parse(raw);
12017
12422
  } catch {
12018
12423
  return { reminders: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -12021,7 +12426,7 @@ async function loadReminderStore(workingDir) {
12021
12426
  async function saveReminderStore(workingDir, store) {
12022
12427
  const storePath = await getStorePath(workingDir);
12023
12428
  store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
12024
- await writeFile13(storePath, JSON.stringify(store, null, 2), "utf-8");
12429
+ await writeFile14(storePath, JSON.stringify(store, null, 2), "utf-8");
12025
12430
  }
12026
12431
  async function getDueReminders(workingDir) {
12027
12432
  const store = await loadReminderStore(workingDir);
@@ -12267,13 +12672,13 @@ var init_reminder = __esm({
12267
12672
  });
12268
12673
 
12269
12674
  // packages/execution/dist/tools/agenda.js
12270
- import { readFile as readFile15, writeFile as writeFile14, mkdir as mkdir10 } from "node:fs/promises";
12271
- import { resolve as resolve23, join as join31 } from "node:path";
12675
+ import { readFile as readFile16, writeFile as writeFile15, mkdir as mkdir11 } from "node:fs/promises";
12676
+ import { resolve as resolve23, join as join32 } from "node:path";
12272
12677
  import { randomBytes as randomBytes5 } from "node:crypto";
12273
12678
  async function loadAttentionStore(workingDir) {
12274
12679
  const storePath = resolve23(workingDir, ".oa", "scheduled", "attention.json");
12275
12680
  try {
12276
- const raw = await readFile15(storePath, "utf-8");
12681
+ const raw = await readFile16(storePath, "utf-8");
12277
12682
  return JSON.parse(raw);
12278
12683
  } catch {
12279
12684
  return { items: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -12281,9 +12686,9 @@ async function loadAttentionStore(workingDir) {
12281
12686
  }
12282
12687
  async function saveAttentionStore(workingDir, store) {
12283
12688
  const dir = resolve23(workingDir, ".oa", "scheduled");
12284
- await mkdir10(dir, { recursive: true });
12689
+ await mkdir11(dir, { recursive: true });
12285
12690
  store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
12286
- await writeFile14(join31(dir, "attention.json"), JSON.stringify(store, null, 2), "utf-8");
12691
+ await writeFile15(join32(dir, "attention.json"), JSON.stringify(store, null, 2), "utf-8");
12287
12692
  }
12288
12693
  async function getActiveAttentionItems(workingDir) {
12289
12694
  const store = await loadAttentionStore(workingDir);
@@ -12579,7 +12984,7 @@ ${sections.join("\n")}`,
12579
12984
  async loadScheduleStore() {
12580
12985
  try {
12581
12986
  const storePath = resolve23(this.workingDir, ".oa", "scheduled", "tasks.json");
12582
- const raw = await readFile15(storePath, "utf-8");
12987
+ const raw = await readFile16(storePath, "utf-8");
12583
12988
  const store = JSON.parse(raw);
12584
12989
  return store.tasks ?? [];
12585
12990
  } catch {
@@ -12593,7 +12998,7 @@ ${sections.join("\n")}`,
12593
12998
  // packages/execution/dist/tools/opencode.js
12594
12999
  import { execSync as execSync19, spawn as spawn10 } from "node:child_process";
12595
13000
  import { existsSync as existsSync21 } from "node:fs";
12596
- import { join as join32, resolve as resolve24 } from "node:path";
13001
+ import { join as join33, resolve as resolve24 } from "node:path";
12597
13002
  function findOpencode() {
12598
13003
  for (const cmd of ["opencode"]) {
12599
13004
  try {
@@ -12605,8 +13010,8 @@ function findOpencode() {
12605
13010
  }
12606
13011
  const homeDir = process.env.HOME || process.env.USERPROFILE || "";
12607
13012
  const candidates = [
12608
- join32(homeDir, ".opencode", "bin", "opencode"),
12609
- join32(homeDir, "bin", "opencode"),
13013
+ join33(homeDir, ".opencode", "bin", "opencode"),
13014
+ join33(homeDir, "bin", "opencode"),
12610
13015
  "/usr/local/bin/opencode"
12611
13016
  ];
12612
13017
  for (const p of candidates) {
@@ -12867,7 +13272,7 @@ var init_opencode = __esm({
12867
13272
  // packages/execution/dist/tools/factory.js
12868
13273
  import { execSync as execSync20, spawn as spawn11 } from "node:child_process";
12869
13274
  import { existsSync as existsSync22 } from "node:fs";
12870
- import { join as join33 } from "node:path";
13275
+ import { join as join34 } from "node:path";
12871
13276
  function findDroid() {
12872
13277
  for (const cmd of ["droid"]) {
12873
13278
  try {
@@ -12879,8 +13284,8 @@ function findDroid() {
12879
13284
  }
12880
13285
  const homeDir = process.env.HOME || process.env.USERPROFILE || "";
12881
13286
  const candidates = [
12882
- join33(homeDir, ".factory", "bin", "droid"),
12883
- join33(homeDir, "bin", "droid"),
13287
+ join34(homeDir, ".factory", "bin", "droid"),
13288
+ join34(homeDir, "bin", "droid"),
12884
13289
  "/usr/local/bin/droid"
12885
13290
  ];
12886
13291
  for (const p of candidates) {
@@ -13175,8 +13580,8 @@ var init_factory = __esm({
13175
13580
 
13176
13581
  // packages/execution/dist/tools/cron-agent.js
13177
13582
  import { execSync as execSync21 } from "node:child_process";
13178
- import { readFile as readFile16, writeFile as writeFile15, mkdir as mkdir11 } from "node:fs/promises";
13179
- import { resolve as resolve25, join as join34 } from "node:path";
13583
+ import { readFile as readFile17, writeFile as writeFile16, mkdir as mkdir12 } from "node:fs/promises";
13584
+ import { resolve as resolve25, join as join35 } from "node:path";
13180
13585
  import { randomBytes as randomBytes6 } from "node:crypto";
13181
13586
  function isValidCron2(expr) {
13182
13587
  const parts = expr.trim().split(/\s+/);
@@ -13262,7 +13667,7 @@ function installCronAgentJob(job, workingDir) {
13262
13667
  const lines = getCurrentCrontab2();
13263
13668
  const oaBin = findOaBinary2();
13264
13669
  const logDir = resolve25(workingDir, ".oa", "cron-agents", "logs");
13265
- const logFile = join34(logDir, `${job.id}.log`);
13670
+ const logFile = join35(logDir, `${job.id}.log`);
13266
13671
  const storeFile = resolve25(workingDir, ".oa", "cron-agents", "store.json");
13267
13672
  const taskEscaped = job.task.replace(/'/g, "'\\''");
13268
13673
  const jobId = job.id;
@@ -13292,7 +13697,7 @@ function removeCronAgentJob(jobId) {
13292
13697
  async function loadStore2(workingDir) {
13293
13698
  const storePath = resolve25(workingDir, ".oa", "cron-agents", "store.json");
13294
13699
  try {
13295
- const raw = await readFile16(storePath, "utf-8");
13700
+ const raw = await readFile17(storePath, "utf-8");
13296
13701
  return JSON.parse(raw);
13297
13702
  } catch {
13298
13703
  return { jobs: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -13300,10 +13705,10 @@ async function loadStore2(workingDir) {
13300
13705
  }
13301
13706
  async function saveStore2(workingDir, store) {
13302
13707
  const dir = resolve25(workingDir, ".oa", "cron-agents");
13303
- await mkdir11(dir, { recursive: true });
13304
- await mkdir11(join34(dir, "logs"), { recursive: true });
13708
+ await mkdir12(dir, { recursive: true });
13709
+ await mkdir12(join35(dir, "logs"), { recursive: true });
13305
13710
  store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
13306
- await writeFile15(join34(dir, "store.json"), JSON.stringify(store, null, 2), "utf-8");
13711
+ await writeFile16(join35(dir, "store.json"), JSON.stringify(store, null, 2), "utf-8");
13307
13712
  }
13308
13713
  var LONG_HORIZON_PRESETS, CRON_AGENT_MARKER, CronAgentTool;
13309
13714
  var init_cron_agent = __esm({
@@ -13568,7 +13973,7 @@ var init_cron_agent = __esm({
13568
13973
  return { success: false, output: "", error: "id is required", durationMs: performance.now() - start };
13569
13974
  const logFile = resolve25(this.workingDir, ".oa", "cron-agents", "logs", `${id}.log`);
13570
13975
  try {
13571
- const raw = await readFile16(logFile, "utf-8");
13976
+ const raw = await readFile17(logFile, "utf-8");
13572
13977
  const truncated = raw.length > 2e4 ? "...(truncated)\n" + raw.slice(-2e4) : raw;
13573
13978
  return { success: true, output: `Logs for ${id}:
13574
13979
  ${truncated}`, durationMs: performance.now() - start };
@@ -13639,9 +14044,9 @@ ${truncated}`, durationMs: performance.now() - start };
13639
14044
  });
13640
14045
 
13641
14046
  // packages/execution/dist/tools/nexus.js
13642
- import { readFile as readFile17, writeFile as writeFile16, mkdir as mkdir12, chmod, unlink, readdir as readdir3, open as fsOpen } from "node:fs/promises";
14047
+ import { readFile as readFile18, writeFile as writeFile17, mkdir as mkdir13, chmod, unlink, readdir as readdir4, open as fsOpen } from "node:fs/promises";
13643
14048
  import { existsSync as existsSync23, readFileSync as readFileSync16, watch as fsWatchLocal } from "node:fs";
13644
- import { resolve as resolve26, join as join35 } from "node:path";
14049
+ import { resolve as resolve26, join as join36 } from "node:path";
13645
14050
  import { randomBytes as randomBytes7, createCipheriv, createDecipheriv, scryptSync, createHash } from "node:crypto";
13646
14051
  import { execSync as execSync22, spawn as spawn12 } from "node:child_process";
13647
14052
  import { hostname, userInfo } from "node:os";
@@ -15615,7 +16020,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15615
16020
  }
15616
16021
  async ensureDir() {
15617
16022
  if (!existsSync23(this.nexusDir)) {
15618
- await mkdir12(this.nexusDir, { recursive: true });
16023
+ await mkdir13(this.nexusDir, { recursive: true });
15619
16024
  }
15620
16025
  }
15621
16026
  async execute(args) {
@@ -15738,7 +16143,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15738
16143
  // Daemon management
15739
16144
  // =========================================================================
15740
16145
  getDaemonPid() {
15741
- const pidFile = join35(this.nexusDir, "daemon.pid");
16146
+ const pidFile = join36(this.nexusDir, "daemon.pid");
15742
16147
  if (!existsSync23(pidFile))
15743
16148
  return null;
15744
16149
  try {
@@ -15764,12 +16169,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15764
16169
  throw new Error("Nexus daemon not running. Use action 'connect' first.");
15765
16170
  }
15766
16171
  const cmdId = randomBytes7(8).toString("hex");
15767
- const cmdFile = join35(this.nexusDir, "cmd.json");
15768
- const respFile = join35(this.nexusDir, "resp.json");
16172
+ const cmdFile = join36(this.nexusDir, "cmd.json");
16173
+ const respFile = join36(this.nexusDir, "resp.json");
15769
16174
  if (existsSync23(respFile))
15770
16175
  await unlink(respFile).catch(() => {
15771
16176
  });
15772
- await writeFile16(cmdFile, JSON.stringify({ id: cmdId, action, args }, null, 2));
16177
+ await writeFile17(cmdFile, JSON.stringify({ id: cmdId, action, args }, null, 2));
15773
16178
  const pollMs = 50;
15774
16179
  const polls = Math.ceil(timeoutMs / pollMs);
15775
16180
  let resolved = false;
@@ -15801,7 +16206,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15801
16206
  if (!existsSync23(respFile))
15802
16207
  continue;
15803
16208
  try {
15804
- const resp = JSON.parse(await readFile17(respFile, "utf8"));
16209
+ const resp = JSON.parse(await readFile18(respFile, "utf8"));
15805
16210
  if (resp.id === cmdId) {
15806
16211
  resolved = true;
15807
16212
  return resp.output || (resp.ok ? "OK" : "Failed");
@@ -15824,7 +16229,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15824
16229
  }
15825
16230
  if (existsSync23(respFile)) {
15826
16231
  try {
15827
- const resp = JSON.parse(await readFile17(respFile, "utf8"));
16232
+ const resp = JSON.parse(await readFile18(respFile, "utf8"));
15828
16233
  if (resp.id === cmdId) {
15829
16234
  return resp.output || (resp.ok ? "OK" : "Failed");
15830
16235
  }
@@ -15849,7 +16254,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15849
16254
  const currentScriptHash = createHash("sha256").update(DAEMON_SCRIPT).digest("hex").slice(0, 16);
15850
16255
  const existingPid = this.getDaemonPid();
15851
16256
  if (existingPid) {
15852
- const daemonPath2 = join35(this.nexusDir, "nexus-daemon.mjs");
16257
+ const daemonPath2 = join36(this.nexusDir, "nexus-daemon.mjs");
15853
16258
  let needsRestart = true;
15854
16259
  if (existsSync23(daemonPath2)) {
15855
16260
  try {
@@ -15873,16 +16278,16 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15873
16278
  } catch {
15874
16279
  }
15875
16280
  for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
15876
- const p = join35(this.nexusDir, f);
16281
+ const p = join36(this.nexusDir, f);
15877
16282
  if (existsSync23(p))
15878
16283
  await unlink(p).catch(() => {
15879
16284
  });
15880
16285
  }
15881
16286
  } else {
15882
- const statusFile2 = join35(this.nexusDir, "status.json");
16287
+ const statusFile2 = join36(this.nexusDir, "status.json");
15883
16288
  if (existsSync23(statusFile2)) {
15884
16289
  try {
15885
- const status = JSON.parse(await readFile17(statusFile2, "utf8"));
16290
+ const status = JSON.parse(await readFile18(statusFile2, "utf8"));
15886
16291
  if (status.connected && status.peerId) {
15887
16292
  await this.ensureWallet();
15888
16293
  return `Already connected (pid: ${existingPid}, peerId: ${status.peerId})`;
@@ -15898,7 +16303,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15898
16303
  }
15899
16304
  }
15900
16305
  for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
15901
- const p = join35(this.nexusDir, f);
16306
+ const p = join36(this.nexusDir, f);
15902
16307
  if (existsSync23(p))
15903
16308
  await unlink(p).catch(() => {
15904
16309
  });
@@ -15916,7 +16321,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15916
16321
  });
15917
16322
  });
15918
16323
  try {
15919
- const nexusPkg = join35(nodeModulesDir, "open-agents-nexus", "package.json");
16324
+ const nexusPkg = join36(nodeModulesDir, "open-agents-nexus", "package.json");
15920
16325
  if (existsSync23(nexusPkg)) {
15921
16326
  nexusResolved = true;
15922
16327
  try {
@@ -15927,7 +16332,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15927
16332
  } else {
15928
16333
  try {
15929
16334
  const globalDir = await execAsync2("npm root -g", { timeout: 5e3 });
15930
- const globalPkg = join35(globalDir, "open-agents-nexus", "package.json");
16335
+ const globalPkg = join36(globalDir, "open-agents-nexus", "package.json");
15931
16336
  if (existsSync23(globalPkg)) {
15932
16337
  nexusResolved = true;
15933
16338
  try {
@@ -15972,8 +16377,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15972
16377
  }
15973
16378
  }
15974
16379
  await this.ensureWallet();
15975
- const daemonPath = join35(this.nexusDir, "nexus-daemon.mjs");
15976
- await writeFile16(daemonPath, DAEMON_SCRIPT);
16380
+ const daemonPath = join36(this.nexusDir, "nexus-daemon.mjs");
16381
+ await writeFile17(daemonPath, DAEMON_SCRIPT);
15977
16382
  const agentName = args.agent_name || "open-agents-node";
15978
16383
  const agentType = args.agent_type || "general";
15979
16384
  const nodePaths = [nodeModulesDir];
@@ -15983,8 +16388,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
15983
16388
  } catch {
15984
16389
  }
15985
16390
  const { openSync: openSync2, closeSync: closeSync2 } = await import("node:fs");
15986
- const daemonLogPath = join35(this.nexusDir, "daemon.log");
15987
- const daemonErrPath = join35(this.nexusDir, "daemon.err");
16391
+ const daemonLogPath = join36(this.nexusDir, "daemon.log");
16392
+ const daemonErrPath = join36(this.nexusDir, "daemon.err");
15988
16393
  const outFd = openSync2(daemonLogPath, "w");
15989
16394
  const errFd = openSync2(daemonErrPath, "w");
15990
16395
  const child = spawn12("node", [daemonPath, this.nexusDir, agentName, agentType], {
@@ -16002,16 +16407,16 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16002
16407
  closeSync2(errFd);
16003
16408
  } catch {
16004
16409
  }
16005
- const statusFile = join35(this.nexusDir, "status.json");
16410
+ const statusFile = join36(this.nexusDir, "status.json");
16006
16411
  for (let i = 0; i < 40; i++) {
16007
16412
  await new Promise((r) => setTimeout(r, 500));
16008
16413
  if (existsSync23(statusFile)) {
16009
16414
  try {
16010
- const status = JSON.parse(await readFile17(statusFile, "utf8"));
16415
+ const status = JSON.parse(await readFile18(statusFile, "utf8"));
16011
16416
  if (status.error) {
16012
16417
  let errTail = "";
16013
16418
  try {
16014
- errTail = (await readFile17(daemonErrPath, "utf8")).slice(-300);
16419
+ errTail = (await readFile18(daemonErrPath, "utf8")).slice(-300);
16015
16420
  } catch {
16016
16421
  }
16017
16422
  return `Nexus daemon failed to connect: ${status.error}${errTail ? "\n" + errTail : ""}`;
@@ -16033,12 +16438,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16033
16438
  const pid = this.getDaemonPid();
16034
16439
  let earlyError = "";
16035
16440
  try {
16036
- earlyError = (await readFile17(daemonErrPath, "utf8")).slice(-500);
16441
+ earlyError = (await readFile18(daemonErrPath, "utf8")).slice(-500);
16037
16442
  } catch {
16038
16443
  }
16039
16444
  let earlyOutput = "";
16040
16445
  try {
16041
- earlyOutput = (await readFile17(daemonLogPath, "utf8")).slice(-500);
16446
+ earlyOutput = (await readFile18(daemonLogPath, "utf8")).slice(-500);
16042
16447
  } catch {
16043
16448
  }
16044
16449
  if (pid) {
@@ -16061,7 +16466,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16061
16466
  } catch {
16062
16467
  }
16063
16468
  for (const f of ["daemon.pid", "status.json", "cmd.json", "resp.json"]) {
16064
- const p = join35(this.nexusDir, f);
16469
+ const p = join36(this.nexusDir, f);
16065
16470
  if (existsSync23(p))
16066
16471
  await unlink(p).catch(() => {
16067
16472
  });
@@ -16072,11 +16477,11 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16072
16477
  const pid = this.getDaemonPid();
16073
16478
  if (!pid)
16074
16479
  return "Nexus daemon not running. Use action 'connect' to start.";
16075
- const statusFile = join35(this.nexusDir, "status.json");
16480
+ const statusFile = join36(this.nexusDir, "status.json");
16076
16481
  if (!existsSync23(statusFile))
16077
16482
  return `Daemon running (pid: ${pid}) but no status yet.`;
16078
16483
  try {
16079
- const status = JSON.parse(await readFile17(statusFile, "utf8"));
16484
+ const status = JSON.parse(await readFile18(statusFile, "utf8"));
16080
16485
  const lines = [
16081
16486
  `Nexus Status (v1.5.0)`,
16082
16487
  ` Connected: ${status.connected}`,
@@ -16087,10 +16492,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16087
16492
  ` Capabilities: ${(status.capabilities || []).length ? (status.capabilities || []).join(", ") : "none"}`,
16088
16493
  ` Blocked peers: ${(status.blockedPeers || []).length || 0}`
16089
16494
  ];
16090
- const walletPath = join35(this.nexusDir, "wallet.enc");
16495
+ const walletPath = join36(this.nexusDir, "wallet.enc");
16091
16496
  if (existsSync23(walletPath)) {
16092
16497
  try {
16093
- const w = JSON.parse(await readFile17(walletPath, "utf8"));
16498
+ const w = JSON.parse(await readFile18(walletPath, "utf8"));
16094
16499
  lines.push(` Wallet: ${w.address}`);
16095
16500
  } catch {
16096
16501
  lines.push(` Wallet: corrupt`);
@@ -16098,14 +16503,14 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16098
16503
  } else {
16099
16504
  lines.push(` Wallet: not configured`);
16100
16505
  }
16101
- const inboxDir = join35(this.nexusDir, "inbox");
16506
+ const inboxDir = join36(this.nexusDir, "inbox");
16102
16507
  if (existsSync23(inboxDir)) {
16103
16508
  try {
16104
- const roomDirs = await readdir3(inboxDir);
16509
+ const roomDirs = await readdir4(inboxDir);
16105
16510
  let totalMsgs = 0;
16106
16511
  for (const rd of roomDirs) {
16107
16512
  try {
16108
- totalMsgs += (await readdir3(join35(inboxDir, rd))).length;
16513
+ totalMsgs += (await readdir4(join36(inboxDir, rd))).length;
16109
16514
  } catch {
16110
16515
  }
16111
16516
  }
@@ -16152,18 +16557,18 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16152
16557
  }
16153
16558
  async doReadMessages(args) {
16154
16559
  const roomId = args.room_id;
16155
- const inboxDir = join35(this.nexusDir, "inbox");
16560
+ const inboxDir = join36(this.nexusDir, "inbox");
16156
16561
  if (roomId) {
16157
- const roomInbox = join35(inboxDir, roomId);
16562
+ const roomInbox = join36(inboxDir, roomId);
16158
16563
  if (!existsSync23(roomInbox))
16159
16564
  return `No messages in room: ${roomId}`;
16160
- const files = (await readdir3(roomInbox)).sort().slice(-20);
16565
+ const files = (await readdir4(roomInbox)).sort().slice(-20);
16161
16566
  if (files.length === 0)
16162
16567
  return `No messages in room: ${roomId}`;
16163
16568
  const messages = [`Messages in ${roomId} (last ${files.length}):`];
16164
16569
  for (const f of files) {
16165
16570
  try {
16166
- const msg = JSON.parse(await readFile17(join35(roomInbox, f), "utf8"));
16571
+ const msg = JSON.parse(await readFile18(join36(roomInbox, f), "utf8"));
16167
16572
  const sender = (msg.sender || "unknown").slice(0, 12);
16168
16573
  messages.push(` [${new Date(msg.timestamp).toLocaleTimeString()}] ${sender}...: ${msg.content}`);
16169
16574
  } catch {
@@ -16173,13 +16578,13 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16173
16578
  }
16174
16579
  if (!existsSync23(inboxDir))
16175
16580
  return "No messages received yet.";
16176
- const roomDirs = await readdir3(inboxDir);
16581
+ const roomDirs = await readdir4(inboxDir);
16177
16582
  if (roomDirs.length === 0)
16178
16583
  return "No messages received yet.";
16179
16584
  const lines = ["Inbox:"];
16180
16585
  for (const rd of roomDirs) {
16181
16586
  try {
16182
- const count = (await readdir3(join35(inboxDir, rd))).length;
16587
+ const count = (await readdir4(join36(inboxDir, rd))).length;
16183
16588
  lines.push(` ${rd}: ${count} message(s)`);
16184
16589
  } catch {
16185
16590
  }
@@ -16191,12 +16596,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16191
16596
  // ---------------------------------------------------------------------------
16192
16597
  async doWalletStatus() {
16193
16598
  await this.ensureDir();
16194
- const walletPath = join35(this.nexusDir, "wallet.enc");
16599
+ const walletPath = join36(this.nexusDir, "wallet.enc");
16195
16600
  if (!existsSync23(walletPath)) {
16196
16601
  return "No wallet configured. Use wallet_create to set one up.";
16197
16602
  }
16198
16603
  try {
16199
- const w = JSON.parse(await readFile17(walletPath, "utf8"));
16604
+ const w = JSON.parse(await readFile18(walletPath, "utf8"));
16200
16605
  const lines = [
16201
16606
  `Wallet Status:`,
16202
16607
  ` Address: ${w.address}`,
@@ -16230,7 +16635,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16230
16635
  }
16231
16636
  async doWalletCreate(args) {
16232
16637
  await this.ensureDir();
16233
- const walletPath = join35(this.nexusDir, "wallet.enc");
16638
+ const walletPath = join36(this.nexusDir, "wallet.enc");
16234
16639
  if (existsSync23(walletPath))
16235
16640
  return "Wallet already exists. Delete wallet.enc to create a new one.";
16236
16641
  const userAddress = args.wallet_address;
@@ -16276,7 +16681,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16276
16681
  const cipher = createCipheriv("aes-256-gcm", key, iv);
16277
16682
  let enc = cipher.update(privKeyHex, "utf8", "hex");
16278
16683
  enc += cipher.final("hex");
16279
- const x402KeyPath = join35(this.nexusDir, "x402-wallet.key");
16684
+ const x402KeyPath = join36(this.nexusDir, "x402-wallet.key");
16280
16685
  const x402Fh = await fsOpen(x402KeyPath, "w", 384);
16281
16686
  await x402Fh.writeFile("0x" + privKeyHex);
16282
16687
  await x402Fh.close();
@@ -16314,7 +16719,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16314
16719
  * Silent — no user output, just ensures the files exist.
16315
16720
  */
16316
16721
  async ensureWallet() {
16317
- const walletPath = join35(this.nexusDir, "wallet.enc");
16722
+ const walletPath = join36(this.nexusDir, "wallet.enc");
16318
16723
  if (existsSync23(walletPath))
16319
16724
  return;
16320
16725
  let address;
@@ -16338,7 +16743,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16338
16743
  const cipher = createCipheriv("aes-256-gcm", key, iv);
16339
16744
  let enc = cipher.update(privKeyHex, "utf8", "hex");
16340
16745
  enc += cipher.final("hex");
16341
- const x402KeyPath = join35(this.nexusDir, "x402-wallet.key");
16746
+ const x402KeyPath = join36(this.nexusDir, "x402-wallet.key");
16342
16747
  const x402Fh = await fsOpen(x402KeyPath, "w", 384);
16343
16748
  await x402Fh.writeFile("0x" + privKeyHex);
16344
16749
  await x402Fh.close();
@@ -16398,12 +16803,12 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16398
16803
  // ---------------------------------------------------------------------------
16399
16804
  async doLedgerStatus() {
16400
16805
  await this.ensureDir();
16401
- const ledgerPath = join35(this.nexusDir, "ledger.jsonl");
16806
+ const ledgerPath = join36(this.nexusDir, "ledger.jsonl");
16402
16807
  if (!existsSync23(ledgerPath)) {
16403
16808
  return "No ledger entries. Earnings and spending will be tracked here after x402 transactions.";
16404
16809
  }
16405
16810
  try {
16406
- const raw = await readFile17(ledgerPath, "utf8");
16811
+ const raw = await readFile18(ledgerPath, "utf8");
16407
16812
  const entries = raw.trim().split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
16408
16813
  if (entries.length === 0) {
16409
16814
  return "Ledger is empty. No transactions recorded.";
@@ -16440,11 +16845,11 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16440
16845
  }
16441
16846
  }
16442
16847
  async getLedgerSummary() {
16443
- const ledgerPath = join35(this.nexusDir, "ledger.jsonl");
16848
+ const ledgerPath = join36(this.nexusDir, "ledger.jsonl");
16444
16849
  if (!existsSync23(ledgerPath))
16445
16850
  return null;
16446
16851
  try {
16447
- const raw = await readFile17(ledgerPath, "utf8");
16852
+ const raw = await readFile18(ledgerPath, "utf8");
16448
16853
  const entries = raw.trim().split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
16449
16854
  let totalEarned = 0n, totalSpent = 0n;
16450
16855
  for (const e of entries) {
@@ -16465,25 +16870,25 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16465
16870
  }
16466
16871
  async appendLedger(entry) {
16467
16872
  await this.ensureDir();
16468
- const ledgerPath = join35(this.nexusDir, "ledger.jsonl");
16873
+ const ledgerPath = join36(this.nexusDir, "ledger.jsonl");
16469
16874
  const line = JSON.stringify(entry) + "\n";
16470
- await writeFile16(ledgerPath, existsSync23(ledgerPath) ? await readFile17(ledgerPath, "utf8") + line : line);
16875
+ await writeFile17(ledgerPath, existsSync23(ledgerPath) ? await readFile18(ledgerPath, "utf8") + line : line);
16471
16876
  }
16472
16877
  // ---------------------------------------------------------------------------
16473
16878
  // Step 4: Budget Policy — Spending limits and auto-approve thresholds
16474
16879
  // ---------------------------------------------------------------------------
16475
16880
  async loadBudget() {
16476
- const budgetPath = join35(this.nexusDir, "budget.json");
16881
+ const budgetPath = join36(this.nexusDir, "budget.json");
16477
16882
  if (!existsSync23(budgetPath))
16478
16883
  return null;
16479
16884
  try {
16480
- return JSON.parse(await readFile17(budgetPath, "utf8"));
16885
+ return JSON.parse(await readFile18(budgetPath, "utf8"));
16481
16886
  } catch {
16482
16887
  return null;
16483
16888
  }
16484
16889
  }
16485
16890
  async ensureDefaultBudget() {
16486
- const budgetPath = join35(this.nexusDir, "budget.json");
16891
+ const budgetPath = join36(this.nexusDir, "budget.json");
16487
16892
  if (existsSync23(budgetPath))
16488
16893
  return;
16489
16894
  const defaultBudget = {
@@ -16504,7 +16909,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16504
16909
  deniedPeers: []
16505
16910
  };
16506
16911
  await this.ensureDir();
16507
- await writeFile16(budgetPath, JSON.stringify(defaultBudget, null, 2));
16912
+ await writeFile17(budgetPath, JSON.stringify(defaultBudget, null, 2));
16508
16913
  }
16509
16914
  async doBudgetStatus() {
16510
16915
  await this.ensureDir();
@@ -16553,17 +16958,17 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16553
16958
  if (changes.length === 0) {
16554
16959
  return "No budget parameters provided. Use daily_limit, per_invoke_max, or auto_approve_below.";
16555
16960
  }
16556
- const budgetPath = join35(this.nexusDir, "budget.json");
16557
- await writeFile16(budgetPath, JSON.stringify(budget, null, 2));
16961
+ const budgetPath = join36(this.nexusDir, "budget.json");
16962
+ await writeFile17(budgetPath, JSON.stringify(budget, null, 2));
16558
16963
  return `Budget updated: ${changes.join(", ")}`;
16559
16964
  }
16560
16965
  async getTodaySpending() {
16561
- const ledgerPath = join35(this.nexusDir, "ledger.jsonl");
16966
+ const ledgerPath = join36(this.nexusDir, "ledger.jsonl");
16562
16967
  if (!existsSync23(ledgerPath))
16563
16968
  return 0;
16564
16969
  try {
16565
16970
  const todayPrefix = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
16566
- const raw = await readFile17(ledgerPath, "utf8");
16971
+ const raw = await readFile18(ledgerPath, "utf8");
16567
16972
  let total = 0;
16568
16973
  for (const line of raw.trim().split("\n")) {
16569
16974
  if (!line.trim())
@@ -16602,10 +17007,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16602
17007
  if (todaySpent + amountUsdc > budget.dailyLimitUsdc) {
16603
17008
  return { allowed: false, reason: `Would exceed daily limit ($${((todaySpent + amountUsdc) / 1e6).toFixed(6)} > $${(budget.dailyLimitUsdc / 1e6).toFixed(6)})` };
16604
17009
  }
16605
- const walletPath = join35(this.nexusDir, "wallet.enc");
17010
+ const walletPath = join36(this.nexusDir, "wallet.enc");
16606
17011
  if (existsSync23(walletPath)) {
16607
17012
  try {
16608
- const w = JSON.parse(await readFile17(walletPath, "utf8"));
17013
+ const w = JSON.parse(await readFile18(walletPath, "utf8"));
16609
17014
  if (w.version === 2 && w.address) {
16610
17015
  const balance = await this.queryUsdcBalance(w.address, w.chainId || 8453);
16611
17016
  if (balance !== null && Number(balance) < budget.circuitBreakerUsdc) {
@@ -16633,10 +17038,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16633
17038
  const budgetResult = await this.checkBudget(amountSmallest, "transfer:direct", targetAddress);
16634
17039
  if (!budgetResult.allowed)
16635
17040
  return `BLOCKED by budget policy: ${budgetResult.reason}`;
16636
- const walletPath = join35(this.nexusDir, "wallet.enc");
17041
+ const walletPath = join36(this.nexusDir, "wallet.enc");
16637
17042
  if (!existsSync23(walletPath))
16638
17043
  throw new Error("No wallet. Use wallet_create first.");
16639
- const w = JSON.parse(await readFile17(walletPath, "utf8"));
17044
+ const w = JSON.parse(await readFile18(walletPath, "utf8"));
16640
17045
  if (!w.encryptedKey)
16641
17046
  throw new Error("User-managed wallet cannot spend (no private key)");
16642
17047
  const salt = Buffer.from(w.salt, "hex");
@@ -16694,7 +17099,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16694
17099
  capability: "transfer:direct",
16695
17100
  note: "signed, awaiting submission"
16696
17101
  });
16697
- const proofFile = join35(this.nexusDir, "pending-transfer.json");
17102
+ const proofFile = join36(this.nexusDir, "pending-transfer.json");
16698
17103
  const proof = {
16699
17104
  from: account.address,
16700
17105
  to: targetAddress,
@@ -16707,7 +17112,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16707
17112
  usdcContract: USDC_ADDRESS,
16708
17113
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
16709
17114
  };
16710
- await writeFile16(proofFile, JSON.stringify(proof, null, 2));
17115
+ await writeFile17(proofFile, JSON.stringify(proof, null, 2));
16711
17116
  return [
16712
17117
  `Transfer signed (EIP-3009 TransferWithAuthorization):`,
16713
17118
  ` From: ${account.address}`,
@@ -16736,10 +17141,10 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16736
17141
  throw new Error("prompt is required");
16737
17142
  const estimatedTokens = Math.ceil(prompt.length / 4) + 1e3;
16738
17143
  let estimatedCostSmallest = 0;
16739
- const pricingPath = join35(this.nexusDir, "pricing.json");
17144
+ const pricingPath = join36(this.nexusDir, "pricing.json");
16740
17145
  if (existsSync23(pricingPath)) {
16741
17146
  try {
16742
- const pricing = JSON.parse(await readFile17(pricingPath, "utf8"));
17147
+ const pricing = JSON.parse(await readFile18(pricingPath, "utf8"));
16743
17148
  const modelPricing = (pricing.models || []).find((m) => m.model === model || m.model.startsWith(model.split(":")[0]));
16744
17149
  if (modelPricing?.pricing?.input_per_1m_tokens > 0) {
16745
17150
  estimatedCostSmallest = Math.ceil(estimatedTokens / 1e6 * modelPricing.pricing.input_per_1m_tokens * 1e6);
@@ -16856,7 +17261,7 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
16856
17261
  const bar = (s) => "\u2588".repeat(Math.round(s / 5)) + "\u2591".repeat(20 - Math.round(s / 5));
16857
17262
  const mem = vramMb > 24e3 ? 95 : vramMb > 16e3 ? 80 : vramMb > 8e3 ? 60 : vramMb > 0 ? 40 : 20;
16858
17263
  await this.ensureDir();
16859
- await writeFile16(join35(this.nexusDir, "inference-proof.json"), JSON.stringify({
17264
+ await writeFile17(join36(this.nexusDir, "inference-proof.json"), JSON.stringify({
16860
17265
  modelName,
16861
17266
  gpuName,
16862
17267
  vramMb,
@@ -17563,6 +17968,7 @@ __export(dist_exports, {
17563
17968
  DesktopClickTool: () => DesktopClickTool,
17564
17969
  DesktopDescribeTool: () => DesktopDescribeTool,
17565
17970
  DiagnosticTool: () => DiagnosticTool,
17971
+ EmbeddingStoreTool: () => EmbeddingStoreTool,
17566
17972
  ExplorationCultureTool: () => ExplorationCultureTool,
17567
17973
  ExploreToolsTool: () => ExploreToolsTool,
17568
17974
  FactoryTool: () => FactoryTool,
@@ -17679,6 +18085,7 @@ var init_dist2 = __esm({
17679
18085
  init_identity_kernel();
17680
18086
  init_reflection_integrity();
17681
18087
  init_exploration_culture();
18088
+ init_embedding_store();
17682
18089
  init_structured_read();
17683
18090
  init_vision();
17684
18091
  init_desktop_click();
@@ -18379,12 +18786,12 @@ var init_dist3 = __esm({
18379
18786
 
18380
18787
  // packages/orchestrator/dist/promptLoader.js
18381
18788
  import { readFileSync as readFileSync18, existsSync as existsSync25 } from "node:fs";
18382
- import { join as join36, dirname as dirname12 } from "node:path";
18789
+ import { join as join37, dirname as dirname12 } from "node:path";
18383
18790
  import { fileURLToPath as fileURLToPath7 } from "node:url";
18384
18791
  function loadPrompt(promptPath, vars) {
18385
18792
  let content = cache.get(promptPath);
18386
18793
  if (content === void 0) {
18387
- const fullPath = join36(PROMPTS_DIR, promptPath);
18794
+ const fullPath = join37(PROMPTS_DIR, promptPath);
18388
18795
  if (!existsSync25(fullPath)) {
18389
18796
  throw new Error(`Prompt file not found: ${fullPath}`);
18390
18797
  }
@@ -18401,7 +18808,7 @@ var init_promptLoader = __esm({
18401
18808
  "use strict";
18402
18809
  __filename = fileURLToPath7(import.meta.url);
18403
18810
  __dirname4 = dirname12(__filename);
18404
- PROMPTS_DIR = join36(__dirname4, "..", "prompts");
18811
+ PROMPTS_DIR = join37(__dirname4, "..", "prompts");
18405
18812
  cache = /* @__PURE__ */ new Map();
18406
18813
  }
18407
18814
  });
@@ -18764,8 +19171,8 @@ var init_code_retriever = __esm({
18764
19171
  });
18765
19172
  }
18766
19173
  async getFileContent(filePath, startLine, endLine) {
18767
- const { readFile: readFile22 } = await import("node:fs/promises");
18768
- const content = await readFile22(filePath, "utf-8");
19174
+ const { readFile: readFile23 } = await import("node:fs/promises");
19175
+ const content = await readFile23(filePath, "utf-8");
18769
19176
  if (startLine === void 0)
18770
19177
  return content;
18771
19178
  const lines = content.split("\n");
@@ -18780,8 +19187,8 @@ var init_code_retriever = __esm({
18780
19187
  // packages/retrieval/dist/lexicalSearch.js
18781
19188
  import { execFile as execFile5 } from "node:child_process";
18782
19189
  import { promisify as promisify4 } from "node:util";
18783
- import { readFile as readFile18, readdir as readdir4, stat as stat3 } from "node:fs/promises";
18784
- import { join as join37, extname as extname7 } from "node:path";
19190
+ import { readFile as readFile19, readdir as readdir5, stat as stat3 } from "node:fs/promises";
19191
+ import { join as join38, extname as extname7 } from "node:path";
18785
19192
  async function searchByPath(pathPattern, options) {
18786
19193
  const allFiles = await collectFiles(options.rootDir, options.includeGlobs ?? DEFAULT_INCLUDE_GLOBS, options.excludeGlobs ?? DEFAULT_EXCLUDE_GLOBS);
18787
19194
  const pattern = options.caseInsensitive ? pathPattern.toLowerCase() : pathPattern;
@@ -18886,7 +19293,7 @@ async function searchWithNodeFallback(pattern, kind, options) {
18886
19293
  if (results.length >= maxMatches)
18887
19294
  break;
18888
19295
  try {
18889
- const content = await readFile18(filePath, "utf-8");
19296
+ const content = await readFile19(filePath, "utf-8");
18890
19297
  const contentLines = content.split("\n");
18891
19298
  for (let i = 0; i < contentLines.length; i++) {
18892
19299
  if (results.length >= maxMatches)
@@ -18914,7 +19321,7 @@ async function collectFiles(rootDir, includeGlobs, excludeGlobs) {
18914
19321
  async function walkForFiles(rootDir, dir, excludeGlobs, results) {
18915
19322
  let entries;
18916
19323
  try {
18917
- entries = await readdir4(dir, { withFileTypes: true, encoding: "utf-8" });
19324
+ entries = await readdir5(dir, { withFileTypes: true, encoding: "utf-8" });
18918
19325
  } catch {
18919
19326
  return;
18920
19327
  }
@@ -18923,7 +19330,7 @@ async function walkForFiles(rootDir, dir, excludeGlobs, results) {
18923
19330
  continue;
18924
19331
  if (excludeGlobs.some((g) => entry.name === g || matchesGlob(entry.name, g)))
18925
19332
  continue;
18926
- const absPath = join37(dir, entry.name);
19333
+ const absPath = join38(dir, entry.name);
18927
19334
  if (entry.isDirectory()) {
18928
19335
  await walkForFiles(rootDir, absPath, excludeGlobs, results);
18929
19336
  } else if (entry.isFile()) {
@@ -19229,8 +19636,8 @@ var init_graphExpand = __esm({
19229
19636
  });
19230
19637
 
19231
19638
  // packages/retrieval/dist/snippetPacker.js
19232
- import { readFile as readFile19 } from "node:fs/promises";
19233
- import { join as join38 } from "node:path";
19639
+ import { readFile as readFile20 } from "node:fs/promises";
19640
+ import { join as join39 } from "node:path";
19234
19641
  async function packSnippets(requests, opts = {}) {
19235
19642
  const maxTokens = opts.maxTokens ?? DEFAULT_MAX_TOKENS;
19236
19643
  const contextLines = opts.contextLines ?? DEFAULT_CONTEXT_LINES;
@@ -19256,10 +19663,10 @@ async function packSnippets(requests, opts = {}) {
19256
19663
  return { packed, dropped, totalTokens };
19257
19664
  }
19258
19665
  async function extractSnippet(req, repoRoot, contextLines = DEFAULT_CONTEXT_LINES) {
19259
- const absPath = req.filePath.startsWith("/") ? req.filePath : join38(repoRoot, req.filePath);
19666
+ const absPath = req.filePath.startsWith("/") ? req.filePath : join39(repoRoot, req.filePath);
19260
19667
  let content;
19261
19668
  try {
19262
- content = await readFile19(absPath, "utf-8");
19669
+ content = await readFile20(absPath, "utf-8");
19263
19670
  } catch {
19264
19671
  return null;
19265
19672
  }
@@ -21850,8 +22257,8 @@ ${marker}` : marker);
21850
22257
  return;
21851
22258
  try {
21852
22259
  const { mkdirSync: mkdirSync21, writeFileSync: writeFileSync20 } = __require("node:fs");
21853
- const { join: join62 } = __require("node:path");
21854
- const sessionDir = join62(this._workingDirectory, ".oa", "session", this._sessionId);
22260
+ const { join: join63 } = __require("node:path");
22261
+ const sessionDir = join63(this._workingDirectory, ".oa", "session", this._sessionId);
21855
22262
  mkdirSync21(sessionDir, { recursive: true });
21856
22263
  const checkpoint = {
21857
22264
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -21864,7 +22271,7 @@ ${marker}` : marker);
21864
22271
  memexEntryCount: this._memexArchive.size,
21865
22272
  fileRegistrySize: this._fileRegistry.size
21866
22273
  };
21867
- writeFileSync20(join62(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
22274
+ writeFileSync20(join63(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
21868
22275
  } catch {
21869
22276
  }
21870
22277
  }
@@ -23132,7 +23539,7 @@ ${transcript}`
23132
23539
  // packages/orchestrator/dist/nexusBackend.js
23133
23540
  import { existsSync as existsSync26, statSync as statSync9, openSync, readSync, closeSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "node:fs";
23134
23541
  import { watch as fsWatch } from "node:fs";
23135
- import { join as join39 } from "node:path";
23542
+ import { join as join40 } from "node:path";
23136
23543
  import { tmpdir as tmpdir7 } from "node:os";
23137
23544
  import { randomBytes as randomBytes8 } from "node:crypto";
23138
23545
  var NexusAgenticBackend;
@@ -23282,7 +23689,7 @@ var init_nexusBackend = __esm({
23282
23689
  * Falls back to unary + word-split if streaming setup fails.
23283
23690
  */
23284
23691
  async *chatCompletionStream(request) {
23285
- const streamFile = join39(tmpdir7(), `nexus-stream-${randomBytes8(6).toString("hex")}.jsonl`);
23692
+ const streamFile = join40(tmpdir7(), `nexus-stream-${randomBytes8(6).toString("hex")}.jsonl`);
23286
23693
  writeFileSync8(streamFile, "", "utf8");
23287
23694
  const daemonArgs = {
23288
23695
  model: this.model,
@@ -24319,7 +24726,7 @@ __export(listen_exports, {
24319
24726
  });
24320
24727
  import { spawn as spawn15, execSync as execSync23 } from "node:child_process";
24321
24728
  import { existsSync as existsSync27, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readdirSync as readdirSync6 } from "node:fs";
24322
- import { join as join40, dirname as dirname13 } from "node:path";
24729
+ import { join as join41, dirname as dirname13 } from "node:path";
24323
24730
  import { homedir as homedir8 } from "node:os";
24324
24731
  import { fileURLToPath as fileURLToPath8 } from "node:url";
24325
24732
  import { EventEmitter } from "node:events";
@@ -24405,12 +24812,12 @@ function findMicCaptureCommand() {
24405
24812
  function findLiveWhisperScript() {
24406
24813
  const thisDir = dirname13(fileURLToPath8(import.meta.url));
24407
24814
  const candidates = [
24408
- join40(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
24409
- join40(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
24410
- join40(thisDir, "../../execution/scripts/live-whisper.py"),
24815
+ join41(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
24816
+ join41(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
24817
+ join41(thisDir, "../../execution/scripts/live-whisper.py"),
24411
24818
  // npm install layout — scripts bundled alongside dist
24412
- join40(thisDir, "../scripts/live-whisper.py"),
24413
- join40(thisDir, "../../scripts/live-whisper.py")
24819
+ join41(thisDir, "../scripts/live-whisper.py"),
24820
+ join41(thisDir, "../../scripts/live-whisper.py")
24414
24821
  ];
24415
24822
  for (const p of candidates) {
24416
24823
  if (existsSync27(p))
@@ -24423,8 +24830,8 @@ function findLiveWhisperScript() {
24423
24830
  stdio: ["pipe", "pipe", "pipe"]
24424
24831
  }).trim();
24425
24832
  const candidates2 = [
24426
- join40(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
24427
- join40(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
24833
+ join41(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
24834
+ join41(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
24428
24835
  ];
24429
24836
  for (const p of candidates2) {
24430
24837
  if (existsSync27(p))
@@ -24432,11 +24839,11 @@ function findLiveWhisperScript() {
24432
24839
  }
24433
24840
  } catch {
24434
24841
  }
24435
- const nvmBase = join40(homedir8(), ".nvm", "versions", "node");
24842
+ const nvmBase = join41(homedir8(), ".nvm", "versions", "node");
24436
24843
  if (existsSync27(nvmBase)) {
24437
24844
  try {
24438
24845
  for (const ver of readdirSync6(nvmBase)) {
24439
- const p = join40(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
24846
+ const p = join41(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
24440
24847
  if (existsSync27(p))
24441
24848
  return p;
24442
24849
  }
@@ -24455,7 +24862,7 @@ function ensureTranscribeCliBackground() {
24455
24862
  timeout: 5e3,
24456
24863
  stdio: ["pipe", "pipe", "pipe"]
24457
24864
  }).trim();
24458
- if (existsSync27(join40(globalRoot, "transcribe-cli", "dist", "index.js"))) {
24865
+ if (existsSync27(join41(globalRoot, "transcribe-cli", "dist", "index.js"))) {
24459
24866
  return true;
24460
24867
  }
24461
24868
  } catch {
@@ -24678,24 +25085,24 @@ var init_listen = __esm({
24678
25085
  timeout: 5e3,
24679
25086
  stdio: ["pipe", "pipe", "pipe"]
24680
25087
  }).trim();
24681
- const tcPath = join40(globalRoot, "transcribe-cli");
24682
- if (existsSync27(join40(tcPath, "dist", "index.js"))) {
25088
+ const tcPath = join41(globalRoot, "transcribe-cli");
25089
+ if (existsSync27(join41(tcPath, "dist", "index.js"))) {
24683
25090
  const { createRequire: createRequire4 } = await import("node:module");
24684
25091
  const req = createRequire4(import.meta.url);
24685
- return req(join40(tcPath, "dist", "index.js"));
25092
+ return req(join41(tcPath, "dist", "index.js"));
24686
25093
  }
24687
25094
  } catch {
24688
25095
  }
24689
- const nvmBase = join40(homedir8(), ".nvm", "versions", "node");
25096
+ const nvmBase = join41(homedir8(), ".nvm", "versions", "node");
24690
25097
  if (existsSync27(nvmBase)) {
24691
25098
  try {
24692
25099
  const { readdirSync: readdirSync17 } = await import("node:fs");
24693
25100
  for (const ver of readdirSync17(nvmBase)) {
24694
- const tcPath = join40(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
24695
- if (existsSync27(join40(tcPath, "dist", "index.js"))) {
25101
+ const tcPath = join41(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
25102
+ if (existsSync27(join41(tcPath, "dist", "index.js"))) {
24696
25103
  const { createRequire: createRequire4 } = await import("node:module");
24697
25104
  const req = createRequire4(import.meta.url);
24698
- return req(join40(tcPath, "dist", "index.js"));
25105
+ return req(join41(tcPath, "dist", "index.js"));
24699
25106
  }
24700
25107
  }
24701
25108
  } catch {
@@ -24977,9 +25384,9 @@ transcribe-cli error: ${transcribeCliError}` : "";
24977
25384
  });
24978
25385
  if (outputDir) {
24979
25386
  const { basename: basename16 } = await import("node:path");
24980
- const transcriptDir = join40(outputDir, ".oa", "transcripts");
25387
+ const transcriptDir = join41(outputDir, ".oa", "transcripts");
24981
25388
  mkdirSync8(transcriptDir, { recursive: true });
24982
- const outFile = join40(transcriptDir, `${basename16(filePath)}.txt`);
25389
+ const outFile = join41(transcriptDir, `${basename16(filePath)}.txt`);
24983
25390
  writeFileSync9(outFile, result.text, "utf-8");
24984
25391
  }
24985
25392
  return {
@@ -30337,7 +30744,7 @@ import { randomBytes as randomBytes9 } from "node:crypto";
30337
30744
  import { URL as URL2 } from "node:url";
30338
30745
  import { loadavg, cpus, totalmem, freemem } from "node:os";
30339
30746
  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";
30340
- import { join as join41 } from "node:path";
30747
+ import { join as join42 } from "node:path";
30341
30748
  function cleanForwardHeaders(raw, targetHost) {
30342
30749
  const out = {};
30343
30750
  for (const [key, value] of Object.entries(raw)) {
@@ -30365,7 +30772,7 @@ function fmtTokens(n) {
30365
30772
  }
30366
30773
  function readExposeState(stateDir) {
30367
30774
  try {
30368
- const path = join41(stateDir, STATE_FILE_NAME);
30775
+ const path = join42(stateDir, STATE_FILE_NAME);
30369
30776
  if (!existsSync28(path))
30370
30777
  return null;
30371
30778
  const raw = readFileSync19(path, "utf8");
@@ -30380,13 +30787,13 @@ function readExposeState(stateDir) {
30380
30787
  function writeExposeState(stateDir, state) {
30381
30788
  try {
30382
30789
  mkdirSync9(stateDir, { recursive: true });
30383
- writeFileSync10(join41(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
30790
+ writeFileSync10(join42(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
30384
30791
  } catch {
30385
30792
  }
30386
30793
  }
30387
30794
  function removeExposeState(stateDir) {
30388
30795
  try {
30389
- unlinkSync5(join41(stateDir, STATE_FILE_NAME));
30796
+ unlinkSync5(join42(stateDir, STATE_FILE_NAME));
30390
30797
  } catch {
30391
30798
  }
30392
30799
  }
@@ -30475,7 +30882,7 @@ async function collectSystemMetricsAsync() {
30475
30882
  }
30476
30883
  function readP2PExposeState(stateDir) {
30477
30884
  try {
30478
- const path = join41(stateDir, P2P_STATE_FILE_NAME);
30885
+ const path = join42(stateDir, P2P_STATE_FILE_NAME);
30479
30886
  if (!existsSync28(path))
30480
30887
  return null;
30481
30888
  const raw = readFileSync19(path, "utf8");
@@ -30490,13 +30897,13 @@ function readP2PExposeState(stateDir) {
30490
30897
  function writeP2PExposeState(stateDir, state) {
30491
30898
  try {
30492
30899
  mkdirSync9(stateDir, { recursive: true });
30493
- writeFileSync10(join41(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
30900
+ writeFileSync10(join42(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
30494
30901
  } catch {
30495
30902
  }
30496
30903
  }
30497
30904
  function removeP2PExposeState(stateDir) {
30498
30905
  try {
30499
- unlinkSync5(join41(stateDir, P2P_STATE_FILE_NAME));
30906
+ unlinkSync5(join42(stateDir, P2P_STATE_FILE_NAME));
30500
30907
  } catch {
30501
30908
  }
30502
30909
  }
@@ -31344,7 +31751,7 @@ ${this.formatConnectionInfo()}`);
31344
31751
  throw new Error(`Expose failed: ${exposeResult.error}`);
31345
31752
  }
31346
31753
  const nexusDir = this._nexusTool.getNexusDir();
31347
- const statusPath = join41(nexusDir, "status.json");
31754
+ const statusPath = join42(nexusDir, "status.json");
31348
31755
  for (let i = 0; i < 80; i++) {
31349
31756
  try {
31350
31757
  const raw = readFileSync19(statusPath, "utf8");
@@ -31378,7 +31785,7 @@ ${this.formatConnectionInfo()}`);
31378
31785
  });
31379
31786
  }
31380
31787
  try {
31381
- const invocDir = join41(nexusDir, "invocations");
31788
+ const invocDir = join42(nexusDir, "invocations");
31382
31789
  if (existsSync28(invocDir)) {
31383
31790
  this._prevInvocCount = readdirSync7(invocDir).filter((f) => f.endsWith(".json")).length;
31384
31791
  this._stats.totalRequests = this._prevInvocCount;
@@ -31408,7 +31815,7 @@ ${this.formatConnectionInfo()}`);
31408
31815
  if (!state)
31409
31816
  return null;
31410
31817
  const nexusDir = nexusTool.getNexusDir();
31411
- const statusPath = join41(nexusDir, "status.json");
31818
+ const statusPath = join42(nexusDir, "status.json");
31412
31819
  try {
31413
31820
  if (!existsSync28(statusPath)) {
31414
31821
  removeP2PExposeState(stateDir);
@@ -31467,7 +31874,7 @@ ${this.formatConnectionInfo()}`);
31467
31874
  let lastMeteringLineCount = 0;
31468
31875
  this._activityPollTimer = setInterval(() => {
31469
31876
  try {
31470
- const invocDir = join41(nexusDir, "invocations");
31877
+ const invocDir = join42(nexusDir, "invocations");
31471
31878
  if (!existsSync28(invocDir))
31472
31879
  return;
31473
31880
  const files = readdirSync7(invocDir).filter((f) => f.endsWith(".json"));
@@ -31483,13 +31890,13 @@ ${this.formatConnectionInfo()}`);
31483
31890
  let recentActive = 0;
31484
31891
  for (const f of files.slice(-10)) {
31485
31892
  try {
31486
- const st = statSync10(join41(invocDir, f));
31893
+ const st = statSync10(join42(invocDir, f));
31487
31894
  if (now - st.mtimeMs < 1e4)
31488
31895
  recentActive++;
31489
31896
  } catch {
31490
31897
  }
31491
31898
  }
31492
- const meteringFile = join41(nexusDir, "metering.jsonl");
31899
+ const meteringFile = join42(nexusDir, "metering.jsonl");
31493
31900
  let meteringLines = lastMeteringLineCount;
31494
31901
  try {
31495
31902
  if (existsSync28(meteringFile)) {
@@ -31519,7 +31926,7 @@ ${this.formatConnectionInfo()}`);
31519
31926
  this._activityPollTimer.unref();
31520
31927
  this._pollTimer = setInterval(() => {
31521
31928
  try {
31522
- const statusPath = join41(nexusDir, "status.json");
31929
+ const statusPath = join42(nexusDir, "status.json");
31523
31930
  if (existsSync28(statusPath)) {
31524
31931
  const status = JSON.parse(readFileSync19(statusPath, "utf8"));
31525
31932
  if (status.peerId && !this._peerId) {
@@ -31530,7 +31937,7 @@ ${this.formatConnectionInfo()}`);
31530
31937
  } catch {
31531
31938
  }
31532
31939
  try {
31533
- const invocDir = join41(nexusDir, "invocations");
31940
+ const invocDir = join42(nexusDir, "invocations");
31534
31941
  if (existsSync28(invocDir)) {
31535
31942
  const files = readdirSync7(invocDir);
31536
31943
  const invocCount = files.filter((f) => f.endsWith(".json")).length;
@@ -31542,7 +31949,7 @@ ${this.formatConnectionInfo()}`);
31542
31949
  } catch {
31543
31950
  }
31544
31951
  try {
31545
- const meteringFile = join41(nexusDir, "metering.jsonl");
31952
+ const meteringFile = join42(nexusDir, "metering.jsonl");
31546
31953
  if (existsSync28(meteringFile)) {
31547
31954
  const content = readFileSync19(meteringFile, "utf8");
31548
31955
  if (content.length > lastMeteringSize) {
@@ -31754,7 +32161,7 @@ var init_types = __esm({
31754
32161
  // packages/cli/dist/tui/p2p/secret-vault.js
31755
32162
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes10, scryptSync as scryptSync2, createHash as createHash2 } from "node:crypto";
31756
32163
  import { readFileSync as readFileSync20, writeFileSync as writeFileSync11, existsSync as existsSync29, mkdirSync as mkdirSync10 } from "node:fs";
31757
- import { join as join42, dirname as dirname14 } from "node:path";
32164
+ import { join as join43, dirname as dirname14 } from "node:path";
31758
32165
  var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
31759
32166
  var init_secret_vault = __esm({
31760
32167
  "packages/cli/dist/tui/p2p/secret-vault.js"() {
@@ -33091,13 +33498,13 @@ async function fetchPeerModels(peerId, authKey) {
33091
33498
  try {
33092
33499
  const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
33093
33500
  const { existsSync: existsSync45, readFileSync: readFileSync33 } = await import("node:fs");
33094
- const { join: join62 } = await import("node:path");
33501
+ const { join: join63 } = await import("node:path");
33095
33502
  const cwd4 = process.cwd();
33096
33503
  const nexusTool = new NexusTool2(cwd4);
33097
33504
  const nexusDir = nexusTool.getNexusDir();
33098
33505
  let isLocalPeer = false;
33099
33506
  try {
33100
- const statusPath = join62(nexusDir, "status.json");
33507
+ const statusPath = join63(nexusDir, "status.json");
33101
33508
  if (existsSync45(statusPath)) {
33102
33509
  const status = JSON.parse(readFileSync33(statusPath, "utf8"));
33103
33510
  if (status.peerId === peerId)
@@ -33106,7 +33513,7 @@ async function fetchPeerModels(peerId, authKey) {
33106
33513
  } catch {
33107
33514
  }
33108
33515
  if (isLocalPeer) {
33109
- const pricingPath = join62(nexusDir, "pricing.json");
33516
+ const pricingPath = join63(nexusDir, "pricing.json");
33110
33517
  if (existsSync45(pricingPath)) {
33111
33518
  try {
33112
33519
  const pricing = JSON.parse(readFileSync33(pricingPath, "utf8"));
@@ -33123,7 +33530,7 @@ async function fetchPeerModels(peerId, authKey) {
33123
33530
  }
33124
33531
  }
33125
33532
  }
33126
- const cachePath = join62(nexusDir, "peer-models-cache.json");
33533
+ const cachePath = join63(nexusDir, "peer-models-cache.json");
33127
33534
  if (existsSync45(cachePath)) {
33128
33535
  try {
33129
33536
  const cache4 = JSON.parse(readFileSync33(cachePath, "utf8"));
@@ -33241,7 +33648,7 @@ async function fetchPeerModels(peerId, authKey) {
33241
33648
  } catch {
33242
33649
  }
33243
33650
  if (isLocalPeer) {
33244
- const pricingPath = join62(nexusDir, "pricing.json");
33651
+ const pricingPath = join63(nexusDir, "pricing.json");
33245
33652
  if (existsSync45(pricingPath)) {
33246
33653
  try {
33247
33654
  const pricing = JSON.parse(readFileSync33(pricingPath, "utf8"));
@@ -33514,12 +33921,12 @@ var init_render2 = __esm({
33514
33921
 
33515
33922
  // packages/prompts/dist/promptLoader.js
33516
33923
  import { readFileSync as readFileSync21, existsSync as existsSync30 } from "node:fs";
33517
- import { join as join43, dirname as dirname15 } from "node:path";
33924
+ import { join as join44, dirname as dirname15 } from "node:path";
33518
33925
  import { fileURLToPath as fileURLToPath9 } from "node:url";
33519
33926
  function loadPrompt2(promptPath, vars) {
33520
33927
  let content = cache2.get(promptPath);
33521
33928
  if (content === void 0) {
33522
- const fullPath = join43(PROMPTS_DIR2, promptPath);
33929
+ const fullPath = join44(PROMPTS_DIR2, promptPath);
33523
33930
  if (!existsSync30(fullPath)) {
33524
33931
  throw new Error(`Prompt file not found: ${fullPath}`);
33525
33932
  }
@@ -33536,8 +33943,8 @@ var init_promptLoader2 = __esm({
33536
33943
  "use strict";
33537
33944
  __filename2 = fileURLToPath9(import.meta.url);
33538
33945
  __dirname5 = dirname15(__filename2);
33539
- devPath = join43(__dirname5, "..", "templates");
33540
- publishedPath = join43(__dirname5, "..", "prompts", "templates");
33946
+ devPath = join44(__dirname5, "..", "templates");
33947
+ publishedPath = join44(__dirname5, "..", "prompts", "templates");
33541
33948
  PROMPTS_DIR2 = existsSync30(devPath) ? devPath : publishedPath;
33542
33949
  cache2 = /* @__PURE__ */ new Map();
33543
33950
  }
@@ -33649,7 +34056,7 @@ var init_task_templates = __esm({
33649
34056
  });
33650
34057
 
33651
34058
  // packages/prompts/dist/index.js
33652
- import { join as join44, dirname as dirname16 } from "node:path";
34059
+ import { join as join45, dirname as dirname16 } from "node:path";
33653
34060
  import { fileURLToPath as fileURLToPath10 } from "node:url";
33654
34061
  var _dir, _packageRoot;
33655
34062
  var init_dist6 = __esm({
@@ -33660,21 +34067,21 @@ var init_dist6 = __esm({
33660
34067
  init_task_templates();
33661
34068
  init_render2();
33662
34069
  _dir = dirname16(fileURLToPath10(import.meta.url));
33663
- _packageRoot = join44(_dir, "..");
34070
+ _packageRoot = join45(_dir, "..");
33664
34071
  }
33665
34072
  });
33666
34073
 
33667
34074
  // packages/cli/dist/tui/oa-directory.js
33668
34075
  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";
33669
- import { join as join45, relative as relative2, basename as basename9, extname as extname8 } from "node:path";
34076
+ import { join as join46, relative as relative2, basename as basename9, extname as extname8 } from "node:path";
33670
34077
  import { homedir as homedir9 } from "node:os";
33671
34078
  function initOaDirectory(repoRoot) {
33672
- const oaPath = join45(repoRoot, OA_DIR);
34079
+ const oaPath = join46(repoRoot, OA_DIR);
33673
34080
  for (const sub of SUBDIRS) {
33674
- mkdirSync11(join45(oaPath, sub), { recursive: true });
34081
+ mkdirSync11(join46(oaPath, sub), { recursive: true });
33675
34082
  }
33676
34083
  try {
33677
- const gitignorePath = join45(repoRoot, ".gitignore");
34084
+ const gitignorePath = join46(repoRoot, ".gitignore");
33678
34085
  const settingsPattern = ".oa/settings.json";
33679
34086
  if (existsSync31(gitignorePath)) {
33680
34087
  const content = readFileSync22(gitignorePath, "utf-8");
@@ -33687,10 +34094,10 @@ function initOaDirectory(repoRoot) {
33687
34094
  return oaPath;
33688
34095
  }
33689
34096
  function hasOaDirectory(repoRoot) {
33690
- return existsSync31(join45(repoRoot, OA_DIR, "index"));
34097
+ return existsSync31(join46(repoRoot, OA_DIR, "index"));
33691
34098
  }
33692
34099
  function loadProjectSettings(repoRoot) {
33693
- const settingsPath = join45(repoRoot, OA_DIR, "settings.json");
34100
+ const settingsPath = join46(repoRoot, OA_DIR, "settings.json");
33694
34101
  try {
33695
34102
  if (existsSync31(settingsPath)) {
33696
34103
  return JSON.parse(readFileSync22(settingsPath, "utf-8"));
@@ -33700,14 +34107,14 @@ function loadProjectSettings(repoRoot) {
33700
34107
  return {};
33701
34108
  }
33702
34109
  function saveProjectSettings(repoRoot, settings) {
33703
- const oaPath = join45(repoRoot, OA_DIR);
34110
+ const oaPath = join46(repoRoot, OA_DIR);
33704
34111
  mkdirSync11(oaPath, { recursive: true });
33705
34112
  const existing = loadProjectSettings(repoRoot);
33706
34113
  const merged = { ...existing, ...settings };
33707
- writeFileSync12(join45(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
34114
+ writeFileSync12(join46(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
33708
34115
  }
33709
34116
  function loadGlobalSettings() {
33710
- const settingsPath = join45(homedir9(), ".open-agents", "settings.json");
34117
+ const settingsPath = join46(homedir9(), ".open-agents", "settings.json");
33711
34118
  try {
33712
34119
  if (existsSync31(settingsPath)) {
33713
34120
  return JSON.parse(readFileSync22(settingsPath, "utf-8"));
@@ -33717,11 +34124,11 @@ function loadGlobalSettings() {
33717
34124
  return {};
33718
34125
  }
33719
34126
  function saveGlobalSettings(settings) {
33720
- const dir = join45(homedir9(), ".open-agents");
34127
+ const dir = join46(homedir9(), ".open-agents");
33721
34128
  mkdirSync11(dir, { recursive: true });
33722
34129
  const existing = loadGlobalSettings();
33723
34130
  const merged = { ...existing, ...settings };
33724
- writeFileSync12(join45(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
34131
+ writeFileSync12(join46(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
33725
34132
  }
33726
34133
  function resolveSettings(repoRoot) {
33727
34134
  const global = loadGlobalSettings();
@@ -33736,7 +34143,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
33736
34143
  while (dir && !visited.has(dir)) {
33737
34144
  visited.add(dir);
33738
34145
  for (const name of CONTEXT_FILES) {
33739
- const filePath = join45(dir, name);
34146
+ const filePath = join46(dir, name);
33740
34147
  const normalizedName = name.toLowerCase();
33741
34148
  if (existsSync31(filePath) && !seen.has(filePath)) {
33742
34149
  seen.add(filePath);
@@ -33755,7 +34162,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
33755
34162
  }
33756
34163
  }
33757
34164
  }
33758
- const projectMap = join45(dir, OA_DIR, "context", "project-map.md");
34165
+ const projectMap = join46(dir, OA_DIR, "context", "project-map.md");
33759
34166
  if (existsSync31(projectMap) && !seen.has(projectMap)) {
33760
34167
  seen.add(projectMap);
33761
34168
  try {
@@ -33771,7 +34178,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
33771
34178
  } catch {
33772
34179
  }
33773
34180
  }
33774
- const parent = join45(dir, "..");
34181
+ const parent = join46(dir, "..");
33775
34182
  if (parent === dir)
33776
34183
  break;
33777
34184
  dir = parent;
@@ -33789,7 +34196,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
33789
34196
  return found;
33790
34197
  }
33791
34198
  function readIndexMeta(repoRoot) {
33792
- const metaPath = join45(repoRoot, OA_DIR, "index", "meta.json");
34199
+ const metaPath = join46(repoRoot, OA_DIR, "index", "meta.json");
33793
34200
  try {
33794
34201
  return JSON.parse(readFileSync22(metaPath, "utf-8"));
33795
34202
  } catch {
@@ -33842,28 +34249,28 @@ ${tree}\`\`\`
33842
34249
  sections.push("");
33843
34250
  }
33844
34251
  const content = sections.join("\n");
33845
- const contextDir = join45(repoRoot, OA_DIR, "context");
34252
+ const contextDir = join46(repoRoot, OA_DIR, "context");
33846
34253
  mkdirSync11(contextDir, { recursive: true });
33847
- writeFileSync12(join45(contextDir, "project-map.md"), content, "utf-8");
34254
+ writeFileSync12(join46(contextDir, "project-map.md"), content, "utf-8");
33848
34255
  return content;
33849
34256
  }
33850
34257
  function saveSession(repoRoot, session) {
33851
- const historyDir = join45(repoRoot, OA_DIR, "history");
34258
+ const historyDir = join46(repoRoot, OA_DIR, "history");
33852
34259
  mkdirSync11(historyDir, { recursive: true });
33853
- writeFileSync12(join45(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
34260
+ writeFileSync12(join46(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
33854
34261
  }
33855
34262
  function loadRecentSessions(repoRoot, limit = 5) {
33856
- const historyDir = join45(repoRoot, OA_DIR, "history");
34263
+ const historyDir = join46(repoRoot, OA_DIR, "history");
33857
34264
  if (!existsSync31(historyDir))
33858
34265
  return [];
33859
34266
  try {
33860
34267
  const files = readdirSync8(historyDir).filter((f) => f.endsWith(".json") && f !== "pending-task.json").map((f) => {
33861
- const stat5 = statSync11(join45(historyDir, f));
34268
+ const stat5 = statSync11(join46(historyDir, f));
33862
34269
  return { file: f, mtime: stat5.mtimeMs };
33863
34270
  }).sort((a, b) => b.mtime - a.mtime).slice(0, limit);
33864
34271
  return files.map((f) => {
33865
34272
  try {
33866
- return JSON.parse(readFileSync22(join45(historyDir, f.file), "utf-8"));
34273
+ return JSON.parse(readFileSync22(join46(historyDir, f.file), "utf-8"));
33867
34274
  } catch {
33868
34275
  return null;
33869
34276
  }
@@ -33873,12 +34280,12 @@ function loadRecentSessions(repoRoot, limit = 5) {
33873
34280
  }
33874
34281
  }
33875
34282
  function savePendingTask(repoRoot, task) {
33876
- const historyDir = join45(repoRoot, OA_DIR, "history");
34283
+ const historyDir = join46(repoRoot, OA_DIR, "history");
33877
34284
  mkdirSync11(historyDir, { recursive: true });
33878
- writeFileSync12(join45(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
34285
+ writeFileSync12(join46(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
33879
34286
  }
33880
34287
  function loadPendingTask(repoRoot) {
33881
- const filePath = join45(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
34288
+ const filePath = join46(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
33882
34289
  try {
33883
34290
  if (!existsSync31(filePath))
33884
34291
  return null;
@@ -33893,9 +34300,9 @@ function loadPendingTask(repoRoot) {
33893
34300
  }
33894
34301
  }
33895
34302
  function saveSessionContext(repoRoot, entry) {
33896
- const contextDir = join45(repoRoot, OA_DIR, "context");
34303
+ const contextDir = join46(repoRoot, OA_DIR, "context");
33897
34304
  mkdirSync11(contextDir, { recursive: true });
33898
- const filePath = join45(contextDir, CONTEXT_SAVE_FILE);
34305
+ const filePath = join46(contextDir, CONTEXT_SAVE_FILE);
33899
34306
  let ctx;
33900
34307
  try {
33901
34308
  if (existsSync31(filePath)) {
@@ -33914,7 +34321,7 @@ function saveSessionContext(repoRoot, entry) {
33914
34321
  writeFileSync12(filePath, JSON.stringify(ctx, null, 2) + "\n", "utf-8");
33915
34322
  }
33916
34323
  function loadSessionContext(repoRoot) {
33917
- const filePath = join45(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
34324
+ const filePath = join46(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
33918
34325
  try {
33919
34326
  if (!existsSync31(filePath))
33920
34327
  return null;
@@ -33965,7 +34372,7 @@ function detectManifests(repoRoot) {
33965
34372
  { file: "docker-compose.yaml", type: "Docker Compose" }
33966
34373
  ];
33967
34374
  for (const check of checks) {
33968
- const filePath = join45(repoRoot, check.file);
34375
+ const filePath = join46(repoRoot, check.file);
33969
34376
  if (existsSync31(filePath)) {
33970
34377
  let name;
33971
34378
  if (check.nameField) {
@@ -33999,7 +34406,7 @@ function findKeyFiles(repoRoot) {
33999
34406
  { pattern: "CLAUDE.md", description: "Claude Code context" }
34000
34407
  ];
34001
34408
  for (const check of checks) {
34002
- if (existsSync31(join45(repoRoot, check.pattern))) {
34409
+ if (existsSync31(join46(repoRoot, check.pattern))) {
34003
34410
  keyFiles.push({ path: check.pattern, description: check.description });
34004
34411
  }
34005
34412
  }
@@ -34025,12 +34432,12 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
34025
34432
  if (entry.isDirectory()) {
34026
34433
  let fileCount = 0;
34027
34434
  try {
34028
- fileCount = readdirSync8(join45(root, entry.name)).filter((f) => !f.startsWith(".")).length;
34435
+ fileCount = readdirSync8(join46(root, entry.name)).filter((f) => !f.startsWith(".")).length;
34029
34436
  } catch {
34030
34437
  }
34031
34438
  result += `${prefix}${connector}${entry.name}/ (${fileCount})
34032
34439
  `;
34033
- result += buildDirTree(join45(root, entry.name), maxDepth, childPrefix, depth + 1);
34440
+ result += buildDirTree(join46(root, entry.name), maxDepth, childPrefix, depth + 1);
34034
34441
  } else if (depth < maxDepth) {
34035
34442
  result += `${prefix}${connector}${entry.name}
34036
34443
  `;
@@ -34050,7 +34457,7 @@ function loadUsageFile(filePath) {
34050
34457
  return { records: [] };
34051
34458
  }
34052
34459
  function saveUsageFile(filePath, data) {
34053
- const dir = join45(filePath, "..");
34460
+ const dir = join46(filePath, "..");
34054
34461
  mkdirSync11(dir, { recursive: true });
34055
34462
  writeFileSync12(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
34056
34463
  }
@@ -34080,15 +34487,15 @@ function recordUsage(kind, value, opts) {
34080
34487
  }
34081
34488
  saveUsageFile(filePath, data);
34082
34489
  };
34083
- update(join45(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
34490
+ update(join46(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
34084
34491
  if (opts?.repoRoot) {
34085
- update(join45(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
34492
+ update(join46(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
34086
34493
  }
34087
34494
  }
34088
34495
  function loadUsageHistory(kind, repoRoot) {
34089
- const globalPath = join45(homedir9(), ".open-agents", USAGE_HISTORY_FILE);
34496
+ const globalPath = join46(homedir9(), ".open-agents", USAGE_HISTORY_FILE);
34090
34497
  const globalData = loadUsageFile(globalPath);
34091
- const localData = repoRoot ? loadUsageFile(join45(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
34498
+ const localData = repoRoot ? loadUsageFile(join46(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
34092
34499
  const map = /* @__PURE__ */ new Map();
34093
34500
  for (const r of globalData.records) {
34094
34501
  if (r.kind !== kind)
@@ -34119,9 +34526,9 @@ function deleteUsageRecord(kind, value, repoRoot) {
34119
34526
  saveUsageFile(filePath, data);
34120
34527
  }
34121
34528
  };
34122
- remove(join45(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
34529
+ remove(join46(homedir9(), ".open-agents", USAGE_HISTORY_FILE));
34123
34530
  if (repoRoot) {
34124
- remove(join45(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
34531
+ remove(join46(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
34125
34532
  }
34126
34533
  }
34127
34534
  var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
@@ -34172,7 +34579,7 @@ import * as readline from "node:readline";
34172
34579
  import { execSync as execSync25, spawn as spawn18, exec as exec2 } from "node:child_process";
34173
34580
  import { promisify as promisify5 } from "node:util";
34174
34581
  import { existsSync as existsSync32, writeFileSync as writeFileSync13, readFileSync as readFileSync23, appendFileSync as appendFileSync2, mkdirSync as mkdirSync12 } from "node:fs";
34175
- import { join as join46 } from "node:path";
34582
+ import { join as join47 } from "node:path";
34176
34583
  import { homedir as homedir10, platform } from "node:os";
34177
34584
  function detectSystemSpecs() {
34178
34585
  let totalRamGB = 0;
@@ -35213,9 +35620,9 @@ async function doSetup(config, rl) {
35213
35620
  `PARAMETER num_predict ${numPredict}`,
35214
35621
  `PARAMETER stop "<|endoftext|>"`
35215
35622
  ].join("\n");
35216
- const modelDir2 = join46(homedir10(), ".open-agents", "models");
35623
+ const modelDir2 = join47(homedir10(), ".open-agents", "models");
35217
35624
  mkdirSync12(modelDir2, { recursive: true });
35218
- const modelfilePath = join46(modelDir2, `Modelfile.${customName}`);
35625
+ const modelfilePath = join47(modelDir2, `Modelfile.${customName}`);
35219
35626
  writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
35220
35627
  process.stdout.write(` ${c2.dim("Creating model...")} `);
35221
35628
  execSync25(`ollama create ${customName} -f ${modelfilePath}`, {
@@ -35261,7 +35668,7 @@ async function isModelAvailable(config) {
35261
35668
  }
35262
35669
  function isFirstRun() {
35263
35670
  try {
35264
- return !existsSync32(join46(homedir10(), ".open-agents", "config.json"));
35671
+ return !existsSync32(join47(homedir10(), ".open-agents", "config.json"));
35265
35672
  } catch {
35266
35673
  return true;
35267
35674
  }
@@ -35298,7 +35705,7 @@ function detectPkgManager() {
35298
35705
  return null;
35299
35706
  }
35300
35707
  function getVenvDir() {
35301
- return join46(homedir10(), ".open-agents", "venv");
35708
+ return join47(homedir10(), ".open-agents", "venv");
35302
35709
  }
35303
35710
  function hasVenvModule() {
35304
35711
  try {
@@ -35310,7 +35717,7 @@ function hasVenvModule() {
35310
35717
  }
35311
35718
  function ensureVenv(log) {
35312
35719
  const venvDir = getVenvDir();
35313
- const venvPip = join46(venvDir, "bin", "pip");
35720
+ const venvPip = join47(venvDir, "bin", "pip");
35314
35721
  if (existsSync32(venvPip))
35315
35722
  return venvDir;
35316
35723
  log("Creating Python venv for vision deps...");
@@ -35323,9 +35730,9 @@ function ensureVenv(log) {
35323
35730
  return null;
35324
35731
  }
35325
35732
  try {
35326
- mkdirSync12(join46(homedir10(), ".open-agents"), { recursive: true });
35733
+ mkdirSync12(join47(homedir10(), ".open-agents"), { recursive: true });
35327
35734
  execSync25(`python3 -m venv "${venvDir}"`, { stdio: "pipe", timeout: 3e4 });
35328
- execSync25(`"${join46(venvDir, "bin", "pip")}" install --upgrade pip`, {
35735
+ execSync25(`"${join47(venvDir, "bin", "pip")}" install --upgrade pip`, {
35329
35736
  stdio: "pipe",
35330
35737
  timeout: 6e4
35331
35738
  });
@@ -35516,11 +35923,11 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
35516
35923
  }
35517
35924
  }
35518
35925
  const venvDir = getVenvDir();
35519
- const venvBin = join46(venvDir, "bin");
35520
- const venvMoondream = join46(venvBin, "moondream-station");
35926
+ const venvBin = join47(venvDir, "bin");
35927
+ const venvMoondream = join47(venvBin, "moondream-station");
35521
35928
  const venv = ensureVenv(log);
35522
35929
  if (venv && !hasCmd("moondream-station") && !existsSync32(venvMoondream)) {
35523
- const venvPip = join46(venvBin, "pip");
35930
+ const venvPip = join47(venvBin, "pip");
35524
35931
  log("Installing moondream-station in ~/.open-agents/venv...");
35525
35932
  try {
35526
35933
  execSync25(`"${venvPip}" install moondream-station`, { stdio: "pipe", timeout: 3e5 });
@@ -35541,8 +35948,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
35541
35948
  }
35542
35949
  }
35543
35950
  if (venv) {
35544
- const venvPython = join46(venvBin, "python");
35545
- const venvPip2 = join46(venvBin, "pip");
35951
+ const venvPython = join47(venvBin, "python");
35952
+ const venvPip2 = join47(venvBin, "pip");
35546
35953
  let ocrStackInstalled = false;
35547
35954
  try {
35548
35955
  execSync25(`"${venvPython}" -c "import cv2, pytesseract, numpy, PIL"`, { stdio: "pipe", timeout: 1e4 });
@@ -35686,9 +36093,9 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
35686
36093
  `PARAMETER num_predict ${numPredict}`,
35687
36094
  `PARAMETER stop "<|endoftext|>"`
35688
36095
  ].join("\n");
35689
- const modelDir2 = join46(homedir10(), ".open-agents", "models");
36096
+ const modelDir2 = join47(homedir10(), ".open-agents", "models");
35690
36097
  mkdirSync12(modelDir2, { recursive: true });
35691
- const modelfilePath = join46(modelDir2, `Modelfile.${customName}`);
36098
+ const modelfilePath = join47(modelDir2, `Modelfile.${customName}`);
35692
36099
  writeFileSync13(modelfilePath, modelfileContent + "\n", "utf8");
35693
36100
  await execAsync(`ollama create ${customName} -f ${modelfilePath}`, {
35694
36101
  timeout: 12e4
@@ -35763,8 +36170,8 @@ async function ensureNeovim() {
35763
36170
  const platform5 = process.platform;
35764
36171
  const arch = process.arch;
35765
36172
  if (platform5 === "linux") {
35766
- const binDir = join46(homedir10(), ".local", "bin");
35767
- const nvimDest = join46(binDir, "nvim");
36173
+ const binDir = join47(homedir10(), ".local", "bin");
36174
+ const nvimDest = join47(binDir, "nvim");
35768
36175
  try {
35769
36176
  mkdirSync12(binDir, { recursive: true });
35770
36177
  } catch {
@@ -35835,7 +36242,7 @@ async function ensureNeovim() {
35835
36242
  }
35836
36243
  function ensurePathInShellRc(binDir) {
35837
36244
  const shell = process.env.SHELL ?? "";
35838
- const rcFile = shell.includes("zsh") ? join46(homedir10(), ".zshrc") : join46(homedir10(), ".bashrc");
36245
+ const rcFile = shell.includes("zsh") ? join47(homedir10(), ".zshrc") : join47(homedir10(), ".bashrc");
35839
36246
  try {
35840
36247
  const rcContent = existsSync32(rcFile) ? readFileSync23(rcFile, "utf8") : "";
35841
36248
  if (rcContent.includes(binDir))
@@ -36607,7 +37014,7 @@ var init_drop_panel = __esm({
36607
37014
  // packages/cli/dist/tui/neovim-mode.js
36608
37015
  import { existsSync as existsSync34, unlinkSync as unlinkSync7 } from "node:fs";
36609
37016
  import { tmpdir as tmpdir8 } from "node:os";
36610
- import { join as join47 } from "node:path";
37017
+ import { join as join48 } from "node:path";
36611
37018
  import { execSync as execSync26 } from "node:child_process";
36612
37019
  function isNeovimActive() {
36613
37020
  return _state !== null && !_state.cleanedUp;
@@ -36655,7 +37062,7 @@ async function startNeovimMode(opts) {
36655
37062
  );
36656
37063
  } catch {
36657
37064
  }
36658
- const socketPath = join47(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
37065
+ const socketPath = join48(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
36659
37066
  try {
36660
37067
  if (existsSync34(socketPath))
36661
37068
  unlinkSync7(socketPath);
@@ -37007,7 +37414,7 @@ __export(voice_exports, {
37007
37414
  resetNarrationContext: () => resetNarrationContext
37008
37415
  });
37009
37416
  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";
37010
- import { join as join48 } from "node:path";
37417
+ import { join as join49 } from "node:path";
37011
37418
  import { homedir as homedir11, tmpdir as tmpdir9, platform as platform2 } from "node:os";
37012
37419
  import { execSync as execSync27, spawn as nodeSpawn } from "node:child_process";
37013
37420
  import { createRequire } from "node:module";
@@ -37029,34 +37436,34 @@ function listVoiceModels() {
37029
37436
  }));
37030
37437
  }
37031
37438
  function voiceDir() {
37032
- return join48(homedir11(), ".open-agents", "voice");
37439
+ return join49(homedir11(), ".open-agents", "voice");
37033
37440
  }
37034
37441
  function modelsDir() {
37035
- return join48(voiceDir(), "models");
37442
+ return join49(voiceDir(), "models");
37036
37443
  }
37037
37444
  function modelDir(id) {
37038
- return join48(modelsDir(), id);
37445
+ return join49(modelsDir(), id);
37039
37446
  }
37040
37447
  function modelOnnxPath(id) {
37041
- return join48(modelDir(id), "model.onnx");
37448
+ return join49(modelDir(id), "model.onnx");
37042
37449
  }
37043
37450
  function modelConfigPath(id) {
37044
- return join48(modelDir(id), "config.json");
37451
+ return join49(modelDir(id), "config.json");
37045
37452
  }
37046
37453
  function luxttsVenvDir() {
37047
- return join48(voiceDir(), "luxtts-venv");
37454
+ return join49(voiceDir(), "luxtts-venv");
37048
37455
  }
37049
37456
  function luxttsVenvPy() {
37050
- return platform2() === "win32" ? join48(luxttsVenvDir(), "Scripts", "python.exe") : join48(luxttsVenvDir(), "bin", "python3");
37457
+ return platform2() === "win32" ? join49(luxttsVenvDir(), "Scripts", "python.exe") : join49(luxttsVenvDir(), "bin", "python3");
37051
37458
  }
37052
37459
  function luxttsRepoDir() {
37053
- return join48(voiceDir(), "LuxTTS");
37460
+ return join49(voiceDir(), "LuxTTS");
37054
37461
  }
37055
37462
  function luxttsCloneRefsDir() {
37056
- return join48(voiceDir(), "clone-refs");
37463
+ return join49(voiceDir(), "clone-refs");
37057
37464
  }
37058
37465
  function luxttsInferScript() {
37059
- return join48(voiceDir(), "luxtts-infer.py");
37466
+ return join49(voiceDir(), "luxtts-infer.py");
37060
37467
  }
37061
37468
  function emotionToPitchBias(emotion, stark = false, autist = false) {
37062
37469
  if (autist)
@@ -37864,7 +38271,7 @@ var init_voice = __esm({
37864
38271
  const refsDir = luxttsCloneRefsDir();
37865
38272
  const targets = ["glados", "overwatch"];
37866
38273
  for (const modelId of targets) {
37867
- const refFile = join48(refsDir, `${modelId}-ref.wav`);
38274
+ const refFile = join49(refsDir, `${modelId}-ref.wav`);
37868
38275
  if (existsSync35(refFile))
37869
38276
  continue;
37870
38277
  try {
@@ -37944,7 +38351,7 @@ var init_voice = __esm({
37944
38351
  }
37945
38352
  p = p.replace(/\\ /g, " ");
37946
38353
  if (p.startsWith("~/") || p === "~") {
37947
- p = join48(homedir11(), p.slice(1));
38354
+ p = join49(homedir11(), p.slice(1));
37948
38355
  }
37949
38356
  if (!existsSync35(p)) {
37950
38357
  return `File not found: ${p}
@@ -37958,7 +38365,7 @@ var init_voice = __esm({
37958
38365
  const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
37959
38366
  const ts = Date.now().toString(36);
37960
38367
  const destFilename = `clone-${srcName}-${ts}.${ext}`;
37961
- const destPath = join48(refsDir, destFilename);
38368
+ const destPath = join49(refsDir, destFilename);
37962
38369
  try {
37963
38370
  const data = readFileSync24(audioPath);
37964
38371
  writeFileSync14(destPath, data);
@@ -38003,7 +38410,7 @@ var init_voice = __esm({
38003
38410
  const refsDir = luxttsCloneRefsDir();
38004
38411
  if (!existsSync35(refsDir))
38005
38412
  mkdirSync13(refsDir, { recursive: true });
38006
- const destPath = join48(refsDir, `${sourceModelId}-ref.wav`);
38413
+ const destPath = join49(refsDir, `${sourceModelId}-ref.wav`);
38007
38414
  const sampleRate = this.config?.audio?.sample_rate ?? 22050;
38008
38415
  this.writeWav(audioData, sampleRate, destPath);
38009
38416
  this.luxttsCloneRef = destPath;
@@ -38019,7 +38426,7 @@ var init_voice = __esm({
38019
38426
  // -------------------------------------------------------------------------
38020
38427
  /** Metadata file for friendly names of clone refs */
38021
38428
  static cloneMetaFile() {
38022
- return join48(luxttsCloneRefsDir(), "meta.json");
38429
+ return join49(luxttsCloneRefsDir(), "meta.json");
38023
38430
  }
38024
38431
  loadCloneMeta() {
38025
38432
  const p = _VoiceEngine.cloneMetaFile();
@@ -38053,7 +38460,7 @@ var init_voice = __esm({
38053
38460
  return _VoiceEngine.AUDIO_EXTS.has(ext);
38054
38461
  });
38055
38462
  return files.map((f) => {
38056
- const p = join48(dir, f);
38463
+ const p = join49(dir, f);
38057
38464
  let size = 0;
38058
38465
  try {
38059
38466
  size = statSync12(p).size;
@@ -38070,7 +38477,7 @@ var init_voice = __esm({
38070
38477
  }
38071
38478
  /** Delete a clone reference file by filename. Returns true if deleted. */
38072
38479
  deleteCloneRef(filename) {
38073
- const p = join48(luxttsCloneRefsDir(), filename);
38480
+ const p = join49(luxttsCloneRefsDir(), filename);
38074
38481
  if (!existsSync35(p))
38075
38482
  return false;
38076
38483
  try {
@@ -38095,7 +38502,7 @@ var init_voice = __esm({
38095
38502
  }
38096
38503
  /** Set the active clone reference by filename. */
38097
38504
  setActiveCloneRef(filename) {
38098
- const p = join48(luxttsCloneRefsDir(), filename);
38505
+ const p = join49(luxttsCloneRefsDir(), filename);
38099
38506
  if (!existsSync35(p))
38100
38507
  return `File not found: ${filename}`;
38101
38508
  this.luxttsCloneRef = p;
@@ -38381,7 +38788,7 @@ var init_voice = __esm({
38381
38788
  }
38382
38789
  this.onPCMOutput(Buffer.from(int16.buffer), sampleRate);
38383
38790
  }
38384
- const wavPath = join48(tmpdir9(), `oa-voice-${Date.now()}.wav`);
38791
+ const wavPath = join49(tmpdir9(), `oa-voice-${Date.now()}.wav`);
38385
38792
  this.writeWav(audioData, sampleRate, wavPath);
38386
38793
  await this.playWav(wavPath);
38387
38794
  try {
@@ -38724,7 +39131,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
38724
39131
  const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
38725
39132
  const mlxVoice = model.mlxVoice ?? "af_heart";
38726
39133
  const mlxLangCode = model.mlxLangCode ?? "a";
38727
- const wavPath = join48(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
39134
+ const wavPath = join49(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
38728
39135
  const pyScript = [
38729
39136
  "import sys, json",
38730
39137
  "from mlx_audio.tts import generate as tts_gen",
@@ -38792,7 +39199,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
38792
39199
  const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
38793
39200
  const mlxVoice = model.mlxVoice ?? "af_heart";
38794
39201
  const mlxLangCode = model.mlxLangCode ?? "a";
38795
- const wavPath = join48(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
39202
+ const wavPath = join49(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
38796
39203
  const pyScript = [
38797
39204
  "import sys, json",
38798
39205
  "from mlx_audio.tts import generate as tts_gen",
@@ -38903,7 +39310,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
38903
39310
  }
38904
39311
  }
38905
39312
  const repoDir = luxttsRepoDir();
38906
- if (!existsSync35(join48(repoDir, "zipvoice", "luxvoice.py"))) {
39313
+ if (!existsSync35(join49(repoDir, "zipvoice", "luxvoice.py"))) {
38907
39314
  renderInfo(" Cloning LuxTTS repository...");
38908
39315
  try {
38909
39316
  if (existsSync35(repoDir)) {
@@ -38952,7 +39359,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
38952
39359
  if (!existsSync35(refsDir))
38953
39360
  return;
38954
39361
  for (const name of ["custom-clone.wav", "custom-clone.mp3", "glados-ref.wav", "overwatch-ref.wav"]) {
38955
- const p = join48(refsDir, name);
39362
+ const p = join49(refsDir, name);
38956
39363
  if (existsSync35(p)) {
38957
39364
  this.luxttsCloneRef = p;
38958
39365
  return;
@@ -39149,7 +39556,7 @@ if __name__ == '__main__':
39149
39556
  const ready = await this.ensureLuxttsDaemon();
39150
39557
  if (!ready)
39151
39558
  return;
39152
- const wavPath = join48(tmpdir9(), `oa-luxtts-${Date.now()}.wav`);
39559
+ const wavPath = join49(tmpdir9(), `oa-luxtts-${Date.now()}.wav`);
39153
39560
  try {
39154
39561
  await this.luxttsRequest({
39155
39562
  action: "synthesize",
@@ -39223,7 +39630,7 @@ if __name__ == '__main__':
39223
39630
  const ready = await this.ensureLuxttsDaemon();
39224
39631
  if (!ready)
39225
39632
  return null;
39226
- const wavPath = join48(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
39633
+ const wavPath = join49(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
39227
39634
  try {
39228
39635
  await this.luxttsRequest({
39229
39636
  action: "synthesize",
@@ -39253,7 +39660,7 @@ if __name__ == '__main__':
39253
39660
  return;
39254
39661
  const arch = process.arch;
39255
39662
  mkdirSync13(voiceDir(), { recursive: true });
39256
- const pkgPath = join48(voiceDir(), "package.json");
39663
+ const pkgPath = join49(voiceDir(), "package.json");
39257
39664
  const expectedDeps = {
39258
39665
  "onnxruntime-node": "^1.21.0",
39259
39666
  "phonemizer": "^1.2.1"
@@ -39275,17 +39682,17 @@ if __name__ == '__main__':
39275
39682
  dependencies: expectedDeps
39276
39683
  }, null, 2));
39277
39684
  }
39278
- const voiceRequire = createRequire(join48(voiceDir(), "index.js"));
39685
+ const voiceRequire = createRequire(join49(voiceDir(), "index.js"));
39279
39686
  const probeOnnx = () => {
39280
39687
  try {
39281
- 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: join48(voiceDir(), "node_modules") } });
39688
+ 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: join49(voiceDir(), "node_modules") } });
39282
39689
  const output = result.toString().trim();
39283
39690
  return output === "OK";
39284
39691
  } catch {
39285
39692
  return false;
39286
39693
  }
39287
39694
  };
39288
- const onnxNodeModules = join48(voiceDir(), "node_modules", "onnxruntime-node");
39695
+ const onnxNodeModules = join49(voiceDir(), "node_modules", "onnxruntime-node");
39289
39696
  const onnxInstalled = existsSync35(onnxNodeModules);
39290
39697
  if (onnxInstalled && !probeOnnx()) {
39291
39698
  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.`);
@@ -41629,8 +42036,8 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
41629
42036
  if (models.length > 0) {
41630
42037
  try {
41631
42038
  const { writeFileSync: writeFileSync20, mkdirSync: mkdirSync21 } = await import("node:fs");
41632
- const { join: join62, dirname: dirname20 } = await import("node:path");
41633
- const cachePath = join62(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
42039
+ const { join: join63, dirname: dirname20 } = await import("node:path");
42040
+ const cachePath = join63(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
41634
42041
  mkdirSync21(dirname20(cachePath), { recursive: true });
41635
42042
  writeFileSync20(cachePath, JSON.stringify({
41636
42043
  peerId,
@@ -41831,14 +42238,14 @@ async function handleUpdate(subcommand, ctx) {
41831
42238
  try {
41832
42239
  const { createRequire: createRequire4 } = await import("node:module");
41833
42240
  const { fileURLToPath: fileURLToPath14 } = await import("node:url");
41834
- const { dirname: dirname20, join: join62 } = await import("node:path");
42241
+ const { dirname: dirname20, join: join63 } = await import("node:path");
41835
42242
  const { existsSync: existsSync45 } = await import("node:fs");
41836
42243
  const req = createRequire4(import.meta.url);
41837
42244
  const thisDir = dirname20(fileURLToPath14(import.meta.url));
41838
42245
  const candidates = [
41839
- join62(thisDir, "..", "package.json"),
41840
- join62(thisDir, "..", "..", "package.json"),
41841
- join62(thisDir, "..", "..", "..", "package.json")
42246
+ join63(thisDir, "..", "package.json"),
42247
+ join63(thisDir, "..", "..", "package.json"),
42248
+ join63(thisDir, "..", "..", "..", "package.json")
41842
42249
  ];
41843
42250
  for (const pkgPath of candidates) {
41844
42251
  if (existsSync45(pkgPath)) {
@@ -42556,7 +42963,7 @@ var init_commands = __esm({
42556
42963
 
42557
42964
  // packages/cli/dist/tui/project-context.js
42558
42965
  import { existsSync as existsSync36, readFileSync as readFileSync25, readdirSync as readdirSync10 } from "node:fs";
42559
- import { join as join49, basename as basename10 } from "node:path";
42966
+ import { join as join50, basename as basename10 } from "node:path";
42560
42967
  import { execSync as execSync28 } from "node:child_process";
42561
42968
  import { homedir as homedir12, platform as platform3, release } from "node:os";
42562
42969
  function getModelTier(modelName) {
@@ -42591,7 +42998,7 @@ function loadProjectMap(repoRoot) {
42591
42998
  if (!hasOaDirectory(repoRoot)) {
42592
42999
  initOaDirectory(repoRoot);
42593
43000
  }
42594
- const mapPath = join49(repoRoot, OA_DIR, "context", "project-map.md");
43001
+ const mapPath = join50(repoRoot, OA_DIR, "context", "project-map.md");
42595
43002
  if (existsSync36(mapPath)) {
42596
43003
  try {
42597
43004
  const content = readFileSync25(mapPath, "utf-8");
@@ -42635,17 +43042,17 @@ ${log}`);
42635
43042
  }
42636
43043
  function loadMemoryContext(repoRoot) {
42637
43044
  const sections = [];
42638
- const oaMemDir = join49(repoRoot, OA_DIR, "memory");
43045
+ const oaMemDir = join50(repoRoot, OA_DIR, "memory");
42639
43046
  const oaEntries = loadMemoryDir(oaMemDir, "project");
42640
43047
  if (oaEntries)
42641
43048
  sections.push(oaEntries);
42642
- const legacyMemDir = join49(repoRoot, ".open-agents", "memory");
43049
+ const legacyMemDir = join50(repoRoot, ".open-agents", "memory");
42643
43050
  if (legacyMemDir !== oaMemDir && existsSync36(legacyMemDir)) {
42644
43051
  const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
42645
43052
  if (legacyEntries)
42646
43053
  sections.push(legacyEntries);
42647
43054
  }
42648
- const globalMemDir = join49(homedir12(), ".open-agents", "memory");
43055
+ const globalMemDir = join50(homedir12(), ".open-agents", "memory");
42649
43056
  const globalEntries = loadMemoryDir(globalMemDir, "global");
42650
43057
  if (globalEntries)
42651
43058
  sections.push(globalEntries);
@@ -42659,7 +43066,7 @@ function loadMemoryDir(memDir, scope) {
42659
43066
  const files = readdirSync10(memDir).filter((f) => f.endsWith(".json"));
42660
43067
  for (const file of files.slice(0, 10)) {
42661
43068
  try {
42662
- const raw = readFileSync25(join49(memDir, file), "utf-8");
43069
+ const raw = readFileSync25(join50(memDir, file), "utf-8");
42663
43070
  const entries = JSON.parse(raw);
42664
43071
  const topic = basename10(file, ".json");
42665
43072
  const keys = Object.keys(entries);
@@ -43683,9 +44090,9 @@ var init_carousel = __esm({
43683
44090
 
43684
44091
  // packages/cli/dist/tui/carousel-descriptors.js
43685
44092
  import { existsSync as existsSync37, readFileSync as readFileSync26, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, readdirSync as readdirSync11 } from "node:fs";
43686
- import { join as join50, basename as basename11 } from "node:path";
44093
+ import { join as join51, basename as basename11 } from "node:path";
43687
44094
  function loadToolProfile(repoRoot) {
43688
- const filePath = join50(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
44095
+ const filePath = join51(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
43689
44096
  try {
43690
44097
  if (!existsSync37(filePath))
43691
44098
  return null;
@@ -43695,9 +44102,9 @@ function loadToolProfile(repoRoot) {
43695
44102
  }
43696
44103
  }
43697
44104
  function saveToolProfile(repoRoot, profile) {
43698
- const contextDir = join50(repoRoot, OA_DIR, "context");
44105
+ const contextDir = join51(repoRoot, OA_DIR, "context");
43699
44106
  mkdirSync14(contextDir, { recursive: true });
43700
- writeFileSync15(join50(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
44107
+ writeFileSync15(join51(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
43701
44108
  }
43702
44109
  function categorizeToolCall(toolName) {
43703
44110
  for (const cat of TOOL_CATEGORIES) {
@@ -43755,7 +44162,7 @@ function weightedColor(profile) {
43755
44162
  return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
43756
44163
  }
43757
44164
  function loadCachedDescriptors(repoRoot) {
43758
- const filePath = join50(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
44165
+ const filePath = join51(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
43759
44166
  try {
43760
44167
  if (!existsSync37(filePath))
43761
44168
  return null;
@@ -43766,14 +44173,14 @@ function loadCachedDescriptors(repoRoot) {
43766
44173
  }
43767
44174
  }
43768
44175
  function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
43769
- const contextDir = join50(repoRoot, OA_DIR, "context");
44176
+ const contextDir = join51(repoRoot, OA_DIR, "context");
43770
44177
  mkdirSync14(contextDir, { recursive: true });
43771
44178
  const cached = {
43772
44179
  phrases,
43773
44180
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
43774
44181
  sourceHash
43775
44182
  };
43776
- writeFileSync15(join50(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
44183
+ writeFileSync15(join51(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
43777
44184
  }
43778
44185
  function generateDescriptors(repoRoot) {
43779
44186
  const profile = loadToolProfile(repoRoot);
@@ -43821,7 +44228,7 @@ function generateDescriptors(repoRoot) {
43821
44228
  return phrases;
43822
44229
  }
43823
44230
  function extractFromPackageJson(repoRoot, tags) {
43824
- const pkgPath = join50(repoRoot, "package.json");
44231
+ const pkgPath = join51(repoRoot, "package.json");
43825
44232
  try {
43826
44233
  if (!existsSync37(pkgPath))
43827
44234
  return;
@@ -43869,7 +44276,7 @@ function extractFromManifests(repoRoot, tags) {
43869
44276
  { file: ".github/workflows", tag: "ci/cd" }
43870
44277
  ];
43871
44278
  for (const check of manifestChecks) {
43872
- if (existsSync37(join50(repoRoot, check.file))) {
44279
+ if (existsSync37(join51(repoRoot, check.file))) {
43873
44280
  tags.push(check.tag);
43874
44281
  }
43875
44282
  }
@@ -43891,7 +44298,7 @@ function extractFromSessions(repoRoot, tags) {
43891
44298
  }
43892
44299
  }
43893
44300
  function extractFromMemory(repoRoot, tags) {
43894
- const memoryDir = join50(repoRoot, OA_DIR, "memory");
44301
+ const memoryDir = join51(repoRoot, OA_DIR, "memory");
43895
44302
  try {
43896
44303
  if (!existsSync37(memoryDir))
43897
44304
  return;
@@ -43900,7 +44307,7 @@ function extractFromMemory(repoRoot, tags) {
43900
44307
  const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
43901
44308
  tags.push(topic);
43902
44309
  try {
43903
- const data = JSON.parse(readFileSync26(join50(memoryDir, file), "utf-8"));
44310
+ const data = JSON.parse(readFileSync26(join51(memoryDir, file), "utf-8"));
43904
44311
  if (data && typeof data === "object") {
43905
44312
  const keys = Object.keys(data).slice(0, 3);
43906
44313
  for (const key of keys) {
@@ -44523,10 +44930,10 @@ var init_stream_renderer = __esm({
44523
44930
 
44524
44931
  // packages/cli/dist/tui/edit-history.js
44525
44932
  import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync15 } from "node:fs";
44526
- import { join as join51 } from "node:path";
44933
+ import { join as join52 } from "node:path";
44527
44934
  function createEditHistoryLogger(repoRoot, sessionId) {
44528
- const historyDir = join51(repoRoot, ".oa", "history");
44529
- const logPath = join51(historyDir, "edits.jsonl");
44935
+ const historyDir = join52(repoRoot, ".oa", "history");
44936
+ const logPath = join52(historyDir, "edits.jsonl");
44530
44937
  try {
44531
44938
  mkdirSync15(historyDir, { recursive: true });
44532
44939
  } catch {
@@ -44638,12 +45045,12 @@ var init_edit_history = __esm({
44638
45045
 
44639
45046
  // packages/cli/dist/tui/promptLoader.js
44640
45047
  import { readFileSync as readFileSync27, existsSync as existsSync38 } from "node:fs";
44641
- import { join as join52, dirname as dirname17 } from "node:path";
45048
+ import { join as join53, dirname as dirname17 } from "node:path";
44642
45049
  import { fileURLToPath as fileURLToPath11 } from "node:url";
44643
45050
  function loadPrompt3(promptPath, vars) {
44644
45051
  let content = cache3.get(promptPath);
44645
45052
  if (content === void 0) {
44646
- const fullPath = join52(PROMPTS_DIR3, promptPath);
45053
+ const fullPath = join53(PROMPTS_DIR3, promptPath);
44647
45054
  if (!existsSync38(fullPath)) {
44648
45055
  throw new Error(`Prompt file not found: ${fullPath}`);
44649
45056
  }
@@ -44660,8 +45067,8 @@ var init_promptLoader3 = __esm({
44660
45067
  "use strict";
44661
45068
  __filename3 = fileURLToPath11(import.meta.url);
44662
45069
  __dirname6 = dirname17(__filename3);
44663
- devPath2 = join52(__dirname6, "..", "..", "prompts");
44664
- publishedPath2 = join52(__dirname6, "..", "prompts");
45070
+ devPath2 = join53(__dirname6, "..", "..", "prompts");
45071
+ publishedPath2 = join53(__dirname6, "..", "prompts");
44665
45072
  PROMPTS_DIR3 = existsSync38(devPath2) ? devPath2 : publishedPath2;
44666
45073
  cache3 = /* @__PURE__ */ new Map();
44667
45074
  }
@@ -44669,10 +45076,10 @@ var init_promptLoader3 = __esm({
44669
45076
 
44670
45077
  // packages/cli/dist/tui/dream-engine.js
44671
45078
  import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync16, readFileSync as readFileSync28, existsSync as existsSync39, cpSync, rmSync, readdirSync as readdirSync12 } from "node:fs";
44672
- import { join as join53, basename as basename12 } from "node:path";
45079
+ import { join as join54, basename as basename12 } from "node:path";
44673
45080
  import { execSync as execSync29 } from "node:child_process";
44674
45081
  function loadAutoresearchMemory(repoRoot) {
44675
- const memoryPath = join53(repoRoot, ".oa", "memory", "autoresearch.json");
45082
+ const memoryPath = join54(repoRoot, ".oa", "memory", "autoresearch.json");
44676
45083
  if (!existsSync39(memoryPath))
44677
45084
  return "";
44678
45085
  try {
@@ -44866,12 +45273,12 @@ var init_dream_engine = __esm({
44866
45273
  const content = String(args["content"] ?? "");
44867
45274
  if (!rawPath)
44868
45275
  return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
44869
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join53(this.autoresearchDir, basename12(rawPath)) : join53(this.autoresearchDir, rawPath);
45276
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join54(this.autoresearchDir, basename12(rawPath)) : join54(this.autoresearchDir, rawPath);
44870
45277
  if (!targetPath.startsWith(this.autoresearchDir)) {
44871
45278
  return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start };
44872
45279
  }
44873
45280
  try {
44874
- const dir = join53(targetPath, "..");
45281
+ const dir = join54(targetPath, "..");
44875
45282
  mkdirSync16(dir, { recursive: true });
44876
45283
  writeFileSync16(targetPath, content, "utf-8");
44877
45284
  return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
@@ -44901,7 +45308,7 @@ var init_dream_engine = __esm({
44901
45308
  const rawPath = String(args["path"] ?? "");
44902
45309
  const oldStr = String(args["old_string"] ?? "");
44903
45310
  const newStr = String(args["new_string"] ?? "");
44904
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join53(this.autoresearchDir, basename12(rawPath)) : join53(this.autoresearchDir, rawPath);
45311
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join54(this.autoresearchDir, basename12(rawPath)) : join54(this.autoresearchDir, rawPath);
44905
45312
  if (!targetPath.startsWith(this.autoresearchDir)) {
44906
45313
  return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start };
44907
45314
  }
@@ -44955,12 +45362,12 @@ var init_dream_engine = __esm({
44955
45362
  const content = String(args["content"] ?? "");
44956
45363
  if (!rawPath)
44957
45364
  return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
44958
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join53(this.dreamsDir, basename12(rawPath)) : join53(this.dreamsDir, rawPath);
45365
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join54(this.dreamsDir, basename12(rawPath)) : join54(this.dreamsDir, rawPath);
44959
45366
  if (!targetPath.startsWith(this.dreamsDir)) {
44960
45367
  return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start };
44961
45368
  }
44962
45369
  try {
44963
- const dir = join53(targetPath, "..");
45370
+ const dir = join54(targetPath, "..");
44964
45371
  mkdirSync16(dir, { recursive: true });
44965
45372
  writeFileSync16(targetPath, content, "utf-8");
44966
45373
  return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
@@ -44990,7 +45397,7 @@ var init_dream_engine = __esm({
44990
45397
  const rawPath = String(args["path"] ?? "");
44991
45398
  const oldStr = String(args["old_string"] ?? "");
44992
45399
  const newStr = String(args["new_string"] ?? "");
44993
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join53(this.dreamsDir, basename12(rawPath)) : join53(this.dreamsDir, rawPath);
45400
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join54(this.dreamsDir, basename12(rawPath)) : join54(this.dreamsDir, rawPath);
44994
45401
  if (!targetPath.startsWith(this.dreamsDir)) {
44995
45402
  return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start };
44996
45403
  }
@@ -45057,7 +45464,7 @@ var init_dream_engine = __esm({
45057
45464
  constructor(config, repoRoot) {
45058
45465
  this.config = config;
45059
45466
  this.repoRoot = repoRoot;
45060
- this.dreamsDir = join53(repoRoot, ".oa", "dreams");
45467
+ this.dreamsDir = join54(repoRoot, ".oa", "dreams");
45061
45468
  this.state = {
45062
45469
  mode: "default",
45063
45470
  active: false,
@@ -45141,7 +45548,7 @@ ${result.summary}`;
45141
45548
  if (mode !== "default" || cycle === totalCycles) {
45142
45549
  renderDreamContraction(cycle);
45143
45550
  const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
45144
- const summaryPath = join53(this.dreamsDir, `cycle-${cycle}-summary.md`);
45551
+ const summaryPath = join54(this.dreamsDir, `cycle-${cycle}-summary.md`);
45145
45552
  writeFileSync16(summaryPath, cycleSummary, "utf-8");
45146
45553
  }
45147
45554
  if (mode === "lucid" && !this.abortController.signal.aborted) {
@@ -45354,7 +45761,7 @@ After synthesis, call task_complete with the final prioritized summary.`, toolMo
45354
45761
  }
45355
45762
  /** Build role-specific tool sets for swarm agents */
45356
45763
  buildSwarmTools(role, _workspace) {
45357
- const autoresearchDir = join53(this.repoRoot, ".oa", "autoresearch");
45764
+ const autoresearchDir = join54(this.repoRoot, ".oa", "autoresearch");
45358
45765
  const taskComplete = this.createSwarmTaskCompleteTool(role);
45359
45766
  switch (role) {
45360
45767
  case "researcher": {
@@ -45718,7 +46125,7 @@ INSTRUCTIONS:
45718
46125
  2. Summarize the key learnings and next steps
45719
46126
 
45720
46127
  Call task_complete with a human-readable summary of the autoresearch session.`, workspace, onEvent);
45721
- const reportPath = join53(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
46128
+ const reportPath = join54(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
45722
46129
  const report = `# Autoresearch Swarm Report \u2014 Cycle ${cycleNum}
45723
46130
 
45724
46131
  **Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
@@ -45807,7 +46214,7 @@ ${summaryResult}
45807
46214
  }
45808
46215
  /** Save workspace backup for lucid mode */
45809
46216
  saveVersionCheckpoint(cycle) {
45810
- const checkpointDir = join53(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
46217
+ const checkpointDir = join54(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
45811
46218
  try {
45812
46219
  mkdirSync16(checkpointDir, { recursive: true });
45813
46220
  try {
@@ -45826,10 +46233,10 @@ ${summaryResult}
45826
46233
  encoding: "utf-8",
45827
46234
  timeout: 5e3
45828
46235
  }).trim();
45829
- writeFileSync16(join53(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
45830
- writeFileSync16(join53(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
45831
- writeFileSync16(join53(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
45832
- writeFileSync16(join53(checkpointDir, "checkpoint.json"), JSON.stringify({
46236
+ writeFileSync16(join54(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
46237
+ writeFileSync16(join54(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
46238
+ writeFileSync16(join54(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
46239
+ writeFileSync16(join54(checkpointDir, "checkpoint.json"), JSON.stringify({
45833
46240
  cycle,
45834
46241
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
45835
46242
  gitHash,
@@ -45837,7 +46244,7 @@ ${summaryResult}
45837
46244
  }, null, 2), "utf-8");
45838
46245
  renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
45839
46246
  } catch {
45840
- writeFileSync16(join53(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
46247
+ writeFileSync16(join54(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
45841
46248
  renderInfo(`Checkpoint saved: cycle ${cycle} (no git)`);
45842
46249
  }
45843
46250
  } catch (err) {
@@ -45895,14 +46302,14 @@ ${files.map((f) => `- [\`${f}\`](./${f})`).join("\n")}
45895
46302
  ---
45896
46303
  *Auto-generated by open-agents dream engine*
45897
46304
  `;
45898
- writeFileSync16(join53(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
46305
+ writeFileSync16(join54(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
45899
46306
  } catch {
45900
46307
  }
45901
46308
  }
45902
46309
  /** Save dream state for resume/inspection */
45903
46310
  saveDreamState() {
45904
46311
  try {
45905
- writeFileSync16(join53(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
46312
+ writeFileSync16(join54(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
45906
46313
  } catch {
45907
46314
  }
45908
46315
  }
@@ -46277,7 +46684,7 @@ var init_bless_engine = __esm({
46277
46684
 
46278
46685
  // packages/cli/dist/tui/dmn-engine.js
46279
46686
  import { existsSync as existsSync40, readFileSync as readFileSync29, writeFileSync as writeFileSync17, mkdirSync as mkdirSync17, readdirSync as readdirSync13, unlinkSync as unlinkSync9 } from "node:fs";
46280
- import { join as join54, basename as basename13 } from "node:path";
46687
+ import { join as join55, basename as basename13 } from "node:path";
46281
46688
  function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
46282
46689
  const competenceReport = competence.length > 0 ? competence.map((c3) => {
46283
46690
  const rate = c3.attempts > 0 ? Math.round(c3.successes / c3.attempts * 100) : 0;
@@ -46390,8 +46797,8 @@ var init_dmn_engine = __esm({
46390
46797
  constructor(config, repoRoot) {
46391
46798
  this.config = config;
46392
46799
  this.repoRoot = repoRoot;
46393
- this.stateDir = join54(repoRoot, ".oa", "dmn");
46394
- this.historyDir = join54(repoRoot, ".oa", "dmn", "cycles");
46800
+ this.stateDir = join55(repoRoot, ".oa", "dmn");
46801
+ this.historyDir = join55(repoRoot, ".oa", "dmn", "cycles");
46395
46802
  mkdirSync17(this.historyDir, { recursive: true });
46396
46803
  this.loadState();
46397
46804
  }
@@ -46981,8 +47388,8 @@ OUTPUT: Call task_complete with JSON:
46981
47388
  async gatherMemoryTopics() {
46982
47389
  const topics = [];
46983
47390
  const dirs = [
46984
- join54(this.repoRoot, ".oa", "memory"),
46985
- join54(this.repoRoot, ".open-agents", "memory")
47391
+ join55(this.repoRoot, ".oa", "memory"),
47392
+ join55(this.repoRoot, ".open-agents", "memory")
46986
47393
  ];
46987
47394
  for (const dir of dirs) {
46988
47395
  if (!existsSync40(dir))
@@ -47001,7 +47408,7 @@ OUTPUT: Call task_complete with JSON:
47001
47408
  }
47002
47409
  // ── State persistence ─────────────────────────────────────────────────
47003
47410
  loadState() {
47004
- const path = join54(this.stateDir, "state.json");
47411
+ const path = join55(this.stateDir, "state.json");
47005
47412
  if (existsSync40(path)) {
47006
47413
  try {
47007
47414
  this.state = JSON.parse(readFileSync29(path, "utf-8"));
@@ -47011,19 +47418,19 @@ OUTPUT: Call task_complete with JSON:
47011
47418
  }
47012
47419
  saveState() {
47013
47420
  try {
47014
- writeFileSync17(join54(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
47421
+ writeFileSync17(join55(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
47015
47422
  } catch {
47016
47423
  }
47017
47424
  }
47018
47425
  saveCycleResult(result) {
47019
47426
  try {
47020
47427
  const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
47021
- writeFileSync17(join54(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
47428
+ writeFileSync17(join55(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
47022
47429
  const files = readdirSync13(this.historyDir).filter((f) => f.startsWith("cycle-") && f.endsWith(".json")).sort();
47023
47430
  if (files.length > 50) {
47024
47431
  for (const old of files.slice(0, files.length - 50)) {
47025
47432
  try {
47026
- unlinkSync9(join54(this.historyDir, old));
47433
+ unlinkSync9(join55(this.historyDir, old));
47027
47434
  } catch {
47028
47435
  }
47029
47436
  }
@@ -47037,7 +47444,7 @@ OUTPUT: Call task_complete with JSON:
47037
47444
 
47038
47445
  // packages/cli/dist/tui/snr-engine.js
47039
47446
  import { existsSync as existsSync41, readdirSync as readdirSync14, readFileSync as readFileSync30 } from "node:fs";
47040
- import { join as join55, basename as basename14 } from "node:path";
47447
+ import { join as join56, basename as basename14 } from "node:path";
47041
47448
  function computeDPrime(signalScores, noiseScores) {
47042
47449
  if (signalScores.length === 0 || noiseScores.length === 0)
47043
47450
  return 0;
@@ -47277,8 +47684,8 @@ Call task_complete with the JSON array when done.`, onEvent)
47277
47684
  loadMemoryEntries(topics) {
47278
47685
  const entries = [];
47279
47686
  const dirs = [
47280
- join55(this.repoRoot, ".oa", "memory"),
47281
- join55(this.repoRoot, ".open-agents", "memory")
47687
+ join56(this.repoRoot, ".oa", "memory"),
47688
+ join56(this.repoRoot, ".open-agents", "memory")
47282
47689
  ];
47283
47690
  for (const dir of dirs) {
47284
47691
  if (!existsSync41(dir))
@@ -47290,7 +47697,7 @@ Call task_complete with the JSON array when done.`, onEvent)
47290
47697
  if (topics.length > 0 && !topics.includes(topic))
47291
47698
  continue;
47292
47699
  try {
47293
- const data = JSON.parse(readFileSync30(join55(dir, f), "utf-8"));
47700
+ const data = JSON.parse(readFileSync30(join56(dir, f), "utf-8"));
47294
47701
  for (const [key, val] of Object.entries(data)) {
47295
47702
  const value = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
47296
47703
  entries.push({ topic, key, value });
@@ -47858,7 +48265,7 @@ var init_tool_policy = __esm({
47858
48265
 
47859
48266
  // packages/cli/dist/tui/telegram-bridge.js
47860
48267
  import { mkdirSync as mkdirSync18, existsSync as existsSync42, unlinkSync as unlinkSync10, readdirSync as readdirSync15, statSync as statSync13 } from "node:fs";
47861
- import { join as join56, resolve as resolve28 } from "node:path";
48268
+ import { join as join57, resolve as resolve28 } from "node:path";
47862
48269
  import { writeFile as writeFileAsync } from "node:fs/promises";
47863
48270
  function convertMarkdownToTelegramHTML(md) {
47864
48271
  let html = md;
@@ -48623,7 +49030,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
48623
49030
  return null;
48624
49031
  const buffer = Buffer.from(await res.arrayBuffer());
48625
49032
  const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension}`;
48626
- const localPath = join56(this.mediaCacheDir, fileName);
49033
+ const localPath = join57(this.mediaCacheDir, fileName);
48627
49034
  await writeFileAsync(localPath, buffer);
48628
49035
  return localPath;
48629
49036
  } catch {
@@ -49274,7 +49681,7 @@ var init_braille_spinner = __esm({
49274
49681
  // packages/cli/dist/tui/system-metrics.js
49275
49682
  import { loadavg as loadavg3, cpus as cpus3, totalmem as totalmem4, freemem as freemem3, platform as platform4 } from "node:os";
49276
49683
  import { exec as exec3 } from "node:child_process";
49277
- import { readFile as readFile20 } from "node:fs/promises";
49684
+ import { readFile as readFile21 } from "node:fs/promises";
49278
49685
  function formatRate(bytesPerSec) {
49279
49686
  if (bytesPerSec < 1024)
49280
49687
  return `${Math.round(bytesPerSec)}B`;
@@ -49286,7 +49693,7 @@ function formatRate(bytesPerSec) {
49286
49693
  }
49287
49694
  async function readProcNetDev() {
49288
49695
  try {
49289
- const data = await readFile20("/proc/net/dev", "utf8");
49696
+ const data = await readFile21("/proc/net/dev", "utf8");
49290
49697
  let rxTotal = 0;
49291
49698
  let txTotal = 0;
49292
49699
  for (const line of data.split("\n")) {
@@ -51061,7 +51468,7 @@ var init_status_bar = __esm({
51061
51468
  import * as readline2 from "node:readline";
51062
51469
  import { Writable } from "node:stream";
51063
51470
  import { cwd } from "node:process";
51064
- import { resolve as resolve29, join as join57, dirname as dirname18, extname as extname10 } from "node:path";
51471
+ import { resolve as resolve29, join as join58, dirname as dirname18, extname as extname10 } from "node:path";
51065
51472
  import { createRequire as createRequire2 } from "node:module";
51066
51473
  import { fileURLToPath as fileURLToPath12 } from "node:url";
51067
51474
  import { readFileSync as readFileSync32, writeFileSync as writeFileSync18, appendFileSync as appendFileSync4, rmSync as rmSync2, readdirSync as readdirSync16, mkdirSync as mkdirSync19 } from "node:fs";
@@ -51085,9 +51492,9 @@ function getVersion3() {
51085
51492
  const require2 = createRequire2(import.meta.url);
51086
51493
  const thisDir = dirname18(fileURLToPath12(import.meta.url));
51087
51494
  const candidates = [
51088
- join57(thisDir, "..", "package.json"),
51089
- join57(thisDir, "..", "..", "package.json"),
51090
- join57(thisDir, "..", "..", "..", "package.json")
51495
+ join58(thisDir, "..", "package.json"),
51496
+ join58(thisDir, "..", "..", "package.json"),
51497
+ join58(thisDir, "..", "..", "..", "package.json")
51091
51498
  ];
51092
51499
  for (const pkgPath of candidates) {
51093
51500
  if (existsSync43(pkgPath)) {
@@ -51188,6 +51595,8 @@ function buildTools(repoRoot, config, contextWindowSize) {
51188
51595
  new ReflectionIntegrityTool(repoRoot),
51189
51596
  // Exploration & Culture — COHERE Layer 8 (ARCHE)
51190
51597
  new ExplorationCultureTool(repoRoot),
51598
+ // Embedding Store — COHERE Private Brain semantic retrieval
51599
+ new EmbeddingStoreTool(repoRoot),
51191
51600
  // Structured file reading (CSV, JSON, Markdown, binary detection)
51192
51601
  new StructuredReadTool(repoRoot),
51193
51602
  // Vision tools (Moondream — desktop awareness + point-and-click)
@@ -51307,15 +51716,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
51307
51716
  function gatherMemorySnippets(root) {
51308
51717
  const snippets = [];
51309
51718
  const dirs = [
51310
- join57(root, ".oa", "memory"),
51311
- join57(root, ".open-agents", "memory")
51719
+ join58(root, ".oa", "memory"),
51720
+ join58(root, ".open-agents", "memory")
51312
51721
  ];
51313
51722
  for (const dir of dirs) {
51314
51723
  if (!existsSync43(dir))
51315
51724
  continue;
51316
51725
  try {
51317
51726
  for (const f of readdirSync16(dir).filter((f2) => f2.endsWith(".json"))) {
51318
- const data = JSON.parse(readFileSync32(join57(dir, f), "utf-8"));
51727
+ const data = JSON.parse(readFileSync32(join58(dir, f), "utf-8"));
51319
51728
  for (const val of Object.values(data)) {
51320
51729
  const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
51321
51730
  if (v.length > 10)
@@ -51579,6 +51988,31 @@ ${context}` : prompt;
51579
51988
  });
51580
51989
  }
51581
51990
  }
51991
+ for (const tool of tools) {
51992
+ if ("setLlmScorer" in tool && typeof tool.setLlmScorer === "function") {
51993
+ tool.setLlmScorer(async (content, type) => {
51994
+ try {
51995
+ const response = await backend.chatCompletion({
51996
+ messages: [
51997
+ { role: "system", content: 'Score this memory candidate on 4 dimensions (0.0-1.0 each). Reply ONLY with JSON: {"novelty":N,"utility":N,"confidence":N,"identityRelevance":N}' },
51998
+ { role: "user", content: `Memory type: ${type}
51999
+ Content: ${content.slice(0, 500)}` }
52000
+ ],
52001
+ tools: [],
52002
+ temperature: 0,
52003
+ maxTokens: 100,
52004
+ timeoutMs: 15e3
52005
+ });
52006
+ const text = response.choices?.[0]?.message?.content ?? "";
52007
+ const match = text.match(/\{[^}]+\}/);
52008
+ if (match)
52009
+ return JSON.parse(match[0]);
52010
+ } catch {
52011
+ }
52012
+ return null;
52013
+ });
52014
+ }
52015
+ }
51582
52016
  for (const tool of tools) {
51583
52017
  if ("setHandleResolver" in tool && typeof tool.setHandleResolver === "function") {
51584
52018
  tool.setHandleResolver((handleId) => {
@@ -52364,7 +52798,7 @@ async function startInteractive(config, repoPath) {
52364
52798
  let p2pGateway = null;
52365
52799
  let peerMesh = null;
52366
52800
  let inferenceRouter = null;
52367
- const secretVault = new SecretVault(join57(repoRoot, ".oa", "vault.enc"));
52801
+ const secretVault = new SecretVault(join58(repoRoot, ".oa", "vault.enc"));
52368
52802
  let adminSessionKey = null;
52369
52803
  const callSubAgents = /* @__PURE__ */ new Map();
52370
52804
  const streamRenderer = new StreamRenderer();
@@ -52573,8 +53007,8 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
52573
53007
  const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
52574
53008
  return [hits, line];
52575
53009
  }
52576
- const HISTORY_DIR = join57(homedir13(), ".open-agents");
52577
- const HISTORY_FILE = join57(HISTORY_DIR, "repl-history");
53010
+ const HISTORY_DIR = join58(homedir13(), ".open-agents");
53011
+ const HISTORY_FILE = join58(HISTORY_DIR, "repl-history");
52578
53012
  const MAX_HISTORY_LINES = 500;
52579
53013
  let savedHistory = [];
52580
53014
  try {
@@ -52784,7 +53218,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
52784
53218
  } catch {
52785
53219
  }
52786
53220
  try {
52787
- const oaDir = join57(repoRoot, ".oa");
53221
+ const oaDir = join58(repoRoot, ".oa");
52788
53222
  const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
52789
53223
  onInfo: (msg) => writeContent(() => renderInfo(msg)),
52790
53224
  onError: (msg) => writeContent(() => renderWarning(msg))
@@ -52807,7 +53241,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
52807
53241
  } catch {
52808
53242
  }
52809
53243
  try {
52810
- const oaDir = join57(repoRoot, ".oa");
53244
+ const oaDir = join58(repoRoot, ".oa");
52811
53245
  const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
52812
53246
  onInfo: (msg) => writeContent(() => renderInfo(msg)),
52813
53247
  onError: (msg) => writeContent(() => renderWarning(msg))
@@ -53626,7 +54060,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
53626
54060
  kind,
53627
54061
  targetUrl,
53628
54062
  authKey,
53629
- stateDir: join57(repoRoot, ".oa"),
54063
+ stateDir: join58(repoRoot, ".oa"),
53630
54064
  passthrough: passthrough ?? false,
53631
54065
  loadbalance: loadbalance ?? false,
53632
54066
  endpointAuth: passthrough ? currentConfig.apiKey : void 0,
@@ -53674,7 +54108,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
53674
54108
  await tunnelGateway.stop();
53675
54109
  tunnelGateway = null;
53676
54110
  }
53677
- const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join57(repoRoot, ".oa") });
54111
+ const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join58(repoRoot, ".oa") });
53678
54112
  newTunnel.on("stats", (stats) => {
53679
54113
  statusBar.setExposeStatus({
53680
54114
  status: stats.status,
@@ -53936,7 +54370,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
53936
54370
  }
53937
54371
  },
53938
54372
  destroyProject() {
53939
- const oaPath = join57(repoRoot, OA_DIR);
54373
+ const oaPath = join58(repoRoot, OA_DIR);
53940
54374
  if (existsSync43(oaPath)) {
53941
54375
  try {
53942
54376
  rmSync2(oaPath, { recursive: true, force: true });
@@ -54869,9 +55303,9 @@ var init_run = __esm({
54869
55303
  // packages/indexer/dist/codebase-indexer.js
54870
55304
  import { glob } from "glob";
54871
55305
  import ignore from "ignore";
54872
- import { readFile as readFile21, stat as stat4 } from "node:fs/promises";
55306
+ import { readFile as readFile22, stat as stat4 } from "node:fs/promises";
54873
55307
  import { createHash as createHash4 } from "node:crypto";
54874
- import { join as join58, relative as relative3, extname as extname11, basename as basename15 } from "node:path";
55308
+ import { join as join59, relative as relative3, extname as extname11, basename as basename15 } from "node:path";
54875
55309
  var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
54876
55310
  var init_codebase_indexer = __esm({
54877
55311
  "packages/indexer/dist/codebase-indexer.js"() {
@@ -54915,7 +55349,7 @@ var init_codebase_indexer = __esm({
54915
55349
  const ig = ignore.default();
54916
55350
  if (this.config.respectGitignore) {
54917
55351
  try {
54918
- const gitignoreContent = await readFile21(join58(this.config.rootDir, ".gitignore"), "utf-8");
55352
+ const gitignoreContent = await readFile22(join59(this.config.rootDir, ".gitignore"), "utf-8");
54919
55353
  ig.add(gitignoreContent);
54920
55354
  } catch {
54921
55355
  }
@@ -54930,12 +55364,12 @@ var init_codebase_indexer = __esm({
54930
55364
  for (const relativePath of files) {
54931
55365
  if (ig.ignores(relativePath))
54932
55366
  continue;
54933
- const fullPath = join58(this.config.rootDir, relativePath);
55367
+ const fullPath = join59(this.config.rootDir, relativePath);
54934
55368
  try {
54935
55369
  const fileStat = await stat4(fullPath);
54936
55370
  if (fileStat.size > this.config.maxFileSize)
54937
55371
  continue;
54938
- const content = await readFile21(fullPath);
55372
+ const content = await readFile22(fullPath);
54939
55373
  const hash = createHash4("sha256").update(content).digest("hex");
54940
55374
  const ext = extname11(relativePath);
54941
55375
  indexed.push({
@@ -54976,7 +55410,7 @@ var init_codebase_indexer = __esm({
54976
55410
  if (!child) {
54977
55411
  child = {
54978
55412
  name: part,
54979
- path: join58(current.path, part),
55413
+ path: join59(current.path, part),
54980
55414
  type: "directory",
54981
55415
  children: []
54982
55416
  };
@@ -55317,7 +55751,7 @@ var config_exports = {};
55317
55751
  __export(config_exports, {
55318
55752
  configCommand: () => configCommand
55319
55753
  });
55320
- import { join as join59, resolve as resolve31 } from "node:path";
55754
+ import { join as join60, resolve as resolve31 } from "node:path";
55321
55755
  import { homedir as homedir14 } from "node:os";
55322
55756
  import { cwd as cwd3 } from "node:process";
55323
55757
  function redactIfSensitive(key, value) {
@@ -55400,7 +55834,7 @@ function handleShow(opts, config) {
55400
55834
  }
55401
55835
  }
55402
55836
  printSection("Config File");
55403
- printInfo(`~/.open-agents/config.json (${join59(homedir14(), ".open-agents", "config.json")})`);
55837
+ printInfo(`~/.open-agents/config.json (${join60(homedir14(), ".open-agents", "config.json")})`);
55404
55838
  printSection("Priority Chain");
55405
55839
  printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
55406
55840
  printInfo(" 2. Project .oa/settings.json (--local)");
@@ -55439,7 +55873,7 @@ function handleSet(opts, _config) {
55439
55873
  const coerced = coerceForSettings(key, value);
55440
55874
  saveProjectSettings(repoRoot, { [key]: coerced });
55441
55875
  printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value)}`);
55442
- printInfo(`Saved to ${join59(repoRoot, ".oa", "settings.json")}`);
55876
+ printInfo(`Saved to ${join60(repoRoot, ".oa", "settings.json")}`);
55443
55877
  printInfo("This override applies only when running in this workspace.");
55444
55878
  } catch (err) {
55445
55879
  printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
@@ -55698,7 +56132,7 @@ __export(eval_exports, {
55698
56132
  });
55699
56133
  import { tmpdir as tmpdir10 } from "node:os";
55700
56134
  import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync19 } from "node:fs";
55701
- import { join as join60 } from "node:path";
56135
+ import { join as join61 } from "node:path";
55702
56136
  async function evalCommand(opts, config) {
55703
56137
  const suiteName = opts.suite ?? "basic";
55704
56138
  const suite = SUITES[suiteName];
@@ -55823,9 +56257,9 @@ async function evalCommand(opts, config) {
55823
56257
  process.exit(failed > 0 ? 1 : 0);
55824
56258
  }
55825
56259
  function createTempEvalRepo() {
55826
- const dir = join60(tmpdir10(), `open-agents-eval-${Date.now()}`);
56260
+ const dir = join61(tmpdir10(), `open-agents-eval-${Date.now()}`);
55827
56261
  mkdirSync20(dir, { recursive: true });
55828
- writeFileSync19(join60(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
56262
+ writeFileSync19(join61(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
55829
56263
  return dir;
55830
56264
  }
55831
56265
  var BASIC_SUITE, FULL_SUITE, SUITES;
@@ -55885,7 +56319,7 @@ init_updater();
55885
56319
  import { parseArgs as nodeParseArgs2 } from "node:util";
55886
56320
  import { createRequire as createRequire3 } from "node:module";
55887
56321
  import { fileURLToPath as fileURLToPath13 } from "node:url";
55888
- import { dirname as dirname19, join as join61 } from "node:path";
56322
+ import { dirname as dirname19, join as join62 } from "node:path";
55889
56323
 
55890
56324
  // packages/cli/dist/cli.js
55891
56325
  import { createInterface } from "node:readline";
@@ -55992,7 +56426,7 @@ init_output();
55992
56426
  function getVersion4() {
55993
56427
  try {
55994
56428
  const require2 = createRequire3(import.meta.url);
55995
- const pkgPath = join61(dirname19(fileURLToPath13(import.meta.url)), "..", "package.json");
56429
+ const pkgPath = join62(dirname19(fileURLToPath13(import.meta.url)), "..", "package.json");
55996
56430
  const pkg = require2(pkgPath);
55997
56431
  return pkg.version;
55998
56432
  } catch {