open-agents-ai 0.186.5 → 0.186.6

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 +1058 -919
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13782,9 +13782,9 @@ print("${sentinel}")
13782
13782
  if (!this.proc || this.proc.killed) {
13783
13783
  return { success: false, path: "" };
13784
13784
  }
13785
- const { mkdirSync: mkdirSync33, writeFileSync: writeFileSync31 } = await import("node:fs");
13785
+ const { mkdirSync: mkdirSync34, writeFileSync: writeFileSync32 } = await import("node:fs");
13786
13786
  const sessionDir = join22(this.cwd, ".oa", "rlm");
13787
- mkdirSync33(sessionDir, { recursive: true });
13787
+ mkdirSync34(sessionDir, { recursive: true });
13788
13788
  const sessionPath = join22(sessionDir, "session.json");
13789
13789
  try {
13790
13790
  const inspectCode = `
@@ -13808,7 +13808,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
13808
13808
  trajectoryCount: this.trajectory.length,
13809
13809
  subCallCount: this.subCallCount
13810
13810
  };
13811
- writeFileSync31(sessionPath, JSON.stringify(sessionData, null, 2), "utf8");
13811
+ writeFileSync32(sessionPath, JSON.stringify(sessionData, null, 2), "utf8");
13812
13812
  return { success: true, path: sessionPath };
13813
13813
  }
13814
13814
  } catch {
@@ -13820,11 +13820,11 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
13820
13820
  * what was previously computed. */
13821
13821
  async loadSessionInfo() {
13822
13822
  try {
13823
- const { readFileSync: readFileSync48, existsSync: existsSync60 } = await import("node:fs");
13823
+ const { readFileSync: readFileSync49, existsSync: existsSync61 } = await import("node:fs");
13824
13824
  const sessionPath = join22(this.cwd, ".oa", "rlm", "session.json");
13825
- if (!existsSync60(sessionPath))
13825
+ if (!existsSync61(sessionPath))
13826
13826
  return null;
13827
- return JSON.parse(readFileSync48(sessionPath, "utf8"));
13827
+ return JSON.parse(readFileSync49(sessionPath, "utf8"));
13828
13828
  } catch {
13829
13829
  return null;
13830
13830
  }
@@ -14001,10 +14001,10 @@ var init_memory_metabolism = __esm({
14001
14001
  const trajDir = join23(this.cwd, ".oa", "rlm-trajectories");
14002
14002
  let lessons = [];
14003
14003
  try {
14004
- const { readdirSync: readdirSync25, readFileSync: readFileSync48 } = await import("node:fs");
14004
+ const { readdirSync: readdirSync25, readFileSync: readFileSync49 } = await import("node:fs");
14005
14005
  const files = readdirSync25(trajDir).filter((f) => f.endsWith(".jsonl")).sort().reverse().slice(0, 3);
14006
14006
  for (const file of files) {
14007
- const lines = readFileSync48(join23(trajDir, file), "utf8").split("\n").filter((l) => l.trim());
14007
+ const lines = readFileSync49(join23(trajDir, file), "utf8").split("\n").filter((l) => l.trim());
14008
14008
  for (const line of lines) {
14009
14009
  try {
14010
14010
  const entry = JSON.parse(line);
@@ -14388,14 +14388,14 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
14388
14388
  * Optionally filter by task type for phase-aware context (FSM paper insight).
14389
14389
  */
14390
14390
  getTopMemoriesSync(k = 5, taskType) {
14391
- const { readFileSync: readFileSync48, existsSync: existsSync60 } = __require("node:fs");
14391
+ const { readFileSync: readFileSync49, existsSync: existsSync61 } = __require("node:fs");
14392
14392
  const metaDir = join23(this.cwd, ".oa", "memory", "metabolism");
14393
14393
  const storeFile = join23(metaDir, "store.json");
14394
- if (!existsSync60(storeFile))
14394
+ if (!existsSync61(storeFile))
14395
14395
  return "";
14396
14396
  let store2 = [];
14397
14397
  try {
14398
- store2 = JSON.parse(readFileSync48(storeFile, "utf8"));
14398
+ store2 = JSON.parse(readFileSync49(storeFile, "utf8"));
14399
14399
  } catch {
14400
14400
  return "";
14401
14401
  }
@@ -14417,14 +14417,14 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
14417
14417
  /** Update memory scores based on task outcome. Called after task completion.
14418
14418
  * Memories used in successful tasks get boosted. Memories present during failures get decayed. */
14419
14419
  updateFromOutcomeSync(surfacedMemoryText, succeeded) {
14420
- const { readFileSync: readFileSync48, writeFileSync: writeFileSync31, existsSync: existsSync60, mkdirSync: mkdirSync33 } = __require("node:fs");
14420
+ const { readFileSync: readFileSync49, writeFileSync: writeFileSync32, existsSync: existsSync61, mkdirSync: mkdirSync34 } = __require("node:fs");
14421
14421
  const metaDir = join23(this.cwd, ".oa", "memory", "metabolism");
14422
14422
  const storeFile = join23(metaDir, "store.json");
14423
- if (!existsSync60(storeFile))
14423
+ if (!existsSync61(storeFile))
14424
14424
  return;
14425
14425
  let store2 = [];
14426
14426
  try {
14427
- store2 = JSON.parse(readFileSync48(storeFile, "utf8"));
14427
+ store2 = JSON.parse(readFileSync49(storeFile, "utf8"));
14428
14428
  } catch {
14429
14429
  return;
14430
14430
  }
@@ -14448,8 +14448,8 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
14448
14448
  updated = true;
14449
14449
  }
14450
14450
  if (updated) {
14451
- mkdirSync33(metaDir, { recursive: true });
14452
- writeFileSync31(storeFile, JSON.stringify(store2, null, 2));
14451
+ mkdirSync34(metaDir, { recursive: true });
14452
+ writeFileSync32(storeFile, JSON.stringify(store2, null, 2));
14453
14453
  }
14454
14454
  }
14455
14455
  // ── Storage ──────────────────────────────────────────────────────────
@@ -14871,13 +14871,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
14871
14871
  // Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
14872
14872
  /** Retrieve top-K strategies for context injection. Returns "" if none. */
14873
14873
  getRelevantStrategiesSync(k = 3, taskType) {
14874
- const { readFileSync: readFileSync48, existsSync: existsSync60 } = __require("node:fs");
14874
+ const { readFileSync: readFileSync49, existsSync: existsSync61 } = __require("node:fs");
14875
14875
  const archiveFile = join25(this.cwd, ".oa", "arche", "variants.json");
14876
- if (!existsSync60(archiveFile))
14876
+ if (!existsSync61(archiveFile))
14877
14877
  return "";
14878
14878
  let variants = [];
14879
14879
  try {
14880
- variants = JSON.parse(readFileSync48(archiveFile, "utf8"));
14880
+ variants = JSON.parse(readFileSync49(archiveFile, "utf8"));
14881
14881
  } catch {
14882
14882
  return "";
14883
14883
  }
@@ -14895,13 +14895,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
14895
14895
  }
14896
14896
  /** Archive a strategy variant synchronously (for task completion path) */
14897
14897
  archiveVariantSync(strategy, outcome, tags = []) {
14898
- const { readFileSync: readFileSync48, writeFileSync: writeFileSync31, existsSync: existsSync60, mkdirSync: mkdirSync33 } = __require("node:fs");
14898
+ const { readFileSync: readFileSync49, writeFileSync: writeFileSync32, existsSync: existsSync61, mkdirSync: mkdirSync34 } = __require("node:fs");
14899
14899
  const dir = join25(this.cwd, ".oa", "arche");
14900
14900
  const archiveFile = join25(dir, "variants.json");
14901
14901
  let variants = [];
14902
14902
  try {
14903
- if (existsSync60(archiveFile))
14904
- variants = JSON.parse(readFileSync48(archiveFile, "utf8"));
14903
+ if (existsSync61(archiveFile))
14904
+ variants = JSON.parse(readFileSync49(archiveFile, "utf8"));
14905
14905
  } catch {
14906
14906
  }
14907
14907
  variants.push({
@@ -14916,8 +14916,8 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
14916
14916
  });
14917
14917
  if (variants.length > 50)
14918
14918
  variants = variants.slice(-50);
14919
- mkdirSync33(dir, { recursive: true });
14920
- writeFileSync31(archiveFile, JSON.stringify(variants, null, 2));
14919
+ mkdirSync34(dir, { recursive: true });
14920
+ writeFileSync32(archiveFile, JSON.stringify(variants, null, 2));
14921
14921
  }
14922
14922
  async saveArchive(variants) {
14923
14923
  const dir = join25(this.cwd, ".oa", "arche");
@@ -22650,6 +22650,94 @@ var init_buildRunner = __esm({
22650
22650
  }
22651
22651
  });
22652
22652
 
22653
+ // packages/execution/dist/constraints.js
22654
+ import { existsSync as existsSync30, readFileSync as readFileSync23, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11 } from "node:fs";
22655
+ import { join as join44 } from "node:path";
22656
+ import { homedir as homedir11 } from "node:os";
22657
+ function loadConstraints(projectRoot) {
22658
+ projectConstraints = loadFile(join44(projectRoot, ".oa", "constraints.json"));
22659
+ globalConstraints = loadFile(join44(homedir11(), ".open-agents", "constraints.json"));
22660
+ }
22661
+ function loadFile(path) {
22662
+ try {
22663
+ if (!existsSync30(path))
22664
+ return [];
22665
+ const data = JSON.parse(readFileSync23(path, "utf-8"));
22666
+ return data.constraints || [];
22667
+ } catch {
22668
+ return [];
22669
+ }
22670
+ }
22671
+ function addSessionConstraint(constraint) {
22672
+ constraint.scope = "session";
22673
+ sessionConstraints.push(constraint);
22674
+ }
22675
+ function addProjectConstraint(projectRoot, constraint) {
22676
+ constraint.scope = "project";
22677
+ const path = join44(projectRoot, ".oa", "constraints.json");
22678
+ let data = { version: 1, constraints: [] };
22679
+ try {
22680
+ if (existsSync30(path))
22681
+ data = JSON.parse(readFileSync23(path, "utf-8"));
22682
+ } catch {
22683
+ }
22684
+ data.constraints.push(constraint);
22685
+ mkdirSync11(join44(projectRoot, ".oa"), { recursive: true });
22686
+ writeFileSync11(path, JSON.stringify(data, null, 2), "utf-8");
22687
+ projectConstraints = data.constraints;
22688
+ }
22689
+ function getAllConstraints() {
22690
+ return [...sessionConstraints, ...projectConstraints, ...globalConstraints];
22691
+ }
22692
+ function checkConstraints(toolName, args) {
22693
+ const violations = [];
22694
+ const allConstraints = getAllConstraints();
22695
+ const argsStr = JSON.stringify(args);
22696
+ for (const c3 of allConstraints) {
22697
+ const triggerPatterns = c3.trigger.split("|");
22698
+ if (!triggerPatterns.some((t) => toolName === t || t === "*"))
22699
+ continue;
22700
+ try {
22701
+ const regex = new RegExp(c3.pattern, "i");
22702
+ if (regex.test(argsStr)) {
22703
+ if (c3.target_files?.length) {
22704
+ const filePath = args.path || args.file || args.file_path || "";
22705
+ const matchesFile = c3.target_files.some((g) => {
22706
+ if (g.includes("**")) {
22707
+ const prefix = g.split("**")[0];
22708
+ const suffix = g.split("**").pop().replace("*", "");
22709
+ return filePath.startsWith(prefix) && (suffix === "" || filePath.endsWith(suffix.replace(/^\/*/, "")));
22710
+ }
22711
+ if (g.startsWith("*"))
22712
+ return filePath.endsWith(g.slice(1));
22713
+ return filePath === g;
22714
+ });
22715
+ if (!matchesFile)
22716
+ continue;
22717
+ }
22718
+ violations.push({
22719
+ constraint: c3,
22720
+ matched: argsStr.slice(0, 200)
22721
+ });
22722
+ }
22723
+ } catch {
22724
+ }
22725
+ }
22726
+ return violations;
22727
+ }
22728
+ function formatViolationWarning(violations) {
22729
+ return violations.map((v) => `[CONSTRAINT: ${v.constraint.id}] ${v.constraint.message}`).join("\n");
22730
+ }
22731
+ var projectConstraints, globalConstraints, sessionConstraints;
22732
+ var init_constraints = __esm({
22733
+ "packages/execution/dist/constraints.js"() {
22734
+ "use strict";
22735
+ projectConstraints = [];
22736
+ globalConstraints = [];
22737
+ sessionConstraints = [];
22738
+ }
22739
+ });
22740
+
22653
22741
  // packages/execution/dist/validationPipeline.js
22654
22742
  async function runValidationPipeline(config) {
22655
22743
  const { projectRoot, profile, stopOnFirstFailure = true } = config;
@@ -22832,12 +22920,15 @@ __export(dist_exports, {
22832
22920
  WebSearchTool: () => WebSearchTool,
22833
22921
  WorkingNotesTool: () => WorkingNotesTool,
22834
22922
  YouTubeDownloadTool: () => YouTubeDownloadTool,
22923
+ addProjectConstraint: () => addProjectConstraint,
22924
+ addSessionConstraint: () => addSessionConstraint,
22835
22925
  applyPatch: () => applyPatch,
22836
22926
  buildCompactDiff: () => buildCompactDiff,
22837
22927
  buildCustomTools: () => buildCustomTools,
22838
22928
  buildGraph: () => buildGraph,
22839
22929
  buildSkillsSummary: () => buildSkillsSummary,
22840
22930
  buildSubProcessArgs: () => buildSubProcessArgs,
22931
+ checkConstraints: () => checkConstraints,
22841
22932
  checkDesktopDeps: () => checkDesktopDeps,
22842
22933
  clearExploreNotes: () => clearExploreNotes,
22843
22934
  clearWorkingNotes: () => clearWorkingNotes,
@@ -22850,7 +22941,9 @@ __export(dist_exports, {
22850
22941
  ensureCommand: () => ensureCommand,
22851
22942
  ensureDepsForGroup: () => ensureDepsForGroup,
22852
22943
  formatSnapshotForContext: () => formatSnapshotForContext,
22944
+ formatViolationWarning: () => formatViolationWarning,
22853
22945
  getActiveAttentionItems: () => getActiveAttentionItems,
22946
+ getAllConstraints: () => getAllConstraints,
22854
22947
  getAllFullSubAgents: () => getAllFullSubAgents,
22855
22948
  getDueReminders: () => getDueReminders,
22856
22949
  getExploreNotes: () => getExploreNotes,
@@ -22868,6 +22961,7 @@ __export(dist_exports, {
22868
22961
  killProcess: () => killProcess,
22869
22962
  killProcessTree: () => killProcessTree,
22870
22963
  listCustomToolFiles: () => listCustomToolFiles,
22964
+ loadConstraints: () => loadConstraints,
22871
22965
  loadCustomTools: () => loadCustomTools,
22872
22966
  loadReminderStore: () => loadReminderStore,
22873
22967
  loadSkillContent: () => loadSkillContent,
@@ -22978,6 +23072,7 @@ var init_dist2 = __esm({
22978
23072
  init_testRunner();
22979
23073
  init_buildRunner();
22980
23074
  init_process_kill();
23075
+ init_constraints();
22981
23076
  init_validationPipeline();
22982
23077
  }
22983
23078
  });
@@ -23653,17 +23748,17 @@ var init_dist3 = __esm({
23653
23748
  });
23654
23749
 
23655
23750
  // packages/orchestrator/dist/promptLoader.js
23656
- import { readFileSync as readFileSync23, existsSync as existsSync30 } from "node:fs";
23657
- import { join as join44, dirname as dirname13 } from "node:path";
23751
+ import { readFileSync as readFileSync24, existsSync as existsSync31 } from "node:fs";
23752
+ import { join as join45, dirname as dirname13 } from "node:path";
23658
23753
  import { fileURLToPath as fileURLToPath7 } from "node:url";
23659
23754
  function loadPrompt(promptPath, vars) {
23660
23755
  let content = cache.get(promptPath);
23661
23756
  if (content === void 0) {
23662
- const fullPath = join44(PROMPTS_DIR, promptPath);
23663
- if (!existsSync30(fullPath)) {
23757
+ const fullPath = join45(PROMPTS_DIR, promptPath);
23758
+ if (!existsSync31(fullPath)) {
23664
23759
  throw new Error(`Prompt file not found: ${fullPath}`);
23665
23760
  }
23666
- content = readFileSync23(fullPath, "utf-8");
23761
+ content = readFileSync24(fullPath, "utf-8");
23667
23762
  cache.set(promptPath, content);
23668
23763
  }
23669
23764
  if (!vars)
@@ -23676,7 +23771,7 @@ var init_promptLoader = __esm({
23676
23771
  "use strict";
23677
23772
  __filename = fileURLToPath7(import.meta.url);
23678
23773
  __dirname4 = dirname13(__filename);
23679
- PROMPTS_DIR = join44(__dirname4, "..", "prompts");
23774
+ PROMPTS_DIR = join45(__dirname4, "..", "prompts");
23680
23775
  cache = /* @__PURE__ */ new Map();
23681
23776
  }
23682
23777
  });
@@ -24056,7 +24151,7 @@ var init_code_retriever = __esm({
24056
24151
  import { execFile as execFile6 } from "node:child_process";
24057
24152
  import { promisify as promisify5 } from "node:util";
24058
24153
  import { readFile as readFile20, readdir as readdir5, stat as stat3 } from "node:fs/promises";
24059
- import { join as join45, extname as extname8 } from "node:path";
24154
+ import { join as join46, extname as extname8 } from "node:path";
24060
24155
  async function searchByPath(pathPattern, options) {
24061
24156
  const allFiles = await collectFiles(options.rootDir, options.includeGlobs ?? DEFAULT_INCLUDE_GLOBS, options.excludeGlobs ?? DEFAULT_EXCLUDE_GLOBS);
24062
24157
  const pattern = options.caseInsensitive ? pathPattern.toLowerCase() : pathPattern;
@@ -24198,7 +24293,7 @@ async function walkForFiles(rootDir, dir, excludeGlobs, results) {
24198
24293
  continue;
24199
24294
  if (excludeGlobs.some((g) => entry.name === g || matchesGlob(entry.name, g)))
24200
24295
  continue;
24201
- const absPath = join45(dir, entry.name);
24296
+ const absPath = join46(dir, entry.name);
24202
24297
  if (entry.isDirectory()) {
24203
24298
  await walkForFiles(rootDir, absPath, excludeGlobs, results);
24204
24299
  } else if (entry.isFile()) {
@@ -24505,7 +24600,7 @@ var init_graphExpand = __esm({
24505
24600
 
24506
24601
  // packages/retrieval/dist/snippetPacker.js
24507
24602
  import { readFile as readFile21 } from "node:fs/promises";
24508
- import { join as join46 } from "node:path";
24603
+ import { join as join47 } from "node:path";
24509
24604
  async function packSnippets(requests, opts = {}) {
24510
24605
  const maxTokens = opts.maxTokens ?? DEFAULT_MAX_TOKENS;
24511
24606
  const contextLines = opts.contextLines ?? DEFAULT_CONTEXT_LINES;
@@ -24531,7 +24626,7 @@ async function packSnippets(requests, opts = {}) {
24531
24626
  return { packed, dropped, totalTokens };
24532
24627
  }
24533
24628
  async function extractSnippet(req, repoRoot, contextLines = DEFAULT_CONTEXT_LINES) {
24534
- const absPath = req.filePath.startsWith("/") ? req.filePath : join46(repoRoot, req.filePath);
24629
+ const absPath = req.filePath.startsWith("/") ? req.filePath : join47(repoRoot, req.filePath);
24535
24630
  let content;
24536
24631
  try {
24537
24632
  content = await readFile21(absPath, "utf-8");
@@ -25689,6 +25784,36 @@ var init_personality = __esm({
25689
25784
  }
25690
25785
  });
25691
25786
 
25787
+ // packages/orchestrator/dist/pressure-gate.js
25788
+ function detectPressure(message) {
25789
+ const hasProfanity = PRESSURE_SIGNALS.test(message);
25790
+ const hasUrgency = URGENCY_MARKERS.test(message);
25791
+ if (hasProfanity && hasUrgency)
25792
+ return "high";
25793
+ if (hasProfanity || hasUrgency)
25794
+ return "moderate";
25795
+ return "none";
25796
+ }
25797
+ function generateReflectionCue(level) {
25798
+ if (level === "none")
25799
+ return "";
25800
+ if (level === "moderate") {
25801
+ return "\n<reflection>The user is frustrated. Before acting, verify your proposed change addresses the root cause, not just the symptom.</reflection>\n";
25802
+ }
25803
+ return "\n<reflection>The user is very frustrated. Pause. Check your constraints and past feedback before writing code. The fastest fix is often the wrong fix.</reflection>\n";
25804
+ }
25805
+ function pressureCheck(message) {
25806
+ return generateReflectionCue(detectPressure(message));
25807
+ }
25808
+ var PRESSURE_SIGNALS, URGENCY_MARKERS;
25809
+ var init_pressure_gate = __esm({
25810
+ "packages/orchestrator/dist/pressure-gate.js"() {
25811
+ "use strict";
25812
+ PRESSURE_SIGNALS = /fuck|shit|idiot|asshat|god ?damn|unacceptable|broken|regression|cocked|screwed|bullshit/i;
25813
+ URGENCY_MARKERS = /fix (this|it|now)|just make it|stop doing|why the (fuck|hell)|you (broke|fucked|ruined|screwed)|right now|immediately/i;
25814
+ }
25815
+ });
25816
+
25692
25817
  // packages/orchestrator/dist/agenticRunner.js
25693
25818
  function repairJson(raw) {
25694
25819
  if (!raw || typeof raw !== "string")
@@ -25760,6 +25885,7 @@ var init_agenticRunner = __esm({
25760
25885
  init_dist();
25761
25886
  init_personality();
25762
25887
  init_promptLoader();
25888
+ init_pressure_gate();
25763
25889
  init_dist2();
25764
25890
  SYSTEM_PROMPT = loadPrompt("agentic/system-large.md");
25765
25891
  SYSTEM_PROMPT_MEDIUM = loadPrompt("agentic/system-medium.md");
@@ -25878,7 +26004,8 @@ var init_agenticRunner = __esm({
25878
26004
  */
25879
26005
  assembleContext(task, context) {
25880
26006
  const sections = [];
25881
- const basePrompt = getSystemPromptForTier(this.options.modelTier);
26007
+ const pressureCue = pressureCheck(task);
26008
+ const basePrompt = getSystemPromptForTier(this.options.modelTier) + pressureCue;
25882
26009
  sections.push({
25883
26010
  label: "c_instr",
25884
26011
  content: basePrompt,
@@ -26681,10 +26808,21 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
26681
26808
  } else if (!tool) {
26682
26809
  result = { success: false, output: "", error: `Unknown tool: ${tc.name}` };
26683
26810
  } else {
26684
- try {
26685
- result = await tool.execute(tc.arguments);
26686
- } catch (err) {
26687
- result = { success: false, output: "", error: err instanceof Error ? err.message : String(err) };
26811
+ const violations = checkConstraints(tc.name, tc.arguments);
26812
+ const blockViolations = violations.filter((v) => v.constraint.action === "block");
26813
+ if (blockViolations.length > 0) {
26814
+ result = { success: false, output: "", error: `BLOCKED by constraint: ${formatViolationWarning(blockViolations)}` };
26815
+ this.emit({ type: "status", content: `Constraint blocked: ${blockViolations[0].constraint.message}`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
26816
+ } else {
26817
+ const warnViolations = violations.filter((v) => v.constraint.action === "warn");
26818
+ if (warnViolations.length > 0) {
26819
+ this.emit({ type: "status", content: `\u26A0\uFE0F Constraint warning: ${warnViolations[0].constraint.message}`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
26820
+ }
26821
+ try {
26822
+ result = await tool.execute(tc.arguments);
26823
+ } catch (err) {
26824
+ result = { success: false, output: "", error: err instanceof Error ? err.message : String(err) };
26825
+ }
26688
26826
  }
26689
26827
  }
26690
26828
  if (isReadLike && result.success) {
@@ -27437,10 +27575,10 @@ ${marker}` : marker);
27437
27575
  if (!this._workingDirectory)
27438
27576
  return;
27439
27577
  try {
27440
- const { mkdirSync: mkdirSync33, writeFileSync: writeFileSync31 } = __require("node:fs");
27441
- const { join: join80 } = __require("node:path");
27442
- const sessionDir = join80(this._workingDirectory, ".oa", "session", this._sessionId);
27443
- mkdirSync33(sessionDir, { recursive: true });
27578
+ const { mkdirSync: mkdirSync34, writeFileSync: writeFileSync32 } = __require("node:fs");
27579
+ const { join: join81 } = __require("node:path");
27580
+ const sessionDir = join81(this._workingDirectory, ".oa", "session", this._sessionId);
27581
+ mkdirSync34(sessionDir, { recursive: true });
27444
27582
  const checkpoint = {
27445
27583
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27446
27584
  sessionId: this._sessionId,
@@ -27452,7 +27590,7 @@ ${marker}` : marker);
27452
27590
  memexEntryCount: this._memexArchive.size,
27453
27591
  fileRegistrySize: this._fileRegistry.size
27454
27592
  };
27455
- writeFileSync31(join80(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
27593
+ writeFileSync32(join81(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
27456
27594
  } catch {
27457
27595
  }
27458
27596
  }
@@ -28590,17 +28728,17 @@ ${transcript}`
28590
28728
  let resizedBase64 = null;
28591
28729
  try {
28592
28730
  const { execSync: execSync36 } = await import("node:child_process");
28593
- const { writeFileSync: writeFileSync31, readFileSync: readFileSync48, unlinkSync: unlinkSync13 } = await import("node:fs");
28594
- const { join: join80 } = await import("node:path");
28731
+ const { writeFileSync: writeFileSync32, readFileSync: readFileSync49, unlinkSync: unlinkSync13 } = await import("node:fs");
28732
+ const { join: join81 } = await import("node:path");
28595
28733
  const { tmpdir: tmpdir11 } = await import("node:os");
28596
- const tmpIn = join80(tmpdir11(), `oa_img_in_${Date.now()}.png`);
28597
- const tmpOut = join80(tmpdir11(), `oa_img_out_${Date.now()}.jpg`);
28598
- writeFileSync31(tmpIn, buffer);
28734
+ const tmpIn = join81(tmpdir11(), `oa_img_in_${Date.now()}.png`);
28735
+ const tmpOut = join81(tmpdir11(), `oa_img_out_${Date.now()}.jpg`);
28736
+ writeFileSync32(tmpIn, buffer);
28599
28737
  const pyBin = process.platform === "win32" ? "python" : "python3";
28600
28738
  const escapedIn = tmpIn.replace(/\\/g, "\\\\");
28601
28739
  const escapedOut = tmpOut.replace(/\\/g, "\\\\");
28602
28740
  execSync36(`${pyBin} -c "from PIL import Image; img = Image.open('${escapedIn}'); img.thumbnail((512, 512), Image.LANCZOS); img = img.convert('RGB'); img.save('${escapedOut}', 'JPEG', quality=75)"`, { timeout: 1e4, stdio: "pipe" });
28603
- const resizedBuf = readFileSync48(tmpOut);
28741
+ const resizedBuf = readFileSync49(tmpOut);
28604
28742
  resizedBase64 = `data:image/jpeg;base64,${resizedBuf.toString("base64")}`;
28605
28743
  try {
28606
28744
  unlinkSync13(tmpIn);
@@ -29176,9 +29314,9 @@ ${description}`
29176
29314
  });
29177
29315
 
29178
29316
  // packages/orchestrator/dist/nexusBackend.js
29179
- import { existsSync as existsSync31, statSync as statSync10, openSync, readSync, closeSync, unlinkSync as unlinkSync5, writeFileSync as writeFileSync11 } from "node:fs";
29317
+ import { existsSync as existsSync32, statSync as statSync10, openSync, readSync, closeSync, unlinkSync as unlinkSync5, writeFileSync as writeFileSync12 } from "node:fs";
29180
29318
  import { watch as fsWatch } from "node:fs";
29181
- import { join as join47 } from "node:path";
29319
+ import { join as join48 } from "node:path";
29182
29320
  import { tmpdir as tmpdir7 } from "node:os";
29183
29321
  import { randomBytes as randomBytes11 } from "node:crypto";
29184
29322
  var NexusAgenticBackend;
@@ -29328,8 +29466,8 @@ var init_nexusBackend = __esm({
29328
29466
  * Falls back to unary + word-split if streaming setup fails.
29329
29467
  */
29330
29468
  async *chatCompletionStream(request) {
29331
- const streamFile = join47(tmpdir7(), `nexus-stream-${randomBytes11(6).toString("hex")}.jsonl`);
29332
- writeFileSync11(streamFile, "", "utf8");
29469
+ const streamFile = join48(tmpdir7(), `nexus-stream-${randomBytes11(6).toString("hex")}.jsonl`);
29470
+ writeFileSync12(streamFile, "", "utf8");
29333
29471
  const daemonArgs = {
29334
29472
  model: this.model,
29335
29473
  messages: JSON.stringify(request.messages),
@@ -30341,6 +30479,7 @@ var init_dist5 = __esm({
30341
30479
  init_mergeRunner();
30342
30480
  init_retryController();
30343
30481
  init_agenticRunner();
30482
+ init_pressure_gate();
30344
30483
  init_nexusBackend();
30345
30484
  init_cascadeBackend();
30346
30485
  init_flowstatePrompt();
@@ -30364,9 +30503,9 @@ __export(listen_exports, {
30364
30503
  waitForTranscribeCli: () => waitForTranscribeCli
30365
30504
  });
30366
30505
  import { spawn as spawn16, execSync as execSync26 } from "node:child_process";
30367
- import { existsSync as existsSync32, mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, readdirSync as readdirSync8 } from "node:fs";
30368
- import { join as join48, dirname as dirname14 } from "node:path";
30369
- import { homedir as homedir11 } from "node:os";
30506
+ import { existsSync as existsSync33, mkdirSync as mkdirSync12, writeFileSync as writeFileSync13, readdirSync as readdirSync8 } from "node:fs";
30507
+ import { join as join49, dirname as dirname14 } from "node:path";
30508
+ import { homedir as homedir12 } from "node:os";
30370
30509
  import { fileURLToPath as fileURLToPath8 } from "node:url";
30371
30510
  import { EventEmitter } from "node:events";
30372
30511
  import { createInterface as createInterface2 } from "node:readline";
@@ -30451,15 +30590,15 @@ function findMicCaptureCommand() {
30451
30590
  function findLiveWhisperScript() {
30452
30591
  const thisDir = dirname14(fileURLToPath8(import.meta.url));
30453
30592
  const candidates = [
30454
- join48(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
30455
- join48(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
30456
- join48(thisDir, "../../execution/scripts/live-whisper.py"),
30593
+ join49(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
30594
+ join49(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
30595
+ join49(thisDir, "../../execution/scripts/live-whisper.py"),
30457
30596
  // npm install layout — scripts bundled alongside dist
30458
- join48(thisDir, "../scripts/live-whisper.py"),
30459
- join48(thisDir, "../../scripts/live-whisper.py")
30597
+ join49(thisDir, "../scripts/live-whisper.py"),
30598
+ join49(thisDir, "../../scripts/live-whisper.py")
30460
30599
  ];
30461
30600
  for (const p of candidates) {
30462
- if (existsSync32(p))
30601
+ if (existsSync33(p))
30463
30602
  return p;
30464
30603
  }
30465
30604
  try {
@@ -30469,21 +30608,21 @@ function findLiveWhisperScript() {
30469
30608
  stdio: ["pipe", "pipe", "pipe"]
30470
30609
  }).trim();
30471
30610
  const candidates2 = [
30472
- join48(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
30473
- join48(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
30611
+ join49(globalRoot, "open-agents-ai", "dist", "scripts", "live-whisper.py"),
30612
+ join49(globalRoot, "open-agents-ai", "scripts", "live-whisper.py")
30474
30613
  ];
30475
30614
  for (const p of candidates2) {
30476
- if (existsSync32(p))
30615
+ if (existsSync33(p))
30477
30616
  return p;
30478
30617
  }
30479
30618
  } catch {
30480
30619
  }
30481
- const nvmBase = join48(homedir11(), ".nvm", "versions", "node");
30482
- if (existsSync32(nvmBase)) {
30620
+ const nvmBase = join49(homedir12(), ".nvm", "versions", "node");
30621
+ if (existsSync33(nvmBase)) {
30483
30622
  try {
30484
30623
  for (const ver of readdirSync8(nvmBase)) {
30485
- const p = join48(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
30486
- if (existsSync32(p))
30624
+ const p = join49(nvmBase, ver, "lib", "node_modules", "open-agents-ai", "dist", "scripts", "live-whisper.py");
30625
+ if (existsSync33(p))
30487
30626
  return p;
30488
30627
  }
30489
30628
  } catch {
@@ -30501,7 +30640,7 @@ function ensureTranscribeCliBackground() {
30501
30640
  timeout: 5e3,
30502
30641
  stdio: ["pipe", "pipe", "pipe"]
30503
30642
  }).trim();
30504
- if (existsSync32(join48(globalRoot, "transcribe-cli", "dist", "index.js"))) {
30643
+ if (existsSync33(join49(globalRoot, "transcribe-cli", "dist", "index.js"))) {
30505
30644
  return true;
30506
30645
  }
30507
30646
  } catch {
@@ -30724,24 +30863,24 @@ var init_listen = __esm({
30724
30863
  timeout: 5e3,
30725
30864
  stdio: ["pipe", "pipe", "pipe"]
30726
30865
  }).trim();
30727
- const tcPath = join48(globalRoot, "transcribe-cli");
30728
- if (existsSync32(join48(tcPath, "dist", "index.js"))) {
30866
+ const tcPath = join49(globalRoot, "transcribe-cli");
30867
+ if (existsSync33(join49(tcPath, "dist", "index.js"))) {
30729
30868
  const { createRequire: createRequire6 } = await import("node:module");
30730
30869
  const req = createRequire6(import.meta.url);
30731
- return req(join48(tcPath, "dist", "index.js"));
30870
+ return req(join49(tcPath, "dist", "index.js"));
30732
30871
  }
30733
30872
  } catch {
30734
30873
  }
30735
- const nvmBase = join48(homedir11(), ".nvm", "versions", "node");
30736
- if (existsSync32(nvmBase)) {
30874
+ const nvmBase = join49(homedir12(), ".nvm", "versions", "node");
30875
+ if (existsSync33(nvmBase)) {
30737
30876
  try {
30738
30877
  const { readdirSync: readdirSync25 } = await import("node:fs");
30739
30878
  for (const ver of readdirSync25(nvmBase)) {
30740
- const tcPath = join48(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
30741
- if (existsSync32(join48(tcPath, "dist", "index.js"))) {
30879
+ const tcPath = join49(nvmBase, ver, "lib", "node_modules", "transcribe-cli");
30880
+ if (existsSync33(join49(tcPath, "dist", "index.js"))) {
30742
30881
  const { createRequire: createRequire6 } = await import("node:module");
30743
30882
  const req = createRequire6(import.meta.url);
30744
- return req(join48(tcPath, "dist", "index.js"));
30883
+ return req(join49(tcPath, "dist", "index.js"));
30745
30884
  }
30746
30885
  }
30747
30886
  } catch {
@@ -31023,10 +31162,10 @@ transcribe-cli error: ${transcribeCliError}` : "";
31023
31162
  });
31024
31163
  if (outputDir) {
31025
31164
  const { basename: basename18 } = await import("node:path");
31026
- const transcriptDir = join48(outputDir, ".oa", "transcripts");
31027
- mkdirSync11(transcriptDir, { recursive: true });
31028
- const outFile = join48(transcriptDir, `${basename18(filePath)}.txt`);
31029
- writeFileSync12(outFile, result.text, "utf-8");
31165
+ const transcriptDir = join49(outputDir, ".oa", "transcripts");
31166
+ mkdirSync12(transcriptDir, { recursive: true });
31167
+ const outFile = join49(transcriptDir, `${basename18(filePath)}.txt`);
31168
+ writeFileSync13(outFile, result.text, "utf-8");
31030
31169
  }
31031
31170
  return {
31032
31171
  text: result.text,
@@ -36652,8 +36791,8 @@ import { EventEmitter as EventEmitter3 } from "node:events";
36652
36791
  import { randomBytes as randomBytes12 } from "node:crypto";
36653
36792
  import { URL as URL2 } from "node:url";
36654
36793
  import { loadavg, cpus as cpus2, totalmem as totalmem2, freemem as freemem2 } from "node:os";
36655
- import { existsSync as existsSync33, readFileSync as readFileSync24, writeFileSync as writeFileSync13, unlinkSync as unlinkSync6, mkdirSync as mkdirSync12, readdirSync as readdirSync9, statSync as statSync11 } from "node:fs";
36656
- import { join as join49 } from "node:path";
36794
+ import { existsSync as existsSync34, readFileSync as readFileSync25, writeFileSync as writeFileSync14, unlinkSync as unlinkSync6, mkdirSync as mkdirSync13, readdirSync as readdirSync9, statSync as statSync11 } from "node:fs";
36795
+ import { join as join50 } from "node:path";
36657
36796
  function cleanForwardHeaders(raw, targetHost) {
36658
36797
  const out = {};
36659
36798
  for (const [key, value] of Object.entries(raw)) {
@@ -36681,10 +36820,10 @@ function fmtTokens(n) {
36681
36820
  }
36682
36821
  function readExposeState(stateDir) {
36683
36822
  try {
36684
- const path = join49(stateDir, STATE_FILE_NAME);
36685
- if (!existsSync33(path))
36823
+ const path = join50(stateDir, STATE_FILE_NAME);
36824
+ if (!existsSync34(path))
36686
36825
  return null;
36687
- const raw = readFileSync24(path, "utf8");
36826
+ const raw = readFileSync25(path, "utf8");
36688
36827
  const data = JSON.parse(raw);
36689
36828
  if (!data.pid || !data.tunnelUrl || !data.authKey || !data.proxyPort)
36690
36829
  return null;
@@ -36695,14 +36834,14 @@ function readExposeState(stateDir) {
36695
36834
  }
36696
36835
  function writeExposeState(stateDir, state) {
36697
36836
  try {
36698
- mkdirSync12(stateDir, { recursive: true });
36699
- writeFileSync13(join49(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
36837
+ mkdirSync13(stateDir, { recursive: true });
36838
+ writeFileSync14(join50(stateDir, STATE_FILE_NAME), JSON.stringify(state, null, 2));
36700
36839
  } catch {
36701
36840
  }
36702
36841
  }
36703
36842
  function removeExposeState(stateDir) {
36704
36843
  try {
36705
- unlinkSync6(join49(stateDir, STATE_FILE_NAME));
36844
+ unlinkSync6(join50(stateDir, STATE_FILE_NAME));
36706
36845
  } catch {
36707
36846
  }
36708
36847
  }
@@ -36791,10 +36930,10 @@ async function collectSystemMetricsAsync() {
36791
36930
  }
36792
36931
  function readP2PExposeState(stateDir) {
36793
36932
  try {
36794
- const path = join49(stateDir, P2P_STATE_FILE_NAME);
36795
- if (!existsSync33(path))
36933
+ const path = join50(stateDir, P2P_STATE_FILE_NAME);
36934
+ if (!existsSync34(path))
36796
36935
  return null;
36797
- const raw = readFileSync24(path, "utf8");
36936
+ const raw = readFileSync25(path, "utf8");
36798
36937
  const data = JSON.parse(raw);
36799
36938
  if (!data.peerId || !data.authKey)
36800
36939
  return null;
@@ -36805,14 +36944,14 @@ function readP2PExposeState(stateDir) {
36805
36944
  }
36806
36945
  function writeP2PExposeState(stateDir, state) {
36807
36946
  try {
36808
- mkdirSync12(stateDir, { recursive: true });
36809
- writeFileSync13(join49(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
36947
+ mkdirSync13(stateDir, { recursive: true });
36948
+ writeFileSync14(join50(stateDir, P2P_STATE_FILE_NAME), JSON.stringify(state, null, 2));
36810
36949
  } catch {
36811
36950
  }
36812
36951
  }
36813
36952
  function removeP2PExposeState(stateDir) {
36814
36953
  try {
36815
- unlinkSync6(join49(stateDir, P2P_STATE_FILE_NAME));
36954
+ unlinkSync6(join50(stateDir, P2P_STATE_FILE_NAME));
36816
36955
  } catch {
36817
36956
  }
36818
36957
  }
@@ -37789,10 +37928,10 @@ ${this.formatConnectionInfo()}`);
37789
37928
  throw new Error(`Expose failed: ${exposeResult.error}`);
37790
37929
  }
37791
37930
  const nexusDir = this._nexusTool.getNexusDir();
37792
- const statusPath = join49(nexusDir, "status.json");
37931
+ const statusPath = join50(nexusDir, "status.json");
37793
37932
  for (let i = 0; i < 80; i++) {
37794
37933
  try {
37795
- const raw = readFileSync24(statusPath, "utf8");
37934
+ const raw = readFileSync25(statusPath, "utf8");
37796
37935
  if (raw.length > 10) {
37797
37936
  const status = JSON.parse(raw);
37798
37937
  if (status.connected && status.peerId) {
@@ -37823,8 +37962,8 @@ ${this.formatConnectionInfo()}`);
37823
37962
  });
37824
37963
  }
37825
37964
  try {
37826
- const invocDir = join49(nexusDir, "invocations");
37827
- if (existsSync33(invocDir)) {
37965
+ const invocDir = join50(nexusDir, "invocations");
37966
+ if (existsSync34(invocDir)) {
37828
37967
  this._prevInvocCount = readdirSync9(invocDir).filter((f) => f.endsWith(".json")).length;
37829
37968
  this._stats.totalRequests = this._prevInvocCount;
37830
37969
  }
@@ -37853,13 +37992,13 @@ ${this.formatConnectionInfo()}`);
37853
37992
  if (!state)
37854
37993
  return null;
37855
37994
  const nexusDir = nexusTool.getNexusDir();
37856
- const statusPath = join49(nexusDir, "status.json");
37995
+ const statusPath = join50(nexusDir, "status.json");
37857
37996
  try {
37858
- if (!existsSync33(statusPath)) {
37997
+ if (!existsSync34(statusPath)) {
37859
37998
  removeP2PExposeState(stateDir);
37860
37999
  return null;
37861
38000
  }
37862
- const status = JSON.parse(readFileSync24(statusPath, "utf8"));
38001
+ const status = JSON.parse(readFileSync25(statusPath, "utf8"));
37863
38002
  if (!status.connected || !status.peerId) {
37864
38003
  removeP2PExposeState(stateDir);
37865
38004
  return null;
@@ -37912,8 +38051,8 @@ ${this.formatConnectionInfo()}`);
37912
38051
  let lastMeteringLineCount = 0;
37913
38052
  this._activityPollTimer = setInterval(() => {
37914
38053
  try {
37915
- const invocDir = join49(nexusDir, "invocations");
37916
- if (!existsSync33(invocDir))
38054
+ const invocDir = join50(nexusDir, "invocations");
38055
+ if (!existsSync34(invocDir))
37917
38056
  return;
37918
38057
  const files = readdirSync9(invocDir).filter((f) => f.endsWith(".json"));
37919
38058
  const invocCount = files.length;
@@ -37928,17 +38067,17 @@ ${this.formatConnectionInfo()}`);
37928
38067
  let recentActive = 0;
37929
38068
  for (const f of files.slice(-10)) {
37930
38069
  try {
37931
- const st = statSync11(join49(invocDir, f));
38070
+ const st = statSync11(join50(invocDir, f));
37932
38071
  if (now - st.mtimeMs < 1e4)
37933
38072
  recentActive++;
37934
38073
  } catch {
37935
38074
  }
37936
38075
  }
37937
- const meteringFile = join49(nexusDir, "metering.jsonl");
38076
+ const meteringFile = join50(nexusDir, "metering.jsonl");
37938
38077
  let meteringLines = lastMeteringLineCount;
37939
38078
  try {
37940
- if (existsSync33(meteringFile)) {
37941
- const content = readFileSync24(meteringFile, "utf8");
38079
+ if (existsSync34(meteringFile)) {
38080
+ const content = readFileSync25(meteringFile, "utf8");
37942
38081
  meteringLines = content.split("\n").filter((l) => l.trim()).length;
37943
38082
  }
37944
38083
  } catch {
@@ -37964,9 +38103,9 @@ ${this.formatConnectionInfo()}`);
37964
38103
  this._activityPollTimer.unref();
37965
38104
  this._pollTimer = setInterval(() => {
37966
38105
  try {
37967
- const statusPath = join49(nexusDir, "status.json");
37968
- if (existsSync33(statusPath)) {
37969
- const status = JSON.parse(readFileSync24(statusPath, "utf8"));
38106
+ const statusPath = join50(nexusDir, "status.json");
38107
+ if (existsSync34(statusPath)) {
38108
+ const status = JSON.parse(readFileSync25(statusPath, "utf8"));
37970
38109
  if (status.peerId && !this._peerId) {
37971
38110
  this._peerId = status.peerId;
37972
38111
  }
@@ -37975,8 +38114,8 @@ ${this.formatConnectionInfo()}`);
37975
38114
  } catch {
37976
38115
  }
37977
38116
  try {
37978
- const invocDir = join49(nexusDir, "invocations");
37979
- if (existsSync33(invocDir)) {
38117
+ const invocDir = join50(nexusDir, "invocations");
38118
+ if (existsSync34(invocDir)) {
37980
38119
  const files = readdirSync9(invocDir);
37981
38120
  const invocCount = files.filter((f) => f.endsWith(".json")).length;
37982
38121
  if (invocCount > this._stats.totalRequests) {
@@ -37987,9 +38126,9 @@ ${this.formatConnectionInfo()}`);
37987
38126
  } catch {
37988
38127
  }
37989
38128
  try {
37990
- const meteringFile = join49(nexusDir, "metering.jsonl");
37991
- if (existsSync33(meteringFile)) {
37992
- const content = readFileSync24(meteringFile, "utf8");
38129
+ const meteringFile = join50(nexusDir, "metering.jsonl");
38130
+ if (existsSync34(meteringFile)) {
38131
+ const content = readFileSync25(meteringFile, "utf8");
37993
38132
  if (content.length > lastMeteringSize) {
37994
38133
  const newContent = content.slice(lastMeteringSize);
37995
38134
  lastMeteringSize = content.length;
@@ -38198,8 +38337,8 @@ var init_types = __esm({
38198
38337
 
38199
38338
  // packages/cli/dist/tui/p2p/secret-vault.js
38200
38339
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes13, scryptSync as scryptSync2, createHash as createHash3 } from "node:crypto";
38201
- import { readFileSync as readFileSync25, writeFileSync as writeFileSync14, existsSync as existsSync34, mkdirSync as mkdirSync13 } from "node:fs";
38202
- import { join as join50, dirname as dirname15 } from "node:path";
38340
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync15, existsSync as existsSync35, mkdirSync as mkdirSync14 } from "node:fs";
38341
+ import { join as join51, dirname as dirname15 } from "node:path";
38203
38342
  var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
38204
38343
  var init_secret_vault = __esm({
38205
38344
  "packages/cli/dist/tui/p2p/secret-vault.js"() {
@@ -38411,18 +38550,18 @@ var init_secret_vault = __esm({
38411
38550
  const tag = cipher.getAuthTag();
38412
38551
  const blob = Buffer.concat([salt, iv, tag, encrypted]);
38413
38552
  const dir = dirname15(this.storePath);
38414
- if (!existsSync34(dir))
38415
- mkdirSync13(dir, { recursive: true });
38416
- writeFileSync14(this.storePath, blob, { mode: 384 });
38553
+ if (!existsSync35(dir))
38554
+ mkdirSync14(dir, { recursive: true });
38555
+ writeFileSync15(this.storePath, blob, { mode: 384 });
38417
38556
  }
38418
38557
  /**
38419
38558
  * Load vault from disk, decrypting with the given passphrase.
38420
38559
  * Returns the number of secrets loaded.
38421
38560
  */
38422
38561
  load(passphrase) {
38423
- if (!this.storePath || !existsSync34(this.storePath))
38562
+ if (!this.storePath || !existsSync35(this.storePath))
38424
38563
  return 0;
38425
- const blob = readFileSync25(this.storePath);
38564
+ const blob = readFileSync26(this.storePath);
38426
38565
  if (blob.length < SALT_LEN + IV_LEN + 16) {
38427
38566
  throw new Error("Vault file is corrupted (too small)");
38428
38567
  }
@@ -39576,26 +39715,26 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
39576
39715
  async function fetchPeerModels(peerId, authKey) {
39577
39716
  try {
39578
39717
  const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
39579
- const { existsSync: existsSync60, readFileSync: readFileSync48 } = await import("node:fs");
39580
- const { join: join80 } = await import("node:path");
39718
+ const { existsSync: existsSync61, readFileSync: readFileSync49 } = await import("node:fs");
39719
+ const { join: join81 } = await import("node:path");
39581
39720
  const cwd4 = process.cwd();
39582
39721
  const nexusTool = new NexusTool2(cwd4);
39583
39722
  const nexusDir = nexusTool.getNexusDir();
39584
39723
  let isLocalPeer = false;
39585
39724
  try {
39586
- const statusPath = join80(nexusDir, "status.json");
39587
- if (existsSync60(statusPath)) {
39588
- const status = JSON.parse(readFileSync48(statusPath, "utf8"));
39725
+ const statusPath = join81(nexusDir, "status.json");
39726
+ if (existsSync61(statusPath)) {
39727
+ const status = JSON.parse(readFileSync49(statusPath, "utf8"));
39589
39728
  if (status.peerId === peerId)
39590
39729
  isLocalPeer = true;
39591
39730
  }
39592
39731
  } catch {
39593
39732
  }
39594
39733
  if (isLocalPeer) {
39595
- const pricingPath = join80(nexusDir, "pricing.json");
39596
- if (existsSync60(pricingPath)) {
39734
+ const pricingPath = join81(nexusDir, "pricing.json");
39735
+ if (existsSync61(pricingPath)) {
39597
39736
  try {
39598
- const pricing = JSON.parse(readFileSync48(pricingPath, "utf8"));
39737
+ const pricing = JSON.parse(readFileSync49(pricingPath, "utf8"));
39599
39738
  const localModels = (pricing.models || []).map((m) => ({
39600
39739
  name: m.model || "unknown",
39601
39740
  size: m.parameterSize || "",
@@ -39609,10 +39748,10 @@ async function fetchPeerModels(peerId, authKey) {
39609
39748
  }
39610
39749
  }
39611
39750
  }
39612
- const cachePath = join80(nexusDir, "peer-models-cache.json");
39613
- if (existsSync60(cachePath)) {
39751
+ const cachePath = join81(nexusDir, "peer-models-cache.json");
39752
+ if (existsSync61(cachePath)) {
39614
39753
  try {
39615
- const cache4 = JSON.parse(readFileSync48(cachePath, "utf8"));
39754
+ const cache4 = JSON.parse(readFileSync49(cachePath, "utf8"));
39616
39755
  if (cache4.peerId === peerId && cache4.models?.length > 0) {
39617
39756
  const age = Date.now() - new Date(cache4.cachedAt).getTime();
39618
39757
  if (age < 5 * 60 * 1e3) {
@@ -39727,10 +39866,10 @@ async function fetchPeerModels(peerId, authKey) {
39727
39866
  } catch {
39728
39867
  }
39729
39868
  if (isLocalPeer) {
39730
- const pricingPath = join80(nexusDir, "pricing.json");
39731
- if (existsSync60(pricingPath)) {
39869
+ const pricingPath = join81(nexusDir, "pricing.json");
39870
+ if (existsSync61(pricingPath)) {
39732
39871
  try {
39733
- const pricing = JSON.parse(readFileSync48(pricingPath, "utf8"));
39872
+ const pricing = JSON.parse(readFileSync49(pricingPath, "utf8"));
39734
39873
  return (pricing.models || []).map((m) => ({
39735
39874
  name: m.model || "unknown",
39736
39875
  size: m.parameterSize || "",
@@ -40010,17 +40149,17 @@ var init_render2 = __esm({
40010
40149
  });
40011
40150
 
40012
40151
  // packages/prompts/dist/promptLoader.js
40013
- import { readFileSync as readFileSync26, existsSync as existsSync35 } from "node:fs";
40014
- import { join as join51, dirname as dirname16 } from "node:path";
40152
+ import { readFileSync as readFileSync27, existsSync as existsSync36 } from "node:fs";
40153
+ import { join as join52, dirname as dirname16 } from "node:path";
40015
40154
  import { fileURLToPath as fileURLToPath9 } from "node:url";
40016
40155
  function loadPrompt2(promptPath, vars) {
40017
40156
  let content = cache2.get(promptPath);
40018
40157
  if (content === void 0) {
40019
- const fullPath = join51(PROMPTS_DIR2, promptPath);
40020
- if (!existsSync35(fullPath)) {
40158
+ const fullPath = join52(PROMPTS_DIR2, promptPath);
40159
+ if (!existsSync36(fullPath)) {
40021
40160
  throw new Error(`Prompt file not found: ${fullPath}`);
40022
40161
  }
40023
- content = readFileSync26(fullPath, "utf-8");
40162
+ content = readFileSync27(fullPath, "utf-8");
40024
40163
  cache2.set(promptPath, content);
40025
40164
  }
40026
40165
  if (!vars)
@@ -40033,9 +40172,9 @@ var init_promptLoader2 = __esm({
40033
40172
  "use strict";
40034
40173
  __filename2 = fileURLToPath9(import.meta.url);
40035
40174
  __dirname5 = dirname16(__filename2);
40036
- devPath = join51(__dirname5, "..", "templates");
40037
- publishedPath = join51(__dirname5, "..", "prompts", "templates");
40038
- PROMPTS_DIR2 = existsSync35(devPath) ? devPath : publishedPath;
40175
+ devPath = join52(__dirname5, "..", "templates");
40176
+ publishedPath = join52(__dirname5, "..", "prompts", "templates");
40177
+ PROMPTS_DIR2 = existsSync36(devPath) ? devPath : publishedPath;
40039
40178
  cache2 = /* @__PURE__ */ new Map();
40040
40179
  }
40041
40180
  });
@@ -40146,7 +40285,7 @@ var init_task_templates = __esm({
40146
40285
  });
40147
40286
 
40148
40287
  // packages/prompts/dist/index.js
40149
- import { join as join52, dirname as dirname17 } from "node:path";
40288
+ import { join as join53, dirname as dirname17 } from "node:path";
40150
40289
  import { fileURLToPath as fileURLToPath10 } from "node:url";
40151
40290
  var _dir, _packageRoot;
40152
40291
  var init_dist6 = __esm({
@@ -40157,7 +40296,7 @@ var init_dist6 = __esm({
40157
40296
  init_task_templates();
40158
40297
  init_render2();
40159
40298
  _dir = dirname17(fileURLToPath10(import.meta.url));
40160
- _packageRoot = join52(_dir, "..");
40299
+ _packageRoot = join53(_dir, "..");
40161
40300
  }
40162
40301
  });
40163
40302
 
@@ -40190,21 +40329,21 @@ __export(oa_directory_exports, {
40190
40329
  writeIndexData: () => writeIndexData,
40191
40330
  writeIndexMeta: () => writeIndexMeta
40192
40331
  });
40193
- import { existsSync as existsSync36, mkdirSync as mkdirSync14, readFileSync as readFileSync27, writeFileSync as writeFileSync15, readdirSync as readdirSync10, statSync as statSync12, unlinkSync as unlinkSync7 } from "node:fs";
40194
- import { join as join53, relative as relative3, basename as basename11, extname as extname9 } from "node:path";
40195
- import { homedir as homedir12 } from "node:os";
40332
+ import { existsSync as existsSync37, mkdirSync as mkdirSync15, readFileSync as readFileSync28, writeFileSync as writeFileSync16, readdirSync as readdirSync10, statSync as statSync12, unlinkSync as unlinkSync7 } from "node:fs";
40333
+ import { join as join54, relative as relative3, basename as basename11, extname as extname9 } from "node:path";
40334
+ import { homedir as homedir13 } from "node:os";
40196
40335
  function initOaDirectory(repoRoot) {
40197
- const oaPath = join53(repoRoot, OA_DIR);
40336
+ const oaPath = join54(repoRoot, OA_DIR);
40198
40337
  for (const sub of SUBDIRS) {
40199
- mkdirSync14(join53(oaPath, sub), { recursive: true });
40338
+ mkdirSync15(join54(oaPath, sub), { recursive: true });
40200
40339
  }
40201
40340
  try {
40202
- const gitignorePath = join53(repoRoot, ".gitignore");
40341
+ const gitignorePath = join54(repoRoot, ".gitignore");
40203
40342
  const settingsPattern = ".oa/settings.json";
40204
- if (existsSync36(gitignorePath)) {
40205
- const content = readFileSync27(gitignorePath, "utf-8");
40343
+ if (existsSync37(gitignorePath)) {
40344
+ const content = readFileSync28(gitignorePath, "utf-8");
40206
40345
  if (!content.includes(settingsPattern)) {
40207
- writeFileSync15(gitignorePath, content.trimEnd() + "\n" + settingsPattern + "\n", "utf-8");
40346
+ writeFileSync16(gitignorePath, content.trimEnd() + "\n" + settingsPattern + "\n", "utf-8");
40208
40347
  }
40209
40348
  }
40210
40349
  } catch {
@@ -40212,41 +40351,41 @@ function initOaDirectory(repoRoot) {
40212
40351
  return oaPath;
40213
40352
  }
40214
40353
  function hasOaDirectory(repoRoot) {
40215
- return existsSync36(join53(repoRoot, OA_DIR, "index"));
40354
+ return existsSync37(join54(repoRoot, OA_DIR, "index"));
40216
40355
  }
40217
40356
  function loadProjectSettings(repoRoot) {
40218
- const settingsPath = join53(repoRoot, OA_DIR, "settings.json");
40357
+ const settingsPath = join54(repoRoot, OA_DIR, "settings.json");
40219
40358
  try {
40220
- if (existsSync36(settingsPath)) {
40221
- return JSON.parse(readFileSync27(settingsPath, "utf-8"));
40359
+ if (existsSync37(settingsPath)) {
40360
+ return JSON.parse(readFileSync28(settingsPath, "utf-8"));
40222
40361
  }
40223
40362
  } catch {
40224
40363
  }
40225
40364
  return {};
40226
40365
  }
40227
40366
  function saveProjectSettings(repoRoot, settings) {
40228
- const oaPath = join53(repoRoot, OA_DIR);
40229
- mkdirSync14(oaPath, { recursive: true });
40367
+ const oaPath = join54(repoRoot, OA_DIR);
40368
+ mkdirSync15(oaPath, { recursive: true });
40230
40369
  const existing = loadProjectSettings(repoRoot);
40231
40370
  const merged = { ...existing, ...settings };
40232
- writeFileSync15(join53(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
40371
+ writeFileSync16(join54(oaPath, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
40233
40372
  }
40234
40373
  function loadGlobalSettings() {
40235
- const settingsPath = join53(homedir12(), ".open-agents", "settings.json");
40374
+ const settingsPath = join54(homedir13(), ".open-agents", "settings.json");
40236
40375
  try {
40237
- if (existsSync36(settingsPath)) {
40238
- return JSON.parse(readFileSync27(settingsPath, "utf-8"));
40376
+ if (existsSync37(settingsPath)) {
40377
+ return JSON.parse(readFileSync28(settingsPath, "utf-8"));
40239
40378
  }
40240
40379
  } catch {
40241
40380
  }
40242
40381
  return {};
40243
40382
  }
40244
40383
  function saveGlobalSettings(settings) {
40245
- const dir = join53(homedir12(), ".open-agents");
40246
- mkdirSync14(dir, { recursive: true });
40384
+ const dir = join54(homedir13(), ".open-agents");
40385
+ mkdirSync15(dir, { recursive: true });
40247
40386
  const existing = loadGlobalSettings();
40248
40387
  const merged = { ...existing, ...settings };
40249
- writeFileSync15(join53(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
40388
+ writeFileSync16(join54(dir, "settings.json"), JSON.stringify(merged, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
40250
40389
  }
40251
40390
  function resolveSettings(repoRoot) {
40252
40391
  const global = loadGlobalSettings();
@@ -40261,12 +40400,12 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
40261
40400
  while (dir && !visited.has(dir)) {
40262
40401
  visited.add(dir);
40263
40402
  for (const name of CONTEXT_FILES) {
40264
- const filePath = join53(dir, name);
40403
+ const filePath = join54(dir, name);
40265
40404
  const normalizedName = name.toLowerCase();
40266
- if (existsSync36(filePath) && !seen.has(filePath)) {
40405
+ if (existsSync37(filePath) && !seen.has(filePath)) {
40267
40406
  seen.add(filePath);
40268
40407
  try {
40269
- let content = readFileSync27(filePath, "utf-8");
40408
+ let content = readFileSync28(filePath, "utf-8");
40270
40409
  if (content.length > maxContentLen) {
40271
40410
  content = content.slice(0, maxContentLen) + "\n\n...(truncated)";
40272
40411
  }
@@ -40280,11 +40419,11 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
40280
40419
  }
40281
40420
  }
40282
40421
  }
40283
- const projectMap = join53(dir, OA_DIR, "context", "project-map.md");
40284
- if (existsSync36(projectMap) && !seen.has(projectMap)) {
40422
+ const projectMap = join54(dir, OA_DIR, "context", "project-map.md");
40423
+ if (existsSync37(projectMap) && !seen.has(projectMap)) {
40285
40424
  seen.add(projectMap);
40286
40425
  try {
40287
- let content = readFileSync27(projectMap, "utf-8");
40426
+ let content = readFileSync28(projectMap, "utf-8");
40288
40427
  if (content.length > maxContentLen) {
40289
40428
  content = content.slice(0, maxContentLen) + "\n\n...(truncated)";
40290
40429
  }
@@ -40296,7 +40435,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
40296
40435
  } catch {
40297
40436
  }
40298
40437
  }
40299
- const parent = join53(dir, "..");
40438
+ const parent = join54(dir, "..");
40300
40439
  if (parent === dir)
40301
40440
  break;
40302
40441
  dir = parent;
@@ -40314,30 +40453,30 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
40314
40453
  return found;
40315
40454
  }
40316
40455
  function readIndexMeta(repoRoot) {
40317
- const metaPath = join53(repoRoot, OA_DIR, "index", "meta.json");
40456
+ const metaPath = join54(repoRoot, OA_DIR, "index", "meta.json");
40318
40457
  try {
40319
- return JSON.parse(readFileSync27(metaPath, "utf-8"));
40458
+ return JSON.parse(readFileSync28(metaPath, "utf-8"));
40320
40459
  } catch {
40321
40460
  return null;
40322
40461
  }
40323
40462
  }
40324
40463
  function writeIndexMeta(repoRoot, meta) {
40325
- const metaPath = join53(repoRoot, OA_DIR, "index", "meta.json");
40326
- mkdirSync14(join53(repoRoot, OA_DIR, "index"), { recursive: true });
40327
- writeFileSync15(metaPath, JSON.stringify(meta, null, 2), "utf-8");
40464
+ const metaPath = join54(repoRoot, OA_DIR, "index", "meta.json");
40465
+ mkdirSync15(join54(repoRoot, OA_DIR, "index"), { recursive: true });
40466
+ writeFileSync16(metaPath, JSON.stringify(meta, null, 2), "utf-8");
40328
40467
  }
40329
40468
  function readIndexData(repoRoot, filename) {
40330
- const filePath = join53(repoRoot, OA_DIR, "index", filename);
40469
+ const filePath = join54(repoRoot, OA_DIR, "index", filename);
40331
40470
  try {
40332
- return JSON.parse(readFileSync27(filePath, "utf-8"));
40471
+ return JSON.parse(readFileSync28(filePath, "utf-8"));
40333
40472
  } catch {
40334
40473
  return null;
40335
40474
  }
40336
40475
  }
40337
40476
  function writeIndexData(repoRoot, filename, data) {
40338
- const filePath = join53(repoRoot, OA_DIR, "index", filename);
40339
- mkdirSync14(join53(repoRoot, OA_DIR, "index"), { recursive: true });
40340
- writeFileSync15(filePath, JSON.stringify(data, null, 2), "utf-8");
40477
+ const filePath = join54(repoRoot, OA_DIR, "index", filename);
40478
+ mkdirSync15(join54(repoRoot, OA_DIR, "index"), { recursive: true });
40479
+ writeFileSync16(filePath, JSON.stringify(data, null, 2), "utf-8");
40341
40480
  }
40342
40481
  function generateProjectMap(repoRoot) {
40343
40482
  const sections = [];
@@ -40385,28 +40524,28 @@ ${tree}\`\`\`
40385
40524
  sections.push("");
40386
40525
  }
40387
40526
  const content = sections.join("\n");
40388
- const contextDir = join53(repoRoot, OA_DIR, "context");
40389
- mkdirSync14(contextDir, { recursive: true });
40390
- writeFileSync15(join53(contextDir, "project-map.md"), content, "utf-8");
40527
+ const contextDir = join54(repoRoot, OA_DIR, "context");
40528
+ mkdirSync15(contextDir, { recursive: true });
40529
+ writeFileSync16(join54(contextDir, "project-map.md"), content, "utf-8");
40391
40530
  return content;
40392
40531
  }
40393
40532
  function saveSession(repoRoot, session) {
40394
- const historyDir = join53(repoRoot, OA_DIR, "history");
40395
- mkdirSync14(historyDir, { recursive: true });
40396
- writeFileSync15(join53(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
40533
+ const historyDir = join54(repoRoot, OA_DIR, "history");
40534
+ mkdirSync15(historyDir, { recursive: true });
40535
+ writeFileSync16(join54(historyDir, `${session.id}.json`), JSON.stringify(session, null, 2), "utf-8");
40397
40536
  }
40398
40537
  function loadRecentSessions(repoRoot, limit = 5) {
40399
- const historyDir = join53(repoRoot, OA_DIR, "history");
40400
- if (!existsSync36(historyDir))
40538
+ const historyDir = join54(repoRoot, OA_DIR, "history");
40539
+ if (!existsSync37(historyDir))
40401
40540
  return [];
40402
40541
  try {
40403
40542
  const files = readdirSync10(historyDir).filter((f) => f.endsWith(".json") && f !== "pending-task.json").map((f) => {
40404
- const stat5 = statSync12(join53(historyDir, f));
40543
+ const stat5 = statSync12(join54(historyDir, f));
40405
40544
  return { file: f, mtime: stat5.mtimeMs };
40406
40545
  }).sort((a, b) => b.mtime - a.mtime).slice(0, limit);
40407
40546
  return files.map((f) => {
40408
40547
  try {
40409
- return JSON.parse(readFileSync27(join53(historyDir, f.file), "utf-8"));
40548
+ return JSON.parse(readFileSync28(join54(historyDir, f.file), "utf-8"));
40410
40549
  } catch {
40411
40550
  return null;
40412
40551
  }
@@ -40416,16 +40555,16 @@ function loadRecentSessions(repoRoot, limit = 5) {
40416
40555
  }
40417
40556
  }
40418
40557
  function savePendingTask(repoRoot, task) {
40419
- const historyDir = join53(repoRoot, OA_DIR, "history");
40420
- mkdirSync14(historyDir, { recursive: true });
40421
- writeFileSync15(join53(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
40558
+ const historyDir = join54(repoRoot, OA_DIR, "history");
40559
+ mkdirSync15(historyDir, { recursive: true });
40560
+ writeFileSync16(join54(historyDir, PENDING_TASK_FILE), JSON.stringify(task, null, 2) + "\n", "utf-8");
40422
40561
  }
40423
40562
  function loadPendingTask(repoRoot) {
40424
- const filePath = join53(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
40563
+ const filePath = join54(repoRoot, OA_DIR, "history", PENDING_TASK_FILE);
40425
40564
  try {
40426
- if (!existsSync36(filePath))
40565
+ if (!existsSync37(filePath))
40427
40566
  return null;
40428
- const data = JSON.parse(readFileSync27(filePath, "utf-8"));
40567
+ const data = JSON.parse(readFileSync28(filePath, "utf-8"));
40429
40568
  try {
40430
40569
  unlinkSync7(filePath);
40431
40570
  } catch {
@@ -40436,13 +40575,13 @@ function loadPendingTask(repoRoot) {
40436
40575
  }
40437
40576
  }
40438
40577
  function saveSessionContext(repoRoot, entry) {
40439
- const contextDir = join53(repoRoot, OA_DIR, "context");
40440
- mkdirSync14(contextDir, { recursive: true });
40441
- const filePath = join53(contextDir, CONTEXT_SAVE_FILE);
40578
+ const contextDir = join54(repoRoot, OA_DIR, "context");
40579
+ mkdirSync15(contextDir, { recursive: true });
40580
+ const filePath = join54(contextDir, CONTEXT_SAVE_FILE);
40442
40581
  let ctx;
40443
40582
  try {
40444
- if (existsSync36(filePath)) {
40445
- ctx = JSON.parse(readFileSync27(filePath, "utf-8"));
40583
+ if (existsSync37(filePath)) {
40584
+ ctx = JSON.parse(readFileSync28(filePath, "utf-8"));
40446
40585
  } else {
40447
40586
  ctx = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
40448
40587
  }
@@ -40454,7 +40593,7 @@ function saveSessionContext(repoRoot, entry) {
40454
40593
  ctx.entries = ctx.entries.slice(-ctx.maxEntries);
40455
40594
  }
40456
40595
  ctx.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
40457
- writeFileSync15(filePath, JSON.stringify(ctx, null, 2) + "\n", "utf-8");
40596
+ writeFileSync16(filePath, JSON.stringify(ctx, null, 2) + "\n", "utf-8");
40458
40597
  try {
40459
40598
  const diaryLines = ["# Session Diary", ""];
40460
40599
  for (const e of ctx.entries.slice(-10)) {
@@ -40469,16 +40608,16 @@ function saveSessionContext(repoRoot, entry) {
40469
40608
  diaryLines.push(`Summary: ${e.summary.slice(0, 200)}`);
40470
40609
  diaryLines.push("");
40471
40610
  }
40472
- writeFileSync15(join53(contextDir, "session-diary.md"), diaryLines.join("\n"), "utf-8");
40611
+ writeFileSync16(join54(contextDir, "session-diary.md"), diaryLines.join("\n"), "utf-8");
40473
40612
  } catch {
40474
40613
  }
40475
40614
  }
40476
40615
  function loadSessionContext(repoRoot) {
40477
- const filePath = join53(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
40616
+ const filePath = join54(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
40478
40617
  try {
40479
- if (!existsSync36(filePath))
40618
+ if (!existsSync37(filePath))
40480
40619
  return null;
40481
- return JSON.parse(readFileSync27(filePath, "utf-8"));
40620
+ return JSON.parse(readFileSync28(filePath, "utf-8"));
40482
40621
  } catch {
40483
40622
  return null;
40484
40623
  }
@@ -40524,12 +40663,12 @@ function detectManifests(repoRoot) {
40524
40663
  { file: "docker-compose.yaml", type: "Docker Compose" }
40525
40664
  ];
40526
40665
  for (const check of checks) {
40527
- const filePath = join53(repoRoot, check.file);
40528
- if (existsSync36(filePath)) {
40666
+ const filePath = join54(repoRoot, check.file);
40667
+ if (existsSync37(filePath)) {
40529
40668
  let name;
40530
40669
  if (check.nameField) {
40531
40670
  try {
40532
- const data = JSON.parse(readFileSync27(filePath, "utf-8"));
40671
+ const data = JSON.parse(readFileSync28(filePath, "utf-8"));
40533
40672
  name = data[check.nameField];
40534
40673
  } catch {
40535
40674
  }
@@ -40558,7 +40697,7 @@ function findKeyFiles(repoRoot) {
40558
40697
  { pattern: "CLAUDE.md", description: "Claude Code context" }
40559
40698
  ];
40560
40699
  for (const check of checks) {
40561
- if (existsSync36(join53(repoRoot, check.pattern))) {
40700
+ if (existsSync37(join54(repoRoot, check.pattern))) {
40562
40701
  keyFiles.push({ path: check.pattern, description: check.description });
40563
40702
  }
40564
40703
  }
@@ -40584,12 +40723,12 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
40584
40723
  if (entry.isDirectory()) {
40585
40724
  let fileCount = 0;
40586
40725
  try {
40587
- fileCount = readdirSync10(join53(root, entry.name)).filter((f) => !f.startsWith(".")).length;
40726
+ fileCount = readdirSync10(join54(root, entry.name)).filter((f) => !f.startsWith(".")).length;
40588
40727
  } catch {
40589
40728
  }
40590
40729
  result += `${prefix}${connector}${entry.name}/ (${fileCount})
40591
40730
  `;
40592
- result += buildDirTree(join53(root, entry.name), maxDepth, childPrefix, depth + 1);
40731
+ result += buildDirTree(join54(root, entry.name), maxDepth, childPrefix, depth + 1);
40593
40732
  } else if (depth < maxDepth) {
40594
40733
  result += `${prefix}${connector}${entry.name}
40595
40734
  `;
@@ -40601,17 +40740,17 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
40601
40740
  }
40602
40741
  function loadUsageFile(filePath) {
40603
40742
  try {
40604
- if (existsSync36(filePath)) {
40605
- return JSON.parse(readFileSync27(filePath, "utf-8"));
40743
+ if (existsSync37(filePath)) {
40744
+ return JSON.parse(readFileSync28(filePath, "utf-8"));
40606
40745
  }
40607
40746
  } catch {
40608
40747
  }
40609
40748
  return { records: [] };
40610
40749
  }
40611
40750
  function saveUsageFile(filePath, data) {
40612
- const dir = join53(filePath, "..");
40613
- mkdirSync14(dir, { recursive: true });
40614
- writeFileSync15(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
40751
+ const dir = join54(filePath, "..");
40752
+ mkdirSync15(dir, { recursive: true });
40753
+ writeFileSync16(filePath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
40615
40754
  }
40616
40755
  function recordUsage(kind, value, opts) {
40617
40756
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -40639,15 +40778,15 @@ function recordUsage(kind, value, opts) {
40639
40778
  }
40640
40779
  saveUsageFile(filePath, data);
40641
40780
  };
40642
- update(join53(homedir12(), ".open-agents", USAGE_HISTORY_FILE));
40781
+ update(join54(homedir13(), ".open-agents", USAGE_HISTORY_FILE));
40643
40782
  if (opts?.repoRoot) {
40644
- update(join53(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
40783
+ update(join54(opts.repoRoot, OA_DIR, USAGE_HISTORY_FILE));
40645
40784
  }
40646
40785
  }
40647
40786
  function loadUsageHistory(kind, repoRoot) {
40648
- const globalPath = join53(homedir12(), ".open-agents", USAGE_HISTORY_FILE);
40787
+ const globalPath = join54(homedir13(), ".open-agents", USAGE_HISTORY_FILE);
40649
40788
  const globalData = loadUsageFile(globalPath);
40650
- const localData = repoRoot ? loadUsageFile(join53(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
40789
+ const localData = repoRoot ? loadUsageFile(join54(repoRoot, OA_DIR, USAGE_HISTORY_FILE)) : { records: [] };
40651
40790
  const map = /* @__PURE__ */ new Map();
40652
40791
  for (const r of globalData.records) {
40653
40792
  if (r.kind !== kind)
@@ -40678,9 +40817,9 @@ function deleteUsageRecord(kind, value, repoRoot) {
40678
40817
  saveUsageFile(filePath, data);
40679
40818
  }
40680
40819
  };
40681
- remove(join53(homedir12(), ".open-agents", USAGE_HISTORY_FILE));
40820
+ remove(join54(homedir13(), ".open-agents", USAGE_HISTORY_FILE));
40682
40821
  if (repoRoot) {
40683
- remove(join53(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
40822
+ remove(join54(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
40684
40823
  }
40685
40824
  }
40686
40825
  var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
@@ -41525,9 +41664,9 @@ __export(personaplex_exports, {
41525
41664
  startPersonaPlexDaemon: () => startPersonaPlexDaemon,
41526
41665
  stopPersonaPlex: () => stopPersonaPlex
41527
41666
  });
41528
- import { existsSync as existsSync37, writeFileSync as writeFileSync16, readFileSync as readFileSync28, mkdirSync as mkdirSync15, copyFileSync as copyFileSync2, readdirSync as readdirSync11, statSync as statSync13 } from "node:fs";
41529
- import { join as join54, dirname as dirname18 } from "node:path";
41530
- import { homedir as homedir13 } from "node:os";
41667
+ import { existsSync as existsSync38, writeFileSync as writeFileSync17, readFileSync as readFileSync29, mkdirSync as mkdirSync16, copyFileSync as copyFileSync2, readdirSync as readdirSync11, statSync as statSync13 } from "node:fs";
41668
+ import { join as join55, dirname as dirname18 } from "node:path";
41669
+ import { homedir as homedir14 } from "node:os";
41531
41670
  import { execSync as execSync28, spawn as spawn19, execFile as execFile7 } from "node:child_process";
41532
41671
  import { fileURLToPath as fileURLToPath11 } from "node:url";
41533
41672
  function execAsync(cmd, opts = {}) {
@@ -41563,7 +41702,7 @@ function selectWeightTier(vramGB) {
41563
41702
  }
41564
41703
  function detectJetson() {
41565
41704
  try {
41566
- const model = readFileSync28("/proc/device-tree/model", "utf8").replace(/\0/g, "").trim();
41705
+ const model = readFileSync29("/proc/device-tree/model", "utf8").replace(/\0/g, "").trim();
41567
41706
  if (/jetson|orin|tegra/i.test(model)) {
41568
41707
  const memInfo = execSync28("grep MemTotal /proc/meminfo", { encoding: "utf8", timeout: 3e3, stdio: "pipe" });
41569
41708
  const memKB = parseInt(memInfo.match(/(\d+)/)?.[1] ?? "0", 10);
@@ -41642,9 +41781,9 @@ function fileLink2(filePath, label) {
41642
41781
  return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
41643
41782
  }
41644
41783
  function isPersonaPlexRunning() {
41645
- if (!existsSync37(PID_FILE))
41784
+ if (!existsSync38(PID_FILE))
41646
41785
  return false;
41647
- const pid = parseInt(readFileSync28(PID_FILE, "utf8").trim(), 10);
41786
+ const pid = parseInt(readFileSync29(PID_FILE, "utf8").trim(), 10);
41648
41787
  if (isNaN(pid) || pid <= 0)
41649
41788
  return false;
41650
41789
  try {
@@ -41657,23 +41796,23 @@ function isPersonaPlexRunning() {
41657
41796
  function getPersonaPlexWSUrl() {
41658
41797
  if (!isPersonaPlexRunning())
41659
41798
  return null;
41660
- if (!existsSync37(PORT_FILE))
41799
+ if (!existsSync38(PORT_FILE))
41661
41800
  return null;
41662
- const port = parseInt(readFileSync28(PORT_FILE, "utf8").trim(), 10);
41801
+ const port = parseInt(readFileSync29(PORT_FILE, "utf8").trim(), 10);
41663
41802
  return isNaN(port) ? null : `wss://127.0.0.1:${port}`;
41664
41803
  }
41665
41804
  function isPersonaPlexInstalled() {
41666
- return existsSync37(join54(PERSONAPLEX_DIR, "model_ready"));
41805
+ return existsSync38(join55(PERSONAPLEX_DIR, "model_ready"));
41667
41806
  }
41668
41807
  function getWeightTier() {
41669
41808
  const detected = detectPersonaPlexCapability();
41670
- const tierFile = join54(PERSONAPLEX_DIR, "weight_tier");
41671
- if (existsSync37(tierFile)) {
41672
- const saved = readFileSync28(tierFile, "utf8").trim();
41809
+ const tierFile = join55(PERSONAPLEX_DIR, "weight_tier");
41810
+ if (existsSync38(tierFile)) {
41811
+ const saved = readFileSync29(tierFile, "utf8").trim();
41673
41812
  if (saved in WEIGHT_REPOS) {
41674
41813
  const vram = detected.vramGB;
41675
41814
  if (saved === "nf4-distilled" && vram < 24) {
41676
- writeFileSync16(tierFile, "nf4");
41815
+ writeFileSync17(tierFile, "nf4");
41677
41816
  return "nf4";
41678
41817
  }
41679
41818
  return saved;
@@ -41687,7 +41826,7 @@ function getWeightRepoInfo(tier) {
41687
41826
  async function installPersonaPlex(onInfo, weightTier) {
41688
41827
  const log2 = onInfo ?? (() => {
41689
41828
  });
41690
- mkdirSync15(PERSONAPLEX_DIR, { recursive: true });
41829
+ mkdirSync16(PERSONAPLEX_DIR, { recursive: true });
41691
41830
  let arch2 = "";
41692
41831
  try {
41693
41832
  arch2 = execSync28("uname -m", { encoding: "utf8", timeout: 3e3, stdio: "pipe" }).trim();
@@ -41696,8 +41835,8 @@ async function installPersonaPlex(onInfo, weightTier) {
41696
41835
  const isAarch64 = arch2 === "aarch64" || arch2 === "arm64";
41697
41836
  if (isAarch64)
41698
41837
  log2(`Detected ARM64 platform (${arch2}) \u2014 Jetson/ARM install path`);
41699
- const venvDir = join54(PERSONAPLEX_DIR, "venv");
41700
- if (!existsSync37(venvDir)) {
41838
+ const venvDir = join55(PERSONAPLEX_DIR, "venv");
41839
+ if (!existsSync38(venvDir)) {
41701
41840
  log2("Creating Python virtual environment...");
41702
41841
  try {
41703
41842
  const ssp = isAarch64 ? " --system-site-packages" : "";
@@ -41707,8 +41846,8 @@ async function installPersonaPlex(onInfo, weightTier) {
41707
41846
  return false;
41708
41847
  }
41709
41848
  }
41710
- const pip = process.platform === "win32" ? join54(venvDir, "Scripts", "pip.exe") : join54(venvDir, "bin", "pip");
41711
- const python = process.platform === "win32" ? join54(venvDir, "Scripts", "python.exe") : join54(venvDir, "bin", "python3");
41849
+ const pip = process.platform === "win32" ? join55(venvDir, "Scripts", "pip.exe") : join55(venvDir, "bin", "pip");
41850
+ const python = process.platform === "win32" ? join55(venvDir, "Scripts", "python.exe") : join55(venvDir, "bin", "python3");
41712
41851
  log2("Checking system dependencies (libopus)...");
41713
41852
  try {
41714
41853
  if (process.platform === "linux") {
@@ -41738,9 +41877,9 @@ async function installPersonaPlex(onInfo, weightTier) {
41738
41877
  }
41739
41878
  }
41740
41879
  log2("Installing PersonaPlex (moshi package)...");
41741
- const repoDir = join54(PERSONAPLEX_DIR, "personaplex-repo");
41880
+ const repoDir = join55(PERSONAPLEX_DIR, "personaplex-repo");
41742
41881
  try {
41743
- if (!existsSync37(repoDir)) {
41882
+ if (!existsSync38(repoDir)) {
41744
41883
  await execAsync(`git clone https://github.com/NVIDIA/personaplex.git "${repoDir}"`, { timeout: 12e4 });
41745
41884
  }
41746
41885
  if (isAarch64) {
@@ -41757,11 +41896,11 @@ async function installPersonaPlex(onInfo, weightTier) {
41757
41896
  }
41758
41897
  if (isAarch64) {
41759
41898
  log2("ARM64: Installing moshi (--no-deps to preserve JetPack torch)...");
41760
- await execAsync(`"${pip}" install --quiet --no-deps "${join54(repoDir, "moshi")}/."`, { timeout: 3e5 });
41899
+ await execAsync(`"${pip}" install --quiet --no-deps "${join55(repoDir, "moshi")}/."`, { timeout: 3e5 });
41761
41900
  log2("ARM64: Installing remaining moshi dependencies...");
41762
41901
  await execAsync(`"${pip}" install --quiet "numpy>=1.26,<2.2" "safetensors>=0.4.0,<0.5" "huggingface-hub>=0.24,<0.25" "einops==0.7" "sentencepiece==0.2" "sounddevice==0.5" "aiohttp>=3.10.5,<3.11"`, { timeout: 3e5 });
41763
41902
  } else {
41764
- await execAsync(`"${pip}" install --quiet "${join54(repoDir, "moshi")}/."`, { timeout: 6e5 });
41903
+ await execAsync(`"${pip}" install --quiet "${join55(repoDir, "moshi")}/."`, { timeout: 6e5 });
41765
41904
  }
41766
41905
  } catch (err) {
41767
41906
  log2(`Moshi install failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -41776,19 +41915,19 @@ async function installPersonaPlex(onInfo, weightTier) {
41776
41915
  }
41777
41916
  return false;
41778
41917
  }
41779
- const serverPy = join54(venvDir, "lib", `python3.${process.versions.node ? "12" : "10"}`, "site-packages", "moshi", "server.py");
41918
+ const serverPy = join55(venvDir, "lib", `python3.${process.versions.node ? "12" : "10"}`, "site-packages", "moshi", "server.py");
41780
41919
  try {
41781
41920
  const sitePackages = execSync28(`"${python}" -c "import moshi, os; print(os.path.dirname(moshi.__file__))"`, {
41782
41921
  encoding: "utf8",
41783
41922
  timeout: 5e3,
41784
41923
  stdio: "pipe"
41785
41924
  }).trim();
41786
- const serverFile = join54(sitePackages, "server.py");
41787
- if (existsSync37(serverFile)) {
41788
- let src = readFileSync28(serverFile, "utf8");
41925
+ const serverFile = join55(sitePackages, "server.py");
41926
+ if (existsSync38(serverFile)) {
41927
+ let src = readFileSync29(serverFile, "utf8");
41789
41928
  if (src.includes('int(request["seed"])')) {
41790
41929
  src = src.replace('int(request["seed"])', 'int(request.query["seed"])');
41791
- writeFileSync16(serverFile, src);
41930
+ writeFileSync17(serverFile, src);
41792
41931
  log2("Applied seed parameter bug fix to moshi server.");
41793
41932
  }
41794
41933
  }
@@ -41800,9 +41939,9 @@ async function installPersonaPlex(onInfo, weightTier) {
41800
41939
  timeout: 5e3,
41801
41940
  stdio: "pipe"
41802
41941
  }).trim();
41803
- const loadersFile = join54(sitePackages, "models", "loaders.py");
41804
- if (existsSync37(loadersFile)) {
41805
- let src = readFileSync28(loadersFile, "utf8");
41942
+ const loadersFile = join55(sitePackages, "models", "loaders.py");
41943
+ if (existsSync38(loadersFile)) {
41944
+ let src = readFileSync29(loadersFile, "utf8");
41806
41945
  if (!src.includes("_dequantize_2bit_state_dict")) {
41807
41946
  const dequantPatch = `
41808
41947
  import math
@@ -41886,7 +42025,7 @@ $2if filename.endswith(".safetensors"):`);
41886
42025
 
41887
42026
  ${patchPoint}`);
41888
42027
  }
41889
- writeFileSync16(loadersFile, src);
42028
+ writeFileSync17(loadersFile, src);
41890
42029
  log2("Patched loaders.py with 2-bit TurboQuant native dequant support.");
41891
42030
  }
41892
42031
  }
@@ -41898,24 +42037,24 @@ $2if filename.endswith(".safetensors"):`);
41898
42037
  timeout: 5e3,
41899
42038
  stdio: "pipe"
41900
42039
  }).trim();
41901
- const hybridDest = join54(sitePackages2, "hybrid_agent.py");
41902
- const serverDest = join54(sitePackages2, "server.py");
41903
- if (!existsSync37(hybridDest) || !readFileSync28(hybridDest, "utf8").includes("OA_API_BASE")) {
42040
+ const hybridDest = join55(sitePackages2, "hybrid_agent.py");
42041
+ const serverDest = join55(sitePackages2, "server.py");
42042
+ if (!existsSync38(hybridDest) || !readFileSync29(hybridDest, "utf8").includes("OA_API_BASE")) {
41904
42043
  log2("Deploying hybrid_agent.py (OA API integration)...");
41905
42044
  try {
41906
42045
  await execAsync(`curl -sL "https://raw.githubusercontent.com/robit-man/personaplex/main/personaplex-setup/moshi/moshi/hybrid_agent.py" -o "${hybridDest}"`, { timeout: 3e4 });
41907
- if (existsSync37(hybridDest) && readFileSync28(hybridDest, "utf8").includes("OA_API_BASE")) {
42046
+ if (existsSync38(hybridDest) && readFileSync29(hybridDest, "utf8").includes("OA_API_BASE")) {
41908
42047
  log2("hybrid_agent.py deployed (OA API + Ollama fallback).");
41909
42048
  }
41910
42049
  } catch {
41911
42050
  log2("hybrid_agent.py download failed \u2014 hybrid mode will be disabled.");
41912
42051
  }
41913
42052
  }
41914
- if (!readFileSync28(serverDest, "utf8").includes("hybrid_agent")) {
42053
+ if (!readFileSync29(serverDest, "utf8").includes("hybrid_agent")) {
41915
42054
  log2("Deploying patched server.py (hybrid mode + API endpoints)...");
41916
42055
  try {
41917
42056
  await execAsync(`curl -sL "https://raw.githubusercontent.com/robit-man/personaplex/main/personaplex-setup/moshi/moshi/server.py" -o "${serverDest}"`, { timeout: 3e4 });
41918
- if (readFileSync28(serverDest, "utf8").includes("hybrid_agent")) {
42057
+ if (readFileSync29(serverDest, "utf8").includes("hybrid_agent")) {
41919
42058
  log2("server.py patched with hybrid intercept + REST APIs.");
41920
42059
  }
41921
42060
  } catch {
@@ -41978,7 +42117,7 @@ $2if filename.endswith(".safetensors"):`);
41978
42117
  await execAsync(`"${python}" -c "from huggingface_hub import hf_hub_download; hf_hub_download('${nf4.repo}', '${nf4.file}', token=False)"`, {
41979
42118
  timeout: 6e5
41980
42119
  });
41981
- writeFileSync16(join54(PERSONAPLEX_DIR, "weight_tier"), "nf4");
42120
+ writeFileSync17(join55(PERSONAPLEX_DIR, "weight_tier"), "nf4");
41982
42121
  log2(`Downloaded INT4 weights instead (${nf4.sizeGB}GB, public).`);
41983
42122
  } catch {
41984
42123
  log2("Weight download failed.");
@@ -41990,8 +42129,8 @@ $2if filename.endswith(".safetensors"):`);
41990
42129
  log2("Weights will download on first server launch.");
41991
42130
  }
41992
42131
  }
41993
- writeFileSync16(join54(PERSONAPLEX_DIR, "weight_tier"), tier);
41994
- writeFileSync16(join54(PERSONAPLEX_DIR, "model_ready"), (/* @__PURE__ */ new Date()).toISOString());
42132
+ writeFileSync17(join55(PERSONAPLEX_DIR, "weight_tier"), tier);
42133
+ writeFileSync17(join55(PERSONAPLEX_DIR, "model_ready"), (/* @__PURE__ */ new Date()).toISOString());
41995
42134
  log2(`PersonaPlex installed (${tier} tier). Use /call to start voice session.`);
41996
42135
  return true;
41997
42136
  }
@@ -42010,21 +42149,21 @@ async function startPersonaPlexDaemon(onInfo) {
42010
42149
  log2("PersonaPlex not installed. Run /voice personaplex to set up.");
42011
42150
  return null;
42012
42151
  }
42013
- mkdirSync15(PERSONAPLEX_DIR, { recursive: true });
42014
- const venvPython2 = process.platform === "win32" ? join54(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join54(PERSONAPLEX_DIR, "venv", "bin", "python3");
42015
- const sslDir = join54(PERSONAPLEX_DIR, "ssl");
42016
- mkdirSync15(sslDir, { recursive: true });
42152
+ mkdirSync16(PERSONAPLEX_DIR, { recursive: true });
42153
+ const venvPython2 = process.platform === "win32" ? join55(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join55(PERSONAPLEX_DIR, "venv", "bin", "python3");
42154
+ const sslDir = join55(PERSONAPLEX_DIR, "ssl");
42155
+ mkdirSync16(sslDir, { recursive: true });
42017
42156
  const tier = getWeightTier();
42018
42157
  const repoInfo = WEIGHT_REPOS[tier];
42019
42158
  const extraArgs = [];
42020
42159
  if (tier !== "original") {
42021
- const cachedBf16 = join54(PERSONAPLEX_DIR, "model-bf16-cache.safetensors");
42160
+ const cachedBf16 = join55(PERSONAPLEX_DIR, "model-bf16-cache.safetensors");
42022
42161
  if (tier === "nf4-distilled") {
42023
42162
  log2(`Weight tier: ${tier} \u2014 distilled NF4 (90% token match, ${repoInfo.sizeGB}GB)...`);
42024
42163
  try {
42025
42164
  const weightPath = execSync28(`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', '${repoInfo.file}', token=False))"`, { encoding: "utf8", timeout: 6e4, stdio: "pipe" }).trim();
42026
- if (existsSync37(weightPath)) {
42027
- if (!existsSync37(cachedBf16)) {
42165
+ if (existsSync38(weightPath)) {
42166
+ if (!existsSync38(cachedBf16)) {
42028
42167
  log2("Converting .pt checkpoint to safetensors (one-time)...");
42029
42168
  execSync28(`"${venvPython2}" -c "
42030
42169
  import torch; from safetensors.torch import save_file
@@ -42034,7 +42173,7 @@ save_file(state, '${cachedBf16}')
42034
42173
  print('Converted')
42035
42174
  "`, { timeout: 18e4, stdio: "pipe" });
42036
42175
  }
42037
- if (existsSync37(cachedBf16)) {
42176
+ if (existsSync38(cachedBf16)) {
42038
42177
  extraArgs.push("--moshi-weight", cachedBf16);
42039
42178
  log2(`Using distilled weights: ${(statSync13(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
42040
42179
  } else {
@@ -42046,21 +42185,21 @@ print('Converted')
42046
42185
  }
42047
42186
  } else {
42048
42187
  log2(`Weight tier: ${tier} (${repoInfo.sizeGB}GB) \u2014 dequantizing to bf16 cache...`);
42049
- const dequantScript = join54(PERSONAPLEX_DIR, "dequant-loader.py");
42050
- if (!existsSync37(dequantScript)) {
42188
+ const dequantScript = join55(PERSONAPLEX_DIR, "dequant-loader.py");
42189
+ if (!existsSync38(dequantScript)) {
42051
42190
  const shipped = getShippedVoicesDir();
42052
42191
  if (shipped) {
42053
- const src = join54(shipped, "dequant-loader.py");
42054
- if (existsSync37(src))
42192
+ const src = join55(shipped, "dequant-loader.py");
42193
+ if (existsSync38(src))
42055
42194
  copyFileSync2(src, dequantScript);
42056
42195
  }
42057
42196
  }
42058
42197
  try {
42059
42198
  const weightPath = execSync28(`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', '${repoInfo.file}'${repoInfo.needsToken ? "" : ", token=False"}))"`, { encoding: "utf8", timeout: 3e4, stdio: "pipe" }).trim();
42060
- if (existsSync37(dequantScript) && existsSync37(weightPath)) {
42199
+ if (existsSync38(dequantScript) && existsSync38(weightPath)) {
42061
42200
  try {
42062
42201
  execSync28(`"${venvPython2}" "${dequantScript}" --input "${weightPath}" --output "${cachedBf16}"`, { timeout: 3e5, stdio: "pipe" });
42063
- if (existsSync37(cachedBf16)) {
42202
+ if (existsSync38(cachedBf16)) {
42064
42203
  extraArgs.push("--moshi-weight", cachedBf16);
42065
42204
  log2(`Using dequantized cache: ${(statSync13(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
42066
42205
  }
@@ -42070,13 +42209,13 @@ print('Converted')
42070
42209
  }
42071
42210
  try {
42072
42211
  const mimiPath = execSync28(`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', 'tokenizer-e351c8d8-checkpoint125.safetensors', token=False))"`, { encoding: "utf8", timeout: 3e4, stdio: "pipe" }).trim();
42073
- if (existsSync37(mimiPath))
42212
+ if (existsSync38(mimiPath))
42074
42213
  extraArgs.push("--mimi-weight", mimiPath);
42075
42214
  } catch {
42076
42215
  }
42077
42216
  try {
42078
42217
  const tokPath = execSync28(`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', 'tokenizer_spm_32k_3.model', token=False))"`, { encoding: "utf8", timeout: 3e4, stdio: "pipe" }).trim();
42079
- if (existsSync37(tokPath))
42218
+ if (existsSync38(tokPath))
42080
42219
  extraArgs.push("--tokenizer", tokPath);
42081
42220
  } catch {
42082
42221
  }
@@ -42090,7 +42229,7 @@ print('Converted')
42090
42229
  let ollamaModel = process.env["HYBRID_LLM_MODEL"] || "";
42091
42230
  if (!ollamaModel) {
42092
42231
  try {
42093
- const oaConfig = JSON.parse(readFileSync28(join54(homedir13(), ".open-agents", "config.json"), "utf8"));
42232
+ const oaConfig = JSON.parse(readFileSync29(join55(homedir14(), ".open-agents", "config.json"), "utf8"));
42094
42233
  if (oaConfig.model)
42095
42234
  ollamaModel = oaConfig.model;
42096
42235
  } catch {
@@ -42147,8 +42286,8 @@ print('Converted')
42147
42286
  cwd: PERSONAPLEX_DIR
42148
42287
  });
42149
42288
  if (child.pid) {
42150
- writeFileSync16(PID_FILE, String(child.pid));
42151
- writeFileSync16(PORT_FILE, String(PORT));
42289
+ writeFileSync17(PID_FILE, String(child.pid));
42290
+ writeFileSync17(PORT_FILE, String(PORT));
42152
42291
  registry.register({
42153
42292
  name: "PersonaPlex",
42154
42293
  pid: child.pid,
@@ -42195,9 +42334,9 @@ print('Converted')
42195
42334
  return null;
42196
42335
  }
42197
42336
  function stopPersonaPlex() {
42198
- if (!existsSync37(PID_FILE))
42337
+ if (!existsSync38(PID_FILE))
42199
42338
  return;
42200
- const pid = parseInt(readFileSync28(PID_FILE, "utf8").trim(), 10);
42339
+ const pid = parseInt(readFileSync29(PID_FILE, "utf8").trim(), 10);
42201
42340
  if (isNaN(pid) || pid <= 0)
42202
42341
  return;
42203
42342
  try {
@@ -42234,12 +42373,12 @@ function listPersonaPlexVoices() {
42234
42373
  for (const name of builtins) {
42235
42374
  voices.push({ name, type: "builtin", path: `${name}.pt` });
42236
42375
  }
42237
- if (existsSync37(CUSTOM_VOICES_DIR)) {
42376
+ if (existsSync38(CUSTOM_VOICES_DIR)) {
42238
42377
  try {
42239
42378
  for (const f of readdirSync11(CUSTOM_VOICES_DIR)) {
42240
42379
  if (f.endsWith(".pt")) {
42241
42380
  const name = f.replace(/\.pt$/, "");
42242
- voices.push({ name, type: "custom", path: join54(CUSTOM_VOICES_DIR, f) });
42381
+ voices.push({ name, type: "custom", path: join55(CUSTOM_VOICES_DIR, f) });
42243
42382
  }
42244
42383
  }
42245
42384
  } catch {
@@ -42254,19 +42393,19 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
42254
42393
  log2("PersonaPlex not installed. Run /voice personaplex first.");
42255
42394
  return null;
42256
42395
  }
42257
- if (!existsSync37(inputWav)) {
42396
+ if (!existsSync38(inputWav)) {
42258
42397
  log2(`Input WAV not found: ${inputWav}`);
42259
42398
  return null;
42260
42399
  }
42261
- mkdirSync15(CUSTOM_VOICES_DIR, { recursive: true });
42262
- const outputPt = join54(CUSTOM_VOICES_DIR, `${voiceName}.pt`);
42263
- if (existsSync37(outputPt)) {
42400
+ mkdirSync16(CUSTOM_VOICES_DIR, { recursive: true });
42401
+ const outputPt = join55(CUSTOM_VOICES_DIR, `${voiceName}.pt`);
42402
+ if (existsSync38(outputPt)) {
42264
42403
  log2(`Voice "${voiceName}" already exists. Delete ${outputPt} to re-clone.`);
42265
42404
  return outputPt;
42266
42405
  }
42267
- const venvPython2 = process.platform === "win32" ? join54(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join54(PERSONAPLEX_DIR, "venv", "bin", "python3");
42268
- const cloneScript = join54(PERSONAPLEX_DIR, "clone-voice.py");
42269
- if (!existsSync37(cloneScript)) {
42406
+ const venvPython2 = process.platform === "win32" ? join55(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join55(PERSONAPLEX_DIR, "venv", "bin", "python3");
42407
+ const cloneScript = join55(PERSONAPLEX_DIR, "clone-voice.py");
42408
+ if (!existsSync38(cloneScript)) {
42270
42409
  log2("clone-voice.py not found. Reinstall PersonaPlex.");
42271
42410
  return null;
42272
42411
  }
@@ -42298,7 +42437,7 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
42298
42437
  output += d.toString();
42299
42438
  });
42300
42439
  child.on("close", (code) => {
42301
- if (code === 0 && existsSync37(outputPt)) {
42440
+ if (code === 0 && existsSync38(outputPt)) {
42302
42441
  log2(`Voice "${voiceName}" cloned successfully.`);
42303
42442
  resolve36(outputPt);
42304
42443
  } else {
@@ -42310,19 +42449,19 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
42310
42449
  }
42311
42450
  function getShippedVoicesDir() {
42312
42451
  const candidates = [
42313
- join54(PERSONAPLEX_DIR, "shipped_voices"),
42452
+ join55(PERSONAPLEX_DIR, "shipped_voices"),
42314
42453
  // cached copy
42315
- join54(process.cwd(), "voices", "personaplex")
42454
+ join55(process.cwd(), "voices", "personaplex")
42316
42455
  // repo root
42317
42456
  ];
42318
42457
  try {
42319
42458
  const modDir = dirname18(fileURLToPath11(import.meta.url));
42320
- candidates.push(join54(modDir, "..", "..", "..", "voices", "personaplex"));
42321
- candidates.push(join54(modDir, "..", "..", "..", "..", "voices", "personaplex"));
42459
+ candidates.push(join55(modDir, "..", "..", "..", "voices", "personaplex"));
42460
+ candidates.push(join55(modDir, "..", "..", "..", "..", "voices", "personaplex"));
42322
42461
  } catch {
42323
42462
  }
42324
42463
  for (const dir of candidates) {
42325
- if (existsSync37(dir)) {
42464
+ if (existsSync38(dir)) {
42326
42465
  try {
42327
42466
  const files = readdirSync11(dir);
42328
42467
  if (files.some((f) => f.endsWith(".pt")))
@@ -42340,20 +42479,20 @@ function provisionShippedVoices(onInfo) {
42340
42479
  if (!shippedDir)
42341
42480
  return 0;
42342
42481
  const hfVoicesDir = getHFVoicesDir();
42343
- mkdirSync15(CUSTOM_VOICES_DIR, { recursive: true });
42482
+ mkdirSync16(CUSTOM_VOICES_DIR, { recursive: true });
42344
42483
  let deployed = 0;
42345
42484
  try {
42346
42485
  for (const f of readdirSync11(shippedDir)) {
42347
42486
  if (!f.endsWith(".pt"))
42348
42487
  continue;
42349
- const customDst = join54(CUSTOM_VOICES_DIR, f);
42350
- if (!existsSync37(customDst)) {
42351
- copyFileSync2(join54(shippedDir, f), customDst);
42488
+ const customDst = join55(CUSTOM_VOICES_DIR, f);
42489
+ if (!existsSync38(customDst)) {
42490
+ copyFileSync2(join55(shippedDir, f), customDst);
42352
42491
  }
42353
42492
  if (hfVoicesDir) {
42354
- const hfDst = join54(hfVoicesDir, f);
42355
- if (!existsSync37(hfDst)) {
42356
- copyFileSync2(join54(shippedDir, f), hfDst);
42493
+ const hfDst = join55(hfVoicesDir, f);
42494
+ if (!existsSync38(hfDst)) {
42495
+ copyFileSync2(join55(shippedDir, f), hfDst);
42357
42496
  log2(`Deployed voice: ${f.replace(".pt", "")}`);
42358
42497
  deployed++;
42359
42498
  }
@@ -42361,9 +42500,9 @@ function provisionShippedVoices(onInfo) {
42361
42500
  }
42362
42501
  } catch {
42363
42502
  }
42364
- const shippedScript = join54(shippedDir, "clone-voice.py");
42365
- const targetScript = join54(PERSONAPLEX_DIR, "clone-voice.py");
42366
- if (existsSync37(shippedScript) && !existsSync37(targetScript)) {
42503
+ const shippedScript = join55(shippedDir, "clone-voice.py");
42504
+ const targetScript = join55(PERSONAPLEX_DIR, "clone-voice.py");
42505
+ if (existsSync38(shippedScript) && !existsSync38(targetScript)) {
42367
42506
  try {
42368
42507
  copyFileSync2(shippedScript, targetScript);
42369
42508
  } catch {
@@ -42372,16 +42511,16 @@ function provisionShippedVoices(onInfo) {
42372
42511
  return deployed;
42373
42512
  }
42374
42513
  function getHFVoicesDir() {
42375
- const hfBase = join54(homedir13(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
42376
- if (!existsSync37(hfBase))
42514
+ const hfBase = join55(homedir14(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
42515
+ if (!existsSync38(hfBase))
42377
42516
  return null;
42378
42517
  try {
42379
- const snapshots = join54(hfBase, "snapshots");
42380
- if (!existsSync37(snapshots))
42518
+ const snapshots = join55(hfBase, "snapshots");
42519
+ if (!existsSync38(snapshots))
42381
42520
  return null;
42382
42521
  for (const snap of readdirSync11(snapshots)) {
42383
- const voicesDir = join54(snapshots, snap, "voices");
42384
- if (existsSync37(voicesDir))
42522
+ const voicesDir = join55(snapshots, snap, "voices");
42523
+ if (existsSync38(voicesDir))
42385
42524
  return voicesDir;
42386
42525
  }
42387
42526
  } catch {
@@ -42391,22 +42530,22 @@ function getHFVoicesDir() {
42391
42530
  function patchFrontendVoiceList(onInfo) {
42392
42531
  const log2 = onInfo ?? (() => {
42393
42532
  });
42394
- const hfBase = join54(homedir13(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
42395
- if (!existsSync37(hfBase))
42533
+ const hfBase = join55(homedir14(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
42534
+ if (!existsSync38(hfBase))
42396
42535
  return;
42397
42536
  try {
42398
- const snapshots = join54(hfBase, "snapshots");
42537
+ const snapshots = join55(hfBase, "snapshots");
42399
42538
  for (const snap of readdirSync11(snapshots)) {
42400
- const distDir = join54(snapshots, snap, "dist", "assets");
42401
- if (!existsSync37(distDir))
42539
+ const distDir = join55(snapshots, snap, "dist", "assets");
42540
+ if (!existsSync38(distDir))
42402
42541
  continue;
42403
42542
  for (const f of readdirSync11(distDir)) {
42404
42543
  if (!f.startsWith("index-") || !f.endsWith(".js"))
42405
42544
  continue;
42406
- const jsPath = join54(distDir, f);
42407
- let js = readFileSync28(jsPath, "utf8");
42545
+ const jsPath = join55(distDir, f);
42546
+ let js = readFileSync29(jsPath, "utf8");
42408
42547
  const customVoices = [];
42409
- if (existsSync37(CUSTOM_VOICES_DIR)) {
42548
+ if (existsSync38(CUSTOM_VOICES_DIR)) {
42410
42549
  for (const vf of readdirSync11(CUSTOM_VOICES_DIR)) {
42411
42550
  if (vf.endsWith(".pt")) {
42412
42551
  const name = vf.replace(".pt", "");
@@ -42422,7 +42561,7 @@ function patchFrontendVoiceList(onInfo) {
42422
42561
  if (js.includes(needle)) {
42423
42562
  const additions = customVoices.map((v) => `"${v}"`).join(", ");
42424
42563
  js = js.replace(needle, `"VARM4.pt", ${additions}]`);
42425
- writeFileSync16(jsPath, js);
42564
+ writeFileSync17(jsPath, js);
42426
42565
  log2(`Added ${customVoices.length} custom voice(s) to frontend: ${customVoices.map((v) => v.replace(".pt", "")).join(", ")}`);
42427
42566
  }
42428
42567
  }
@@ -42473,11 +42612,11 @@ var init_personaplex = __esm({
42473
42612
  nf4: { repo: "cudabenchmarktest/personaplex-7b-nf4", file: "model-nf4.safetensors", sizeGB: 4.1, needsToken: false },
42474
42613
  "nf4-distilled": { repo: "cudabenchmarktest/personaplex-7b-nf4-distilled", file: "student_best.pt", sizeGB: 16.7, needsToken: false }
42475
42614
  };
42476
- PERSONAPLEX_DIR = join54(homedir13(), ".open-agents", "voice", "personaplex");
42477
- PID_FILE = join54(PERSONAPLEX_DIR, "daemon.pid");
42478
- PORT_FILE = join54(PERSONAPLEX_DIR, "daemon.port");
42479
- LOG_FILE = join54(PERSONAPLEX_DIR, "daemon.log");
42480
- CUSTOM_VOICES_DIR = join54(PERSONAPLEX_DIR, "custom_voices");
42615
+ PERSONAPLEX_DIR = join55(homedir14(), ".open-agents", "voice", "personaplex");
42616
+ PID_FILE = join55(PERSONAPLEX_DIR, "daemon.pid");
42617
+ PORT_FILE = join55(PERSONAPLEX_DIR, "daemon.port");
42618
+ LOG_FILE = join55(PERSONAPLEX_DIR, "daemon.log");
42619
+ CUSTOM_VOICES_DIR = join55(PERSONAPLEX_DIR, "custom_voices");
42481
42620
  }
42482
42621
  });
42483
42622
 
@@ -42485,9 +42624,9 @@ var init_personaplex = __esm({
42485
42624
  import * as readline from "node:readline";
42486
42625
  import { execSync as execSync29, spawn as spawn20, exec as exec2 } from "node:child_process";
42487
42626
  import { promisify as promisify6 } from "node:util";
42488
- import { existsSync as existsSync38, writeFileSync as writeFileSync17, readFileSync as readFileSync29, appendFileSync as appendFileSync2, mkdirSync as mkdirSync16 } from "node:fs";
42489
- import { join as join55 } from "node:path";
42490
- import { homedir as homedir14, platform as platform2 } from "node:os";
42627
+ import { existsSync as existsSync39, writeFileSync as writeFileSync18, readFileSync as readFileSync30, appendFileSync as appendFileSync2, mkdirSync as mkdirSync17 } from "node:fs";
42628
+ import { join as join56 } from "node:path";
42629
+ import { homedir as homedir15, platform as platform2 } from "node:os";
42491
42630
  async function checkToolSupport(modelName, backendUrl = "http://localhost:11434") {
42492
42631
  if (_toolSupportCache.has(modelName))
42493
42632
  return _toolSupportCache.get(modelName);
@@ -42789,7 +42928,7 @@ async function installOllamaMac(_rl) {
42789
42928
  execSync29('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"', { stdio: "inherit", timeout: 6e5 });
42790
42929
  if (!hasCmd("brew")) {
42791
42930
  try {
42792
- const brewPrefix = existsSync38("/opt/homebrew/bin/brew") ? "/opt/homebrew" : "/usr/local";
42931
+ const brewPrefix = existsSync39("/opt/homebrew/bin/brew") ? "/opt/homebrew" : "/usr/local";
42793
42932
  process.env["PATH"] = `${brewPrefix}/bin:${process.env["PATH"]}`;
42794
42933
  } catch {
42795
42934
  }
@@ -43534,10 +43673,10 @@ async function doSetup(config, rl) {
43534
43673
  `PARAMETER num_predict ${numPredict}`,
43535
43674
  `PARAMETER stop "<|endoftext|>"`
43536
43675
  ].join("\n");
43537
- const modelDir2 = join55(homedir14(), ".open-agents", "models");
43538
- mkdirSync16(modelDir2, { recursive: true });
43539
- const modelfilePath = join55(modelDir2, `Modelfile.${customName}`);
43540
- writeFileSync17(modelfilePath, modelfileContent + "\n", "utf8");
43676
+ const modelDir2 = join56(homedir15(), ".open-agents", "models");
43677
+ mkdirSync17(modelDir2, { recursive: true });
43678
+ const modelfilePath = join56(modelDir2, `Modelfile.${customName}`);
43679
+ writeFileSync18(modelfilePath, modelfileContent + "\n", "utf8");
43541
43680
  process.stdout.write(` ${c2.dim("Creating model...")} `);
43542
43681
  execSync29(`ollama create ${customName} -f ${modelfilePath}`, {
43543
43682
  stdio: "pipe",
@@ -43582,7 +43721,7 @@ async function isModelAvailable(config) {
43582
43721
  }
43583
43722
  function isFirstRun() {
43584
43723
  try {
43585
- return !existsSync38(join55(homedir14(), ".open-agents", "config.json"));
43724
+ return !existsSync39(join56(homedir15(), ".open-agents", "config.json"));
43586
43725
  } catch {
43587
43726
  return true;
43588
43727
  }
@@ -43633,7 +43772,7 @@ function detectPkgManager() {
43633
43772
  return null;
43634
43773
  }
43635
43774
  function getVenvDir() {
43636
- return join55(homedir14(), ".open-agents", "venv");
43775
+ return join56(homedir15(), ".open-agents", "venv");
43637
43776
  }
43638
43777
  function hasVenvModule() {
43639
43778
  try {
@@ -43646,9 +43785,9 @@ function hasVenvModule() {
43646
43785
  function ensureVenv(log2) {
43647
43786
  const venvDir = getVenvDir();
43648
43787
  const isWin2 = process.platform === "win32";
43649
- const pipPath = isWin2 ? join55(venvDir, "Scripts", "pip.exe") : join55(venvDir, "bin", "pip");
43788
+ const pipPath = isWin2 ? join56(venvDir, "Scripts", "pip.exe") : join56(venvDir, "bin", "pip");
43650
43789
  const pythonCmd = isWin2 ? "python" : "python3";
43651
- if (existsSync38(pipPath))
43790
+ if (existsSync39(pipPath))
43652
43791
  return venvDir;
43653
43792
  log2("Creating Python venv for vision deps...");
43654
43793
  if (!hasCmd(pythonCmd) && !hasCmd("python3")) {
@@ -43660,7 +43799,7 @@ function ensureVenv(log2) {
43660
43799
  return null;
43661
43800
  }
43662
43801
  try {
43663
- mkdirSync16(join55(homedir14(), ".open-agents"), { recursive: true });
43802
+ mkdirSync17(join56(homedir15(), ".open-agents"), { recursive: true });
43664
43803
  const pyCmd = hasCmd(pythonCmd) ? pythonCmd : "python3";
43665
43804
  execSync29(`${pyCmd} -m venv "${venvDir}"`, { stdio: "pipe", timeout: 3e4 });
43666
43805
  execSync29(`"${pipPath}" install --upgrade pip`, {
@@ -43908,15 +44047,15 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
43908
44047
  }
43909
44048
  const venvDir = getVenvDir();
43910
44049
  const isWin2 = process.platform === "win32";
43911
- const venvBin = join55(venvDir, isWin2 ? "Scripts" : "bin");
43912
- const venvMoondream = join55(venvBin, isWin2 ? "moondream-station.exe" : "moondream-station");
44050
+ const venvBin = join56(venvDir, isWin2 ? "Scripts" : "bin");
44051
+ const venvMoondream = join56(venvBin, isWin2 ? "moondream-station.exe" : "moondream-station");
43913
44052
  const venv = ensureVenv(log2);
43914
- if (venv && !hasCmd("moondream-station") && !existsSync38(venvMoondream)) {
43915
- const venvPip2 = join55(venvBin, "pip");
44053
+ if (venv && !hasCmd("moondream-station") && !existsSync39(venvMoondream)) {
44054
+ const venvPip2 = join56(venvBin, "pip");
43916
44055
  log2("Installing moondream-station in ~/.open-agents/venv...");
43917
44056
  try {
43918
44057
  execSync29(`"${venvPip2}" install moondream-station`, { stdio: "pipe", timeout: 3e5 });
43919
- if (existsSync38(venvMoondream)) {
44058
+ if (existsSync39(venvMoondream)) {
43920
44059
  log2("moondream-station installed successfully.");
43921
44060
  } else {
43922
44061
  try {
@@ -43933,8 +44072,8 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
43933
44072
  }
43934
44073
  }
43935
44074
  if (venv) {
43936
- const venvPython2 = join55(venvBin, isWin2 ? "python.exe" : "python");
43937
- const venvPip2 = join55(venvBin, isWin2 ? "pip.exe" : "pip");
44075
+ const venvPython2 = join56(venvBin, isWin2 ? "python.exe" : "python");
44076
+ const venvPip2 = join56(venvBin, isWin2 ? "pip.exe" : "pip");
43938
44077
  let ocrStackInstalled = false;
43939
44078
  try {
43940
44079
  execSync29(`"${venvPython2}" -c "import cv2, pytesseract, numpy, PIL"`, { stdio: "pipe", timeout: 1e4 });
@@ -43981,9 +44120,9 @@ function ensureCloudflaredBackground(onInfo) {
43981
44120
  const archMap = { x64: "amd64", arm64: "arm64", arm: "arm" };
43982
44121
  const cfArch = archMap[arch2] ?? "amd64";
43983
44122
  try {
43984
- execSync29(`curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${cfArch}" -o /tmp/cloudflared && chmod +x /tmp/cloudflared && mkdir -p "${homedir14()}/.local/bin" && mv /tmp/cloudflared "${homedir14()}/.local/bin/cloudflared"`, { stdio: "pipe", timeout: 6e4 });
43985
- if (!process.env.PATH?.includes(`${homedir14()}/.local/bin`)) {
43986
- process.env.PATH = `${homedir14()}/.local/bin:${process.env.PATH}`;
44123
+ execSync29(`curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${cfArch}" -o /tmp/cloudflared && chmod +x /tmp/cloudflared && mkdir -p "${homedir15()}/.local/bin" && mv /tmp/cloudflared "${homedir15()}/.local/bin/cloudflared"`, { stdio: "pipe", timeout: 6e4 });
44124
+ if (!process.env.PATH?.includes(`${homedir15()}/.local/bin`)) {
44125
+ process.env.PATH = `${homedir15()}/.local/bin:${process.env.PATH}`;
43987
44126
  }
43988
44127
  if (hasCmd("cloudflared")) {
43989
44128
  log2("cloudflared installed.");
@@ -44078,10 +44217,10 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
44078
44217
  `PARAMETER num_predict ${numPredict}`,
44079
44218
  `PARAMETER stop "<|endoftext|>"`
44080
44219
  ].join("\n");
44081
- const modelDir2 = join55(homedir14(), ".open-agents", "models");
44082
- mkdirSync16(modelDir2, { recursive: true });
44083
- const modelfilePath = join55(modelDir2, `Modelfile.${customName}`);
44084
- writeFileSync17(modelfilePath, modelfileContent + "\n", "utf8");
44220
+ const modelDir2 = join56(homedir15(), ".open-agents", "models");
44221
+ mkdirSync17(modelDir2, { recursive: true });
44222
+ const modelfilePath = join56(modelDir2, `Modelfile.${customName}`);
44223
+ writeFileSync18(modelfilePath, modelfileContent + "\n", "utf8");
44085
44224
  await execAsync2(`ollama create ${customName} -f ${modelfilePath}`, {
44086
44225
  timeout: 12e4
44087
44226
  });
@@ -44155,10 +44294,10 @@ async function ensureNeovim() {
44155
44294
  const platform6 = process.platform;
44156
44295
  const arch2 = process.arch;
44157
44296
  if (platform6 === "linux") {
44158
- const binDir = join55(homedir14(), ".local", "bin");
44159
- const nvimDest = join55(binDir, "nvim");
44297
+ const binDir = join56(homedir15(), ".local", "bin");
44298
+ const nvimDest = join56(binDir, "nvim");
44160
44299
  try {
44161
- mkdirSync16(binDir, { recursive: true });
44300
+ mkdirSync17(binDir, { recursive: true });
44162
44301
  } catch {
44163
44302
  }
44164
44303
  const appImageName = arch2 === "arm64" ? "nvim-linux-arm64.appimage" : "nvim-linux-x86_64.appimage";
@@ -44227,9 +44366,9 @@ async function ensureNeovim() {
44227
44366
  }
44228
44367
  function ensurePathInShellRc(binDir) {
44229
44368
  const shell = process.env.SHELL ?? "";
44230
- const rcFile = shell.includes("zsh") ? join55(homedir14(), ".zshrc") : join55(homedir14(), ".bashrc");
44369
+ const rcFile = shell.includes("zsh") ? join56(homedir15(), ".zshrc") : join56(homedir15(), ".bashrc");
44231
44370
  try {
44232
- const rcContent = existsSync38(rcFile) ? readFileSync29(rcFile, "utf8") : "";
44371
+ const rcContent = existsSync39(rcFile) ? readFileSync30(rcFile, "utf8") : "";
44233
44372
  if (rcContent.includes(binDir))
44234
44373
  return;
44235
44374
  const exportLine = `
@@ -44267,7 +44406,7 @@ var init_setup = __esm({
44267
44406
  });
44268
44407
 
44269
44408
  // packages/cli/dist/tui/drop-panel.js
44270
- import { existsSync as existsSync39 } from "node:fs";
44409
+ import { existsSync as existsSync40 } from "node:fs";
44271
44410
  import { extname as extname10, resolve as resolve29 } from "node:path";
44272
44411
  function ansi4(code, text) {
44273
44412
  return isTTY4 ? `\x1B[${code}m${text}\x1B[0m` : text;
@@ -44383,7 +44522,7 @@ function showDropPanel(opts) {
44383
44522
  filePath = decodeURIComponent(filePath.slice(7));
44384
44523
  }
44385
44524
  filePath = resolve29(filePath);
44386
- if (!existsSync39(filePath)) {
44525
+ if (!existsSync40(filePath)) {
44387
44526
  errorMsg = `File not found: ${filePath}`;
44388
44527
  render();
44389
44528
  return;
@@ -44454,9 +44593,9 @@ var init_drop_panel = __esm({
44454
44593
  });
44455
44594
 
44456
44595
  // packages/cli/dist/tui/neovim-mode.js
44457
- import { existsSync as existsSync40, unlinkSync as unlinkSync8 } from "node:fs";
44596
+ import { existsSync as existsSync41, unlinkSync as unlinkSync8 } from "node:fs";
44458
44597
  import { tmpdir as tmpdir8 } from "node:os";
44459
- import { join as join56 } from "node:path";
44598
+ import { join as join57 } from "node:path";
44460
44599
  import { execSync as execSync30 } from "node:child_process";
44461
44600
  function isNeovimActive() {
44462
44601
  return _state !== null && !_state.cleanedUp;
@@ -44504,9 +44643,9 @@ async function startNeovimMode(opts) {
44504
44643
  );
44505
44644
  } catch {
44506
44645
  }
44507
- const socketPath = join56(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
44646
+ const socketPath = join57(tmpdir8(), `oa-nvim-${process.pid}-${Date.now()}.sock`);
44508
44647
  try {
44509
- if (existsSync40(socketPath))
44648
+ if (existsSync41(socketPath))
44510
44649
  unlinkSync8(socketPath);
44511
44650
  } catch {
44512
44651
  }
@@ -44733,13 +44872,13 @@ function resizeNeovim(cols, contentRows) {
44733
44872
  }
44734
44873
  async function connectRPC(state, neovimPkg, cols) {
44735
44874
  let attempts = 0;
44736
- while (!existsSync40(state.socketPath) && attempts < 30) {
44875
+ while (!existsSync41(state.socketPath) && attempts < 30) {
44737
44876
  await new Promise((r) => setTimeout(r, 200));
44738
44877
  attempts++;
44739
44878
  if (state.cleanedUp)
44740
44879
  return;
44741
44880
  }
44742
- if (!existsSync40(state.socketPath))
44881
+ if (!existsSync41(state.socketPath))
44743
44882
  return;
44744
44883
  const nvim = neovimPkg.attach({ socket: state.socketPath });
44745
44884
  state.nvim = nvim;
@@ -44876,7 +45015,7 @@ function doCleanup(state) {
44876
45015
  state.pty = null;
44877
45016
  }
44878
45017
  try {
44879
- if (existsSync40(state.socketPath))
45018
+ if (existsSync41(state.socketPath))
44880
45019
  unlinkSync8(state.socketPath);
44881
45020
  } catch {
44882
45021
  }
@@ -45311,8 +45450,8 @@ __export(sponsor_wizard_exports, {
45311
45450
  saveSponsorConfig: () => saveSponsorConfig,
45312
45451
  showSponsorDashboard: () => showSponsorDashboard
45313
45452
  });
45314
- import { existsSync as existsSync41, readFileSync as readFileSync30, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17 } from "node:fs";
45315
- import { join as join57 } from "node:path";
45453
+ import { existsSync as existsSync42, readFileSync as readFileSync31, writeFileSync as writeFileSync19, mkdirSync as mkdirSync18 } from "node:fs";
45454
+ import { join as join58 } from "node:path";
45316
45455
  function colorPreview(code) {
45317
45456
  return `\x1B[38;5;${code}m\u2588\u2588\u2588\u2588\x1B[0m (${code})`;
45318
45457
  }
@@ -45325,26 +45464,26 @@ function gradientPreview(start, end) {
45325
45464
  return s;
45326
45465
  }
45327
45466
  function sponsorDir(projectDir) {
45328
- return join57(projectDir, ".oa", "sponsor");
45467
+ return join58(projectDir, ".oa", "sponsor");
45329
45468
  }
45330
45469
  function configPath(projectDir) {
45331
- return join57(sponsorDir(projectDir), "config.json");
45470
+ return join58(sponsorDir(projectDir), "config.json");
45332
45471
  }
45333
45472
  function loadSponsorConfig(projectDir) {
45334
45473
  const p = configPath(projectDir);
45335
- if (!existsSync41(p))
45474
+ if (!existsSync42(p))
45336
45475
  return null;
45337
45476
  try {
45338
- return JSON.parse(readFileSync30(p, "utf8"));
45477
+ return JSON.parse(readFileSync31(p, "utf8"));
45339
45478
  } catch {
45340
45479
  return null;
45341
45480
  }
45342
45481
  }
45343
45482
  function saveSponsorConfig(projectDir, config) {
45344
45483
  const dir = sponsorDir(projectDir);
45345
- mkdirSync17(dir, { recursive: true });
45484
+ mkdirSync18(dir, { recursive: true });
45346
45485
  config.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
45347
- writeFileSync18(configPath(projectDir), JSON.stringify(config, null, 2), "utf8");
45486
+ writeFileSync19(configPath(projectDir), JSON.stringify(config, null, 2), "utf8");
45348
45487
  }
45349
45488
  function defaultConfig() {
45350
45489
  return {
@@ -46047,9 +46186,9 @@ __export(voice_exports, {
46047
46186
  registerCustomOnnxModel: () => registerCustomOnnxModel,
46048
46187
  resetNarrationContext: () => resetNarrationContext
46049
46188
  });
46050
- import { existsSync as existsSync42, mkdirSync as mkdirSync18, writeFileSync as writeFileSync19, readFileSync as readFileSync31, unlinkSync as unlinkSync9, readdirSync as readdirSync12, renameSync, statSync as statSync14 } from "node:fs";
46051
- import { join as join58, dirname as dirname19 } from "node:path";
46052
- import { homedir as homedir15, tmpdir as tmpdir9, platform as platform3 } from "node:os";
46189
+ import { existsSync as existsSync43, mkdirSync as mkdirSync19, writeFileSync as writeFileSync20, readFileSync as readFileSync32, unlinkSync as unlinkSync9, readdirSync as readdirSync12, renameSync, statSync as statSync14 } from "node:fs";
46190
+ import { join as join59, dirname as dirname19 } from "node:path";
46191
+ import { homedir as homedir16, tmpdir as tmpdir9, platform as platform3 } from "node:os";
46053
46192
  import { execSync as execSync31, spawn as nodeSpawn } from "node:child_process";
46054
46193
  import { createRequire } from "node:module";
46055
46194
  function sanitizeForTTS(text) {
@@ -46073,40 +46212,40 @@ function listVoiceModels() {
46073
46212
  }));
46074
46213
  }
46075
46214
  function voiceDir() {
46076
- return join58(homedir15(), ".open-agents", "voice");
46215
+ return join59(homedir16(), ".open-agents", "voice");
46077
46216
  }
46078
46217
  function modelsDir() {
46079
- return join58(voiceDir(), "models");
46218
+ return join59(voiceDir(), "models");
46080
46219
  }
46081
46220
  function modelDir(id) {
46082
- return join58(modelsDir(), id);
46221
+ return join59(modelsDir(), id);
46083
46222
  }
46084
46223
  function modelOnnxPath(id) {
46085
- return join58(modelDir(id), "model.onnx");
46224
+ return join59(modelDir(id), "model.onnx");
46086
46225
  }
46087
46226
  function modelConfigPath(id) {
46088
- return join58(modelDir(id), "config.json");
46227
+ return join59(modelDir(id), "config.json");
46089
46228
  }
46090
46229
  function luxttsVenvDir() {
46091
- return join58(voiceDir(), "luxtts-venv");
46230
+ return join59(voiceDir(), "luxtts-venv");
46092
46231
  }
46093
46232
  function luxttsVenvPy() {
46094
- return platform3() === "win32" ? join58(luxttsVenvDir(), "Scripts", "python.exe") : join58(luxttsVenvDir(), "bin", "python3");
46233
+ return platform3() === "win32" ? join59(luxttsVenvDir(), "Scripts", "python.exe") : join59(luxttsVenvDir(), "bin", "python3");
46095
46234
  }
46096
46235
  function luxttsRepoDir() {
46097
- return join58(voiceDir(), "LuxTTS");
46236
+ return join59(voiceDir(), "LuxTTS");
46098
46237
  }
46099
46238
  function luxttsCloneRefsDir() {
46100
- return join58(voiceDir(), "clone-refs");
46239
+ return join59(voiceDir(), "clone-refs");
46101
46240
  }
46102
46241
  function luxttsInferScript() {
46103
- return join58(voiceDir(), "luxtts-infer.py");
46242
+ return join59(voiceDir(), "luxtts-infer.py");
46104
46243
  }
46105
46244
  function writeDetectTorchScript(targetPath) {
46106
- if (existsSync42(targetPath))
46245
+ if (existsSync43(targetPath))
46107
46246
  return;
46108
46247
  try {
46109
- mkdirSync18(dirname19(targetPath), { recursive: true });
46248
+ mkdirSync19(dirname19(targetPath), { recursive: true });
46110
46249
  } catch {
46111
46250
  }
46112
46251
  const script = `#!/usr/bin/env python3
@@ -46179,7 +46318,7 @@ def main():
46179
46318
  if __name__ == "__main__": main()
46180
46319
  `;
46181
46320
  try {
46182
- writeFileSync19(targetPath, script, { mode: 493 });
46321
+ writeFileSync20(targetPath, script, { mode: 493 });
46183
46322
  } catch {
46184
46323
  }
46185
46324
  }
@@ -46990,8 +47129,8 @@ var init_voice = __esm({
46990
47129
  const refsDir = luxttsCloneRefsDir();
46991
47130
  const targets = ["glados", "overwatch"];
46992
47131
  for (const modelId of targets) {
46993
- const refFile = join58(refsDir, `${modelId}-ref.wav`);
46994
- if (existsSync42(refFile))
47132
+ const refFile = join59(refsDir, `${modelId}-ref.wav`);
47133
+ if (existsSync43(refFile))
46995
47134
  continue;
46996
47135
  try {
46997
47136
  await this.generateCloneRef(modelId);
@@ -47070,24 +47209,24 @@ var init_voice = __esm({
47070
47209
  }
47071
47210
  p = p.replace(/\\ /g, " ");
47072
47211
  if (p.startsWith("~/") || p === "~") {
47073
- p = join58(homedir15(), p.slice(1));
47212
+ p = join59(homedir16(), p.slice(1));
47074
47213
  }
47075
- if (!existsSync42(p)) {
47214
+ if (!existsSync43(p)) {
47076
47215
  return `File not found: ${p}
47077
47216
  (original input: ${audioPath})`;
47078
47217
  }
47079
47218
  audioPath = p;
47080
47219
  const refsDir = luxttsCloneRefsDir();
47081
- if (!existsSync42(refsDir))
47082
- mkdirSync18(refsDir, { recursive: true });
47220
+ if (!existsSync43(refsDir))
47221
+ mkdirSync19(refsDir, { recursive: true });
47083
47222
  const ext = audioPath.split(".").pop() || "wav";
47084
47223
  const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
47085
47224
  const ts = Date.now().toString(36);
47086
47225
  const destFilename = `clone-${srcName}-${ts}.${ext}`;
47087
- const destPath = join58(refsDir, destFilename);
47226
+ const destPath = join59(refsDir, destFilename);
47088
47227
  try {
47089
- const data = readFileSync31(audioPath);
47090
- writeFileSync19(destPath, data);
47228
+ const data = readFileSync32(audioPath);
47229
+ writeFileSync20(destPath, data);
47091
47230
  } catch (err) {
47092
47231
  return `Failed to copy audio file: ${err instanceof Error ? err.message : String(err)}`;
47093
47232
  }
@@ -47127,9 +47266,9 @@ var init_voice = __esm({
47127
47266
  return `Failed to synthesize reference audio from ${source.label}.`;
47128
47267
  }
47129
47268
  const refsDir = luxttsCloneRefsDir();
47130
- if (!existsSync42(refsDir))
47131
- mkdirSync18(refsDir, { recursive: true });
47132
- const destPath = join58(refsDir, `${sourceModelId}-ref.wav`);
47269
+ if (!existsSync43(refsDir))
47270
+ mkdirSync19(refsDir, { recursive: true });
47271
+ const destPath = join59(refsDir, `${sourceModelId}-ref.wav`);
47133
47272
  const sampleRate = this.config?.audio?.sample_rate ?? 22050;
47134
47273
  this.writeWav(audioData, sampleRate, destPath);
47135
47274
  this.luxttsCloneRef = destPath;
@@ -47145,23 +47284,23 @@ var init_voice = __esm({
47145
47284
  // -------------------------------------------------------------------------
47146
47285
  /** Metadata file for friendly names of clone refs */
47147
47286
  static cloneMetaFile() {
47148
- return join58(luxttsCloneRefsDir(), "meta.json");
47287
+ return join59(luxttsCloneRefsDir(), "meta.json");
47149
47288
  }
47150
47289
  loadCloneMeta() {
47151
47290
  const p = _VoiceEngine.cloneMetaFile();
47152
- if (!existsSync42(p))
47291
+ if (!existsSync43(p))
47153
47292
  return {};
47154
47293
  try {
47155
- return JSON.parse(readFileSync31(p, "utf8"));
47294
+ return JSON.parse(readFileSync32(p, "utf8"));
47156
47295
  } catch {
47157
47296
  return {};
47158
47297
  }
47159
47298
  }
47160
47299
  saveCloneMeta(meta) {
47161
47300
  const dir = luxttsCloneRefsDir();
47162
- if (!existsSync42(dir))
47163
- mkdirSync18(dir, { recursive: true });
47164
- writeFileSync19(_VoiceEngine.cloneMetaFile(), JSON.stringify(meta, null, 2));
47301
+ if (!existsSync43(dir))
47302
+ mkdirSync19(dir, { recursive: true });
47303
+ writeFileSync20(_VoiceEngine.cloneMetaFile(), JSON.stringify(meta, null, 2));
47165
47304
  }
47166
47305
  /** Audio file extensions recognized as clone references */
47167
47306
  static AUDIO_EXTS = /* @__PURE__ */ new Set(["wav", "mp3", "ogg", "flac", "m4a", "opus", "aac"]);
@@ -47171,7 +47310,7 @@ var init_voice = __esm({
47171
47310
  */
47172
47311
  listCloneRefs() {
47173
47312
  const dir = luxttsCloneRefsDir();
47174
- if (!existsSync42(dir))
47313
+ if (!existsSync43(dir))
47175
47314
  return [];
47176
47315
  const meta = this.loadCloneMeta();
47177
47316
  const files = readdirSync12(dir).filter((f) => {
@@ -47179,7 +47318,7 @@ var init_voice = __esm({
47179
47318
  return _VoiceEngine.AUDIO_EXTS.has(ext);
47180
47319
  });
47181
47320
  return files.map((f) => {
47182
- const p = join58(dir, f);
47321
+ const p = join59(dir, f);
47183
47322
  let size = 0;
47184
47323
  try {
47185
47324
  size = statSync14(p).size;
@@ -47196,8 +47335,8 @@ var init_voice = __esm({
47196
47335
  }
47197
47336
  /** Delete a clone reference file by filename. Returns true if deleted. */
47198
47337
  deleteCloneRef(filename) {
47199
- const p = join58(luxttsCloneRefsDir(), filename);
47200
- if (!existsSync42(p))
47338
+ const p = join59(luxttsCloneRefsDir(), filename);
47339
+ if (!existsSync43(p))
47201
47340
  return false;
47202
47341
  try {
47203
47342
  unlinkSync9(p);
@@ -47221,8 +47360,8 @@ var init_voice = __esm({
47221
47360
  }
47222
47361
  /** Set the active clone reference by filename. */
47223
47362
  setActiveCloneRef(filename) {
47224
- const p = join58(luxttsCloneRefsDir(), filename);
47225
- if (!existsSync42(p))
47363
+ const p = join59(luxttsCloneRefsDir(), filename);
47364
+ if (!existsSync43(p))
47226
47365
  return `File not found: ${filename}`;
47227
47366
  this.luxttsCloneRef = p;
47228
47367
  return `Active clone voice set to: ${filename}`;
@@ -47547,7 +47686,7 @@ var init_voice = __esm({
47547
47686
  }
47548
47687
  this.onPCMOutput(Buffer.from(int16.buffer), sampleRate);
47549
47688
  }
47550
- const wavPath = join58(tmpdir9(), `oa-voice-${Date.now()}.wav`);
47689
+ const wavPath = join59(tmpdir9(), `oa-voice-${Date.now()}.wav`);
47551
47690
  this.writeStereoWav(stereo.left, stereo.right, sampleRate, wavPath);
47552
47691
  await this.playWav(wavPath);
47553
47692
  try {
@@ -47664,7 +47803,7 @@ var init_voice = __esm({
47664
47803
  buffer.writeInt16LE(rSample < 0 ? rSample * 32768 : rSample * 32767, pos);
47665
47804
  pos += 2;
47666
47805
  }
47667
- writeFileSync19(path, buffer);
47806
+ writeFileSync20(path, buffer);
47668
47807
  }
47669
47808
  // -------------------------------------------------------------------------
47670
47809
  // Phonemization
@@ -47742,7 +47881,7 @@ var init_voice = __esm({
47742
47881
  return buffer;
47743
47882
  }
47744
47883
  writeWav(samples, sampleRate, path) {
47745
- writeFileSync19(path, this.buildWavBuffer(samples, sampleRate));
47884
+ writeFileSync20(path, this.buildWavBuffer(samples, sampleRate));
47746
47885
  }
47747
47886
  // -------------------------------------------------------------------------
47748
47887
  // Audio playback (system default speakers)
@@ -47940,7 +48079,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
47940
48079
  const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
47941
48080
  const mlxVoice = model.mlxVoice ?? "af_heart";
47942
48081
  const mlxLangCode = model.mlxLangCode ?? "a";
47943
- const wavPath = join58(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
48082
+ const wavPath = join59(tmpdir9(), `oa-mlx-${Date.now()}.wav`);
47944
48083
  const pyScript = [
47945
48084
  "import sys, json",
47946
48085
  "from mlx_audio.tts import generate as tts_gen",
@@ -47957,11 +48096,11 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
47957
48096
  return;
47958
48097
  }
47959
48098
  }
47960
- if (!existsSync42(wavPath))
48099
+ if (!existsSync43(wavPath))
47961
48100
  return;
47962
48101
  if (volume !== 1) {
47963
48102
  try {
47964
- const wavData = readFileSync31(wavPath);
48103
+ const wavData = readFileSync32(wavPath);
47965
48104
  if (wavData.length > 44) {
47966
48105
  const header = wavData.subarray(0, 44);
47967
48106
  const samples = new Int16Array(wavData.buffer, wavData.byteOffset + 44, (wavData.length - 44) / 2);
@@ -47969,14 +48108,14 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
47969
48108
  samples[i] = Math.round(samples[i] * volume);
47970
48109
  }
47971
48110
  const scaled = Buffer.concat([header, Buffer.from(samples.buffer, samples.byteOffset, samples.byteLength)]);
47972
- writeFileSync19(wavPath, scaled);
48111
+ writeFileSync20(wavPath, scaled);
47973
48112
  }
47974
48113
  } catch {
47975
48114
  }
47976
48115
  }
47977
48116
  if (this.onPCMOutput) {
47978
48117
  try {
47979
- const wavData = readFileSync31(wavPath);
48118
+ const wavData = readFileSync32(wavPath);
47980
48119
  if (wavData.length > 44) {
47981
48120
  const pcm = Buffer.from(wavData.buffer, wavData.byteOffset + 44, wavData.length - 44);
47982
48121
  const sampleRate = wavData.readUInt32LE(24);
@@ -48008,7 +48147,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48008
48147
  const mlxModelId = model.mlxModelId ?? "mlx-community/Kokoro-82M-bf16";
48009
48148
  const mlxVoice = model.mlxVoice ?? "af_heart";
48010
48149
  const mlxLangCode = model.mlxLangCode ?? "a";
48011
- const wavPath = join58(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
48150
+ const wavPath = join59(tmpdir9(), `oa-mlx-buf-${Date.now()}.wav`);
48012
48151
  const pyScript = [
48013
48152
  "import sys, json",
48014
48153
  "from mlx_audio.tts import generate as tts_gen",
@@ -48025,10 +48164,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48025
48164
  return null;
48026
48165
  }
48027
48166
  }
48028
- if (!existsSync42(wavPath))
48167
+ if (!existsSync43(wavPath))
48029
48168
  return null;
48030
48169
  try {
48031
- const data = readFileSync31(wavPath);
48170
+ const data = readFileSync32(wavPath);
48032
48171
  unlinkSync9(wavPath);
48033
48172
  return data;
48034
48173
  } catch {
@@ -48051,7 +48190,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48051
48190
  }
48052
48191
  const venvDir = luxttsVenvDir();
48053
48192
  const venvPy = luxttsVenvPy();
48054
- if (existsSync42(venvPy)) {
48193
+ if (existsSync43(venvPy)) {
48055
48194
  try {
48056
48195
  const quotedPy = `"${venvPy}"`;
48057
48196
  const repoPath = luxttsRepoDir().replace(/\\/g, "/");
@@ -48067,7 +48206,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48067
48206
  if (torchCheck === "cpu") {
48068
48207
  renderWarning("GPU detected but PyTorch is CPU-only. Reinstalling with CUDA support in background...");
48069
48208
  try {
48070
- const detectScript = join58(voiceDir(), "detect-torch.py");
48209
+ const detectScript = join59(voiceDir(), "detect-torch.py");
48071
48210
  writeDetectTorchScript(detectScript);
48072
48211
  let pipArgs = `torch torchaudio --index-url https://download.pytorch.org/whl/cu124`;
48073
48212
  try {
@@ -48092,7 +48231,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48092
48231
  }
48093
48232
  }
48094
48233
  renderInfo("Setting up LuxTTS voice cloning (first-time setup, this takes several minutes)...");
48095
- if (!existsSync42(venvDir)) {
48234
+ if (!existsSync43(venvDir)) {
48096
48235
  renderInfo(" Creating Python virtual environment...");
48097
48236
  try {
48098
48237
  await this.asyncShell(`${py} -m venv ${JSON.stringify(venvDir)}`, 6e4);
@@ -48101,7 +48240,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48101
48240
  }
48102
48241
  }
48103
48242
  {
48104
- const detectScript = join58(voiceDir(), "detect-torch.py");
48243
+ const detectScript = join59(voiceDir(), "detect-torch.py");
48105
48244
  writeDetectTorchScript(detectScript);
48106
48245
  let pipArgsStr = "torch torchaudio";
48107
48246
  let torchDesc = "unknown platform";
@@ -48138,10 +48277,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48138
48277
  }
48139
48278
  }
48140
48279
  const repoDir = luxttsRepoDir();
48141
- if (!existsSync42(join58(repoDir, "zipvoice", "luxvoice.py"))) {
48280
+ if (!existsSync43(join59(repoDir, "zipvoice", "luxvoice.py"))) {
48142
48281
  renderInfo(" Cloning LuxTTS repository...");
48143
48282
  try {
48144
- if (existsSync42(repoDir)) {
48283
+ if (existsSync43(repoDir)) {
48145
48284
  const rmCmd = process.platform === "win32" ? `rmdir /s /q ${JSON.stringify(repoDir)}` : `rm -rf ${JSON.stringify(repoDir)}`;
48146
48285
  await this.asyncShell(rmCmd, 3e4);
48147
48286
  }
@@ -48220,7 +48359,7 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48220
48359
  renderWarning(` Could not install system build deps: ${err instanceof Error ? err.message : String(err)}`);
48221
48360
  }
48222
48361
  }
48223
- const isJetson = isArm && (existsSync42("/etc/nv_tegra_release") || existsSync42("/usr/local/cuda/targets/aarch64-linux") || (process.env.JETSON_L4T_VERSION ?? "") !== "");
48362
+ const isJetson = isArm && (existsSync43("/etc/nv_tegra_release") || existsSync43("/usr/local/cuda/targets/aarch64-linux") || (process.env.JETSON_L4T_VERSION ?? "") !== "");
48224
48363
  const installSteps = isArm ? [
48225
48364
  // ARM: install individually so we get clear error messages per package.
48226
48365
  // ALL are fatal because LuxTTS hard-imports them (no lazy/optional imports).
@@ -48290,14 +48429,14 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
48290
48429
  }
48291
48430
  /** Auto-detect an existing clone reference in the refs directory */
48292
48431
  autoDetectCloneRef() {
48293
- if (this.luxttsCloneRef && existsSync42(this.luxttsCloneRef))
48432
+ if (this.luxttsCloneRef && existsSync43(this.luxttsCloneRef))
48294
48433
  return;
48295
48434
  const refsDir = luxttsCloneRefsDir();
48296
- if (!existsSync42(refsDir))
48435
+ if (!existsSync43(refsDir))
48297
48436
  return;
48298
48437
  for (const name of ["custom-clone.wav", "custom-clone.mp3", "glados-ref.wav", "overwatch-ref.wav"]) {
48299
- const p = join58(refsDir, name);
48300
- if (existsSync42(p)) {
48438
+ const p = join59(refsDir, name);
48439
+ if (existsSync43(p)) {
48301
48440
  this.luxttsCloneRef = p;
48302
48441
  return;
48303
48442
  }
@@ -48397,15 +48536,15 @@ if __name__ == '__main__':
48397
48536
  main()
48398
48537
  `;
48399
48538
  const scriptPath2 = luxttsInferScript();
48400
- mkdirSync18(voiceDir(), { recursive: true });
48401
- writeFileSync19(scriptPath2, script);
48539
+ mkdirSync19(voiceDir(), { recursive: true });
48540
+ writeFileSync20(scriptPath2, script);
48402
48541
  }
48403
48542
  /** Ensure the LuxTTS daemon is running, spawn if needed */
48404
48543
  async ensureLuxttsDaemon() {
48405
48544
  if (this._luxttsDaemon && !this._luxttsDaemon.killed)
48406
48545
  return true;
48407
48546
  const venvPy = luxttsVenvPy();
48408
- if (!existsSync42(venvPy))
48547
+ if (!existsSync43(venvPy))
48409
48548
  return false;
48410
48549
  return new Promise((resolve36) => {
48411
48550
  const env = { ...process.env, LUXTTS_REPO_PATH: luxttsRepoDir() };
@@ -48498,7 +48637,7 @@ if __name__ == '__main__':
48498
48637
  * Used by drainQueue's pre-fetch pipeline for gapless back-to-back playback.
48499
48638
  */
48500
48639
  async synthesizeLuxttsWav(text, speedFactor = 1) {
48501
- if (!this.luxttsCloneRef || !existsSync42(this.luxttsCloneRef))
48640
+ if (!this.luxttsCloneRef || !existsSync43(this.luxttsCloneRef))
48502
48641
  return null;
48503
48642
  const cleaned = text.replace(/\*/g, "").trim();
48504
48643
  if (!cleaned)
@@ -48506,7 +48645,7 @@ if __name__ == '__main__':
48506
48645
  const ready = await this.ensureLuxttsDaemon();
48507
48646
  if (!ready)
48508
48647
  return null;
48509
- const wavPath = join58(tmpdir9(), `oa-luxtts-${Date.now()}-${Math.random().toString(36).slice(2, 6)}.wav`);
48648
+ const wavPath = join59(tmpdir9(), `oa-luxtts-${Date.now()}-${Math.random().toString(36).slice(2, 6)}.wav`);
48510
48649
  try {
48511
48650
  await this.luxttsRequest({
48512
48651
  action: "synthesize",
@@ -48518,17 +48657,17 @@ if __name__ == '__main__':
48518
48657
  } catch {
48519
48658
  return null;
48520
48659
  }
48521
- return existsSync42(wavPath) ? wavPath : null;
48660
+ return existsSync43(wavPath) ? wavPath : null;
48522
48661
  }
48523
48662
  /**
48524
48663
  * Post-process (fade-in, volume, pitch, stereo) and play a LuxTTS WAV file.
48525
48664
  * Cleans up the WAV file after playback.
48526
48665
  */
48527
48666
  async postProcessAndPlayLuxtts(wavPath, volume = 1, pitchFactor = 1, stereoDelayMs = 0.6) {
48528
- if (!existsSync42(wavPath))
48667
+ if (!existsSync43(wavPath))
48529
48668
  return;
48530
48669
  try {
48531
- const wavData = readFileSync31(wavPath);
48670
+ const wavData = readFileSync32(wavPath);
48532
48671
  if (wavData.length > 44) {
48533
48672
  const sampleRate = wavData.readUInt32LE(24);
48534
48673
  const samples = new Int16Array(wavData.buffer, wavData.byteOffset + 44, (wavData.length - 44) / 2);
@@ -48543,13 +48682,13 @@ if __name__ == '__main__':
48543
48682
  }
48544
48683
  const header = wavData.subarray(0, 44);
48545
48684
  const scaled = Buffer.concat([header, Buffer.from(samples.buffer, samples.byteOffset, samples.byteLength)]);
48546
- writeFileSync19(wavPath, scaled);
48685
+ writeFileSync20(wavPath, scaled);
48547
48686
  }
48548
48687
  } catch {
48549
48688
  }
48550
48689
  if (pitchFactor !== 1) {
48551
48690
  try {
48552
- const wavData = readFileSync31(wavPath);
48691
+ const wavData = readFileSync32(wavPath);
48553
48692
  if (wavData.length > 44) {
48554
48693
  const int16 = new Int16Array(wavData.buffer, wavData.byteOffset + 44, (wavData.length - 44) / 2);
48555
48694
  const float32 = new Float32Array(int16.length);
@@ -48564,7 +48703,7 @@ if __name__ == '__main__':
48564
48703
  }
48565
48704
  if (this.onPCMOutput) {
48566
48705
  try {
48567
- const wavData = readFileSync31(wavPath);
48706
+ const wavData = readFileSync32(wavPath);
48568
48707
  if (wavData.length > 44) {
48569
48708
  const pcm = Buffer.from(wavData.buffer, wavData.byteOffset + 44, wavData.length - 44);
48570
48709
  const sampleRate = wavData.readUInt32LE(24);
@@ -48575,7 +48714,7 @@ if __name__ == '__main__':
48575
48714
  }
48576
48715
  if (stereoDelayMs > 0) {
48577
48716
  try {
48578
- const wavData = readFileSync31(wavPath);
48717
+ const wavData = readFileSync32(wavPath);
48579
48718
  if (wavData.length > 44) {
48580
48719
  const sampleRate = wavData.readUInt32LE(24);
48581
48720
  const numChannels = wavData.readUInt16LE(22);
@@ -48611,7 +48750,7 @@ if __name__ == '__main__':
48611
48750
  * Used for Telegram voice messages and WebSocket streaming.
48612
48751
  */
48613
48752
  async synthesizeLuxttsToBuffer(text) {
48614
- if (!this.luxttsCloneRef || !existsSync42(this.luxttsCloneRef))
48753
+ if (!this.luxttsCloneRef || !existsSync43(this.luxttsCloneRef))
48615
48754
  return null;
48616
48755
  const cleaned = text.replace(/\*/g, "").trim();
48617
48756
  if (!cleaned)
@@ -48619,7 +48758,7 @@ if __name__ == '__main__':
48619
48758
  const ready = await this.ensureLuxttsDaemon();
48620
48759
  if (!ready)
48621
48760
  return null;
48622
- const wavPath = join58(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
48761
+ const wavPath = join59(tmpdir9(), `oa-luxtts-buf-${Date.now()}.wav`);
48623
48762
  try {
48624
48763
  await this.luxttsRequest({
48625
48764
  action: "synthesize",
@@ -48631,10 +48770,10 @@ if __name__ == '__main__':
48631
48770
  } catch {
48632
48771
  return null;
48633
48772
  }
48634
- if (!existsSync42(wavPath))
48773
+ if (!existsSync43(wavPath))
48635
48774
  return null;
48636
48775
  try {
48637
- const data = readFileSync31(wavPath);
48776
+ const data = readFileSync32(wavPath);
48638
48777
  unlinkSync9(wavPath);
48639
48778
  return data;
48640
48779
  } catch {
@@ -48648,40 +48787,40 @@ if __name__ == '__main__':
48648
48787
  if (this.ort)
48649
48788
  return;
48650
48789
  const arch2 = process.arch;
48651
- mkdirSync18(voiceDir(), { recursive: true });
48652
- const pkgPath = join58(voiceDir(), "package.json");
48790
+ mkdirSync19(voiceDir(), { recursive: true });
48791
+ const pkgPath = join59(voiceDir(), "package.json");
48653
48792
  const expectedDeps = {
48654
48793
  "onnxruntime-node": "^1.21.0",
48655
48794
  "phonemizer": "^1.2.1"
48656
48795
  };
48657
- if (existsSync42(pkgPath)) {
48796
+ if (existsSync43(pkgPath)) {
48658
48797
  try {
48659
- const existing = JSON.parse(readFileSync31(pkgPath, "utf8"));
48798
+ const existing = JSON.parse(readFileSync32(pkgPath, "utf8"));
48660
48799
  if (!existing.dependencies?.["phonemizer"]) {
48661
48800
  existing.dependencies = { ...existing.dependencies, ...expectedDeps };
48662
- writeFileSync19(pkgPath, JSON.stringify(existing, null, 2));
48801
+ writeFileSync20(pkgPath, JSON.stringify(existing, null, 2));
48663
48802
  }
48664
48803
  } catch {
48665
48804
  }
48666
48805
  }
48667
- if (!existsSync42(pkgPath)) {
48668
- writeFileSync19(pkgPath, JSON.stringify({
48806
+ if (!existsSync43(pkgPath)) {
48807
+ writeFileSync20(pkgPath, JSON.stringify({
48669
48808
  name: "open-agents-voice",
48670
48809
  private: true,
48671
48810
  dependencies: expectedDeps
48672
48811
  }, null, 2));
48673
48812
  }
48674
- const voiceRequire = createRequire(join58(voiceDir(), "index.js"));
48813
+ const voiceRequire = createRequire(join59(voiceDir(), "index.js"));
48675
48814
  const probeOnnx = async () => {
48676
48815
  try {
48677
- const output = await this.asyncShell(`NODE_PATH="${join58(voiceDir(), "node_modules")}" node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, 15e3);
48816
+ const output = await this.asyncShell(`NODE_PATH="${join59(voiceDir(), "node_modules")}" node -e "try { require('onnxruntime-node'); console.log('OK'); } catch(e) { console.log('FAIL:' + e.message); }"`, 15e3);
48678
48817
  return output.trim() === "OK";
48679
48818
  } catch {
48680
48819
  return false;
48681
48820
  }
48682
48821
  };
48683
- const onnxNodeModules = join58(voiceDir(), "node_modules", "onnxruntime-node");
48684
- const onnxInstalled = existsSync42(onnxNodeModules);
48822
+ const onnxNodeModules = join59(voiceDir(), "node_modules", "onnxruntime-node");
48823
+ const onnxInstalled = existsSync43(onnxNodeModules);
48685
48824
  if (onnxInstalled && !await probeOnnx()) {
48686
48825
  throw new Error(`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${arch2}). This is a known issue with some ARM SoCs where the CPU vendor is not recognized. Voice feedback will be disabled but all other features work normally.`);
48687
48826
  }
@@ -48731,18 +48870,18 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
48731
48870
  const dir = modelDir(id);
48732
48871
  const onnxPath = modelOnnxPath(id);
48733
48872
  const configPath2 = modelConfigPath(id);
48734
- if (existsSync42(onnxPath) && existsSync42(configPath2))
48873
+ if (existsSync43(onnxPath) && existsSync43(configPath2))
48735
48874
  return;
48736
- mkdirSync18(dir, { recursive: true });
48737
- if (!existsSync42(configPath2)) {
48875
+ mkdirSync19(dir, { recursive: true });
48876
+ if (!existsSync43(configPath2)) {
48738
48877
  renderInfo(`Downloading ${model.label} voice config...`);
48739
48878
  const configResp = await fetch(model.configUrl);
48740
48879
  if (!configResp.ok)
48741
48880
  throw new Error(`Failed to download config: HTTP ${configResp.status}`);
48742
48881
  const configText = await configResp.text();
48743
- writeFileSync19(configPath2, configText);
48882
+ writeFileSync20(configPath2, configText);
48744
48883
  }
48745
- if (!existsSync42(onnxPath)) {
48884
+ if (!existsSync43(onnxPath)) {
48746
48885
  renderInfo(`Downloading ${model.label} voice model (this may take a minute)...`);
48747
48886
  const onnxResp = await fetch(model.onnxUrl);
48748
48887
  if (!onnxResp.ok)
@@ -48767,7 +48906,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
48767
48906
  }
48768
48907
  }
48769
48908
  const fullBuffer = Buffer.concat(chunks);
48770
- writeFileSync19(onnxPath, fullBuffer);
48909
+ writeFileSync20(onnxPath, fullBuffer);
48771
48910
  renderInfo(`${model.label} model downloaded (${formatBytes2(fullBuffer.length)}).`);
48772
48911
  }
48773
48912
  }
@@ -48779,10 +48918,10 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
48779
48918
  throw new Error("ONNX runtime not loaded");
48780
48919
  const onnxPath = modelOnnxPath(this.modelId);
48781
48920
  const configPath2 = modelConfigPath(this.modelId);
48782
- if (!existsSync42(onnxPath) || !existsSync42(configPath2)) {
48921
+ if (!existsSync43(onnxPath) || !existsSync43(configPath2)) {
48783
48922
  throw new Error(`Model files not found for ${this.modelId}`);
48784
48923
  }
48785
- this.config = JSON.parse(readFileSync31(configPath2, "utf8"));
48924
+ this.config = JSON.parse(readFileSync32(configPath2, "utf8"));
48786
48925
  this.session = await this.ort.InferenceSession.create(onnxPath, {
48787
48926
  executionProviders: ["cpu"],
48788
48927
  graphOptimizationLevel: "all"
@@ -48809,8 +48948,8 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
48809
48948
  // packages/cli/dist/tui/commands.js
48810
48949
  import * as nodeOs from "node:os";
48811
48950
  import { execSync as nodeExecSync } from "node:child_process";
48812
- import { existsSync as existsSync43, readFileSync as readFileSync32, writeFileSync as writeFileSync20, mkdirSync as mkdirSync19, readdirSync as readdirSync13, statSync as statSync15, rmSync } from "node:fs";
48813
- import { join as join59 } from "node:path";
48951
+ import { existsSync as existsSync44, readFileSync as readFileSync33, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, readdirSync as readdirSync13, statSync as statSync15, rmSync } from "node:fs";
48952
+ import { join as join60 } from "node:path";
48814
48953
  function safeLog(text) {
48815
48954
  if (isNeovimActive()) {
48816
48955
  writeToNeovimOutput(text + "\n");
@@ -49223,9 +49362,9 @@ async function handleSlashCommand(input, ctx) {
49223
49362
  renderInfo("No wallet configured. Ask the agent to create one via the nexus tool.");
49224
49363
  }
49225
49364
  } else if (sub === "name") {
49226
- const { homedir: homedir21 } = __require("node:os");
49365
+ const { homedir: homedir22 } = __require("node:os");
49227
49366
  const { existsSync: ex, readFileSync: rf, writeFileSync: wf, mkdirSync: mkd } = __require("node:fs");
49228
- const namePath = __require("node:path").join(homedir21(), ".open-agents", "agent-name");
49367
+ const namePath = __require("node:path").join(homedir22(), ".open-agents", "agent-name");
49229
49368
  if (rest2) {
49230
49369
  const customName = rest2.replace(/[^a-zA-Z0-9_\-.\s]/g, "").trim().slice(0, 40);
49231
49370
  if (!customName) {
@@ -49491,22 +49630,22 @@ async function handleSlashCommand(input, ctx) {
49491
49630
  let content = "";
49492
49631
  let metadata = {};
49493
49632
  if (shareType === "tool") {
49494
- const toolDir = join59(ctx.repoRoot, ".oa", "tools");
49495
- const toolFile = join59(toolDir, shareName.endsWith(".json") ? shareName : `${shareName}.json`);
49496
- if (!existsSync43(toolFile)) {
49633
+ const toolDir = join60(ctx.repoRoot, ".oa", "tools");
49634
+ const toolFile = join60(toolDir, shareName.endsWith(".json") ? shareName : `${shareName}.json`);
49635
+ if (!existsSync44(toolFile)) {
49497
49636
  renderWarning(`Tool not found: ${toolFile}`);
49498
49637
  return "handled";
49499
49638
  }
49500
- content = readFileSync32(toolFile, "utf8");
49639
+ content = readFileSync33(toolFile, "utf8");
49501
49640
  metadata = { type: "tool", name: shareName };
49502
49641
  } else if (shareType === "skill") {
49503
- const skillDir = join59(ctx.repoRoot, ".oa", "skills", shareName);
49504
- const skillFile = join59(skillDir, "SKILL.md");
49505
- if (!existsSync43(skillFile)) {
49642
+ const skillDir = join60(ctx.repoRoot, ".oa", "skills", shareName);
49643
+ const skillFile = join60(skillDir, "SKILL.md");
49644
+ if (!existsSync44(skillFile)) {
49506
49645
  renderWarning(`Skill not found: ${skillFile}`);
49507
49646
  return "handled";
49508
49647
  }
49509
- content = readFileSync32(skillFile, "utf8");
49648
+ content = readFileSync33(skillFile, "utf8");
49510
49649
  metadata = { type: "skill", name: shareName };
49511
49650
  } else {
49512
49651
  renderWarning(`Unknown share type: ${shareType}. Use 'tool' or 'skill'.`);
@@ -49543,9 +49682,9 @@ async function handleSlashCommand(input, ctx) {
49543
49682
  try {
49544
49683
  const nexus = new NexusTool(ctx.repoRoot);
49545
49684
  await nexus.execute({ action: "ipfs_pin", cid: importCid, source: "import" });
49546
- const regFile = join59(ctx.repoRoot, ".oa", "nexus", "ipfs", "cid-registry", "learning-cids.json");
49547
- if (existsSync43(regFile)) {
49548
- const reg = JSON.parse(readFileSync32(regFile, "utf8"));
49685
+ const regFile = join60(ctx.repoRoot, ".oa", "nexus", "ipfs", "cid-registry", "learning-cids.json");
49686
+ if (existsSync44(regFile)) {
49687
+ const reg = JSON.parse(readFileSync33(regFile, "utf8"));
49549
49688
  const pinned = Object.values(reg).some((e) => e.cid === importCid && e.pinned);
49550
49689
  if (pinned) {
49551
49690
  renderInfo(`CID ${importCid.slice(0, 20)}... pinned successfully.`);
@@ -49597,33 +49736,33 @@ async function handleSlashCommand(input, ctx) {
49597
49736
  lines.push(`
49598
49737
  ${c2.bold("IPFS / Helia Status")}
49599
49738
  `);
49600
- const ipfsDir = join59(ctx.repoRoot, ".oa", "ipfs");
49601
- const ipfsLocalDir = join59(ipfsDir, "local");
49739
+ const ipfsDir = join60(ctx.repoRoot, ".oa", "ipfs");
49740
+ const ipfsLocalDir = join60(ipfsDir, "local");
49602
49741
  let ipfsFiles = 0;
49603
49742
  let ipfsBytes = 0;
49604
49743
  let heliaBlocks = 0;
49605
49744
  let heliaBytes = 0;
49606
49745
  try {
49607
- if (existsSync43(ipfsLocalDir)) {
49746
+ if (existsSync44(ipfsLocalDir)) {
49608
49747
  const files = readdirSync13(ipfsLocalDir).filter((f) => f.endsWith(".json"));
49609
49748
  ipfsFiles = files.length;
49610
49749
  for (const f of files) {
49611
49750
  try {
49612
- ipfsBytes += statSync15(join59(ipfsLocalDir, f)).size;
49751
+ ipfsBytes += statSync15(join60(ipfsLocalDir, f)).size;
49613
49752
  } catch {
49614
49753
  }
49615
49754
  }
49616
49755
  }
49617
- const heliaBlockDir = join59(ipfsDir, "blocks");
49618
- if (existsSync43(heliaBlockDir)) {
49756
+ const heliaBlockDir = join60(ipfsDir, "blocks");
49757
+ if (existsSync44(heliaBlockDir)) {
49619
49758
  const walkDir = (dir) => {
49620
49759
  for (const entry of readdirSync13(dir, { withFileTypes: true })) {
49621
49760
  if (entry.isDirectory())
49622
- walkDir(join59(dir, entry.name));
49761
+ walkDir(join60(dir, entry.name));
49623
49762
  else {
49624
49763
  heliaBlocks++;
49625
49764
  try {
49626
- heliaBytes += statSync15(join59(dir, entry.name)).size;
49765
+ heliaBytes += statSync15(join60(dir, entry.name)).size;
49627
49766
  } catch {
49628
49767
  }
49629
49768
  }
@@ -49639,9 +49778,9 @@ async function handleSlashCommand(input, ctx) {
49639
49778
  lines.push(` Blocks: ${c2.bold(String(heliaBlocks))} Size: ${c2.bold(formatFileSize(heliaBytes))}`);
49640
49779
  lines.push(` Backend: ${heliaBlocks > 0 ? c2.green("helia-ipfs") : c2.yellow("sha256-local (Helia not initialized)")}`);
49641
49780
  try {
49642
- const statusFile = join59(ctx.repoRoot, ".oa", "nexus", "status.json");
49643
- if (existsSync43(statusFile)) {
49644
- const status = JSON.parse(readFileSync32(statusFile, "utf8"));
49781
+ const statusFile = join60(ctx.repoRoot, ".oa", "nexus", "status.json");
49782
+ if (existsSync44(statusFile)) {
49783
+ const status = JSON.parse(readFileSync33(statusFile, "utf8"));
49645
49784
  if (status.peerId) {
49646
49785
  lines.push(`
49647
49786
  ${c2.bold("Peer Info")}`);
@@ -49660,11 +49799,11 @@ async function handleSlashCommand(input, ctx) {
49660
49799
  ${c2.dim("Commands: /ipfs pin <CID> /ipfs publish /ipfs cids")}`);
49661
49800
  lines.push(`
49662
49801
  ${c2.bold("Identity Kernel")}`);
49663
- const idDir = join59(ctx.repoRoot, ".oa", "identity");
49802
+ const idDir = join60(ctx.repoRoot, ".oa", "identity");
49664
49803
  try {
49665
- const stateFile = join59(idDir, "self-state.json");
49666
- if (existsSync43(stateFile)) {
49667
- const state = JSON.parse(readFileSync32(stateFile, "utf8"));
49804
+ const stateFile = join60(idDir, "self-state.json");
49805
+ if (existsSync44(stateFile)) {
49806
+ const state = JSON.parse(readFileSync33(stateFile, "utf8"));
49668
49807
  lines.push(` Version: ${c2.bold("v" + (state.version ?? "?"))} Sessions: ${c2.bold(String(state.session_count ?? 0))}`);
49669
49808
  if (state.narrative_summary) {
49670
49809
  lines.push(` Narrative: ${c2.dim(state.narrative_summary.slice(0, 60))}${state.narrative_summary.length > 60 ? "..." : ""}`);
@@ -49673,9 +49812,9 @@ async function handleSlashCommand(input, ctx) {
49673
49812
  const traits = typeof state.personality_traits === "object" ? Object.entries(state.personality_traits).map(([k, v]) => `${k}:${v}`).join(", ") : String(state.personality_traits);
49674
49813
  lines.push(` Traits: ${c2.dim(traits.slice(0, 60))}`);
49675
49814
  }
49676
- const cidFile = join59(idDir, "cids.json");
49677
- if (existsSync43(cidFile)) {
49678
- const cids = JSON.parse(readFileSync32(cidFile, "utf8"));
49815
+ const cidFile = join60(idDir, "cids.json");
49816
+ if (existsSync44(cidFile)) {
49817
+ const cids = JSON.parse(readFileSync33(cidFile, "utf8"));
49679
49818
  const lastCid = Array.isArray(cids) ? cids[cids.length - 1] : cids.latest;
49680
49819
  if (lastCid)
49681
49820
  lines.push(` Last CID: ${c2.dim(String(lastCid).slice(0, 50))}`);
@@ -49688,9 +49827,9 @@ async function handleSlashCommand(input, ctx) {
49688
49827
  lines.push(`
49689
49828
  ${c2.bold("Memory Sentiment")}`);
49690
49829
  try {
49691
- const metaFile = join59(ctx.repoRoot, ".oa", "memory", "metabolism", "store.json");
49692
- if (existsSync43(metaFile)) {
49693
- const store2 = JSON.parse(readFileSync32(metaFile, "utf8"));
49830
+ const metaFile = join60(ctx.repoRoot, ".oa", "memory", "metabolism", "store.json");
49831
+ if (existsSync44(metaFile)) {
49832
+ const store2 = JSON.parse(readFileSync33(metaFile, "utf8"));
49694
49833
  const active = store2.filter((m) => m.type !== "quarantine");
49695
49834
  const recoveries = active.filter((m) => m.content?.startsWith("[recovery]")).length;
49696
49835
  const strategies = active.filter((m) => m.content?.startsWith("[strategy]")).length;
@@ -49708,8 +49847,8 @@ async function handleSlashCommand(input, ctx) {
49708
49847
  } catch {
49709
49848
  }
49710
49849
  try {
49711
- const dbPath = join59(ctx.repoRoot, ".oa", "memory", "structured.db");
49712
- if (existsSync43(dbPath)) {
49850
+ const dbPath = join60(ctx.repoRoot, ".oa", "memory", "structured.db");
49851
+ if (existsSync44(dbPath)) {
49713
49852
  const { initDb: initDb2, closeDb: cDb, ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
49714
49853
  const db = initDb2(dbPath);
49715
49854
  const memStore = new ProceduralMemoryStore2(db);
@@ -49730,8 +49869,8 @@ async function handleSlashCommand(input, ctx) {
49730
49869
  lines.push(`
49731
49870
  ${c2.bold("Storage Overview")}
49732
49871
  `);
49733
- const oaDir = join59(ctx.repoRoot, ".oa");
49734
- if (!existsSync43(oaDir)) {
49872
+ const oaDir = join60(ctx.repoRoot, ".oa");
49873
+ if (!existsSync44(oaDir)) {
49735
49874
  lines.push(` ${c2.dim("No .oa/ directory found.")}`);
49736
49875
  safeLog(lines.join("\n") + "\n");
49737
49876
  return "handled";
@@ -49741,7 +49880,7 @@ async function handleSlashCommand(input, ctx) {
49741
49880
  const walkStorage = (dir, category) => {
49742
49881
  try {
49743
49882
  for (const entry of readdirSync13(dir, { withFileTypes: true })) {
49744
- const full = join59(dir, entry.name);
49883
+ const full = join60(dir, entry.name);
49745
49884
  if (entry.isDirectory()) {
49746
49885
  const subCat = category || entry.name;
49747
49886
  walkStorage(full, subCat);
@@ -49777,10 +49916,10 @@ async function handleSlashCommand(input, ctx) {
49777
49916
  for (const entry of readdirSync13(dir, { withFileTypes: true })) {
49778
49917
  const name = entry.name.toLowerCase();
49779
49918
  if (sensitivePatterns.some((p) => name.includes(p))) {
49780
- sensitiveFound.push(join59(dir, entry.name).replace(oaDir + "/", ""));
49919
+ sensitiveFound.push(join60(dir, entry.name).replace(oaDir + "/", ""));
49781
49920
  }
49782
49921
  if (entry.isDirectory())
49783
- checkSensitive(join59(dir, entry.name));
49922
+ checkSensitive(join60(dir, entry.name));
49784
49923
  }
49785
49924
  } catch {
49786
49925
  }
@@ -49808,8 +49947,8 @@ async function handleSlashCommand(input, ctx) {
49808
49947
  renderInfo("Supported: .wav .mp3 .flac .ogg (audio\u2192transcribe) | .pdf .txt .md (text\u2192chunk)");
49809
49948
  return "handled";
49810
49949
  }
49811
- const resolvedPath = join59(ctx.repoRoot, filePath);
49812
- if (!existsSync43(resolvedPath)) {
49950
+ const resolvedPath = join60(ctx.repoRoot, filePath);
49951
+ if (!existsSync44(resolvedPath)) {
49813
49952
  renderWarning(`File not found: ${resolvedPath}`);
49814
49953
  return "handled";
49815
49954
  }
@@ -49825,9 +49964,9 @@ async function handleSlashCommand(input, ctx) {
49825
49964
  }
49826
49965
  try {
49827
49966
  const { initDb: initDb2, closeDb: cDb, ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
49828
- const dbDir = join59(ctx.repoRoot, ".oa", "memory");
49829
- mkdirSync19(dbDir, { recursive: true });
49830
- const db = initDb2(join59(dbDir, "structured.db"));
49967
+ const dbDir = join60(ctx.repoRoot, ".oa", "memory");
49968
+ mkdirSync20(dbDir, { recursive: true });
49969
+ const db = initDb2(join60(dbDir, "structured.db"));
49831
49970
  const memStore = new ProceduralMemoryStore2(db);
49832
49971
  if (isAudio) {
49833
49972
  renderInfo(`Transcribing: ${filePath}...`);
@@ -49868,7 +50007,7 @@ async function handleSlashCommand(input, ctx) {
49868
50007
  return "handled";
49869
50008
  }
49870
50009
  } else {
49871
- content = readFileSync32(resolvedPath, "utf8");
50010
+ content = readFileSync33(resolvedPath, "utf8");
49872
50011
  }
49873
50012
  if (!content.trim()) {
49874
50013
  renderWarning("No content extracted.");
@@ -49907,9 +50046,9 @@ async function handleSlashCommand(input, ctx) {
49907
50046
  }
49908
50047
  case "fortemi": {
49909
50048
  const fortemiSubCmd = (arg || "").trim().toLowerCase();
49910
- const fortemiDir = join59(ctx.repoRoot, "..", "fortemi-react");
49911
- const altFortemiDir = join59(nodeOs.homedir(), "fortemi-react");
49912
- const fDir = existsSync43(fortemiDir) ? fortemiDir : existsSync43(altFortemiDir) ? altFortemiDir : null;
50049
+ const fortemiDir = join60(ctx.repoRoot, "..", "fortemi-react");
50050
+ const altFortemiDir = join60(nodeOs.homedir(), "fortemi-react");
50051
+ const fDir = existsSync44(fortemiDir) ? fortemiDir : existsSync44(altFortemiDir) ? altFortemiDir : null;
49913
50052
  if (fortemiSubCmd === "start" || fortemiSubCmd === "") {
49914
50053
  if (!fDir) {
49915
50054
  renderWarning("fortemi-react not found adjacent or in home directory.");
@@ -49924,14 +50063,14 @@ async function handleSlashCommand(input, ctx) {
49924
50063
  // 24h
49925
50064
  nonce: Math.random().toString(36).slice(2, 10)
49926
50065
  };
49927
- const jwtFile = join59(ctx.repoRoot, ".oa", "fortemi-jwt.json");
49928
- mkdirSync19(join59(ctx.repoRoot, ".oa"), { recursive: true });
49929
- writeFileSync20(jwtFile, JSON.stringify(jwtPayload, null, 2));
50066
+ const jwtFile = join60(ctx.repoRoot, ".oa", "fortemi-jwt.json");
50067
+ mkdirSync20(join60(ctx.repoRoot, ".oa"), { recursive: true });
50068
+ writeFileSync21(jwtFile, JSON.stringify(jwtPayload, null, 2));
49930
50069
  renderInfo(`Launching fortemi-react from ${fDir}...`);
49931
50070
  try {
49932
50071
  const { spawn: spawn23 } = __require("node:child_process");
49933
50072
  const child = spawn23("npx", ["vite", "dev", "--host", "0.0.0.0", "--port", "3000"], {
49934
- cwd: join59(fDir, "apps", "standalone"),
50073
+ cwd: join60(fDir, "apps", "standalone"),
49935
50074
  stdio: "ignore",
49936
50075
  detached: true,
49937
50076
  env: { ...process.env, OA_JWT: JSON.stringify(jwtPayload) }
@@ -49940,8 +50079,8 @@ async function handleSlashCommand(input, ctx) {
49940
50079
  renderInfo("Fortemi-React starting on http://localhost:3000");
49941
50080
  renderInfo(`JWT saved to ${jwtFile}`);
49942
50081
  renderInfo("Memory operations will proxy to fortemi when available.");
49943
- const bridgeFile = join59(ctx.repoRoot, ".oa", "fortemi-bridge.json");
49944
- writeFileSync20(bridgeFile, JSON.stringify({
50082
+ const bridgeFile = join60(ctx.repoRoot, ".oa", "fortemi-bridge.json");
50083
+ writeFileSync21(bridgeFile, JSON.stringify({
49945
50084
  url: "http://localhost:3000",
49946
50085
  pid: child.pid,
49947
50086
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -49953,12 +50092,12 @@ async function handleSlashCommand(input, ctx) {
49953
50092
  return "handled";
49954
50093
  }
49955
50094
  if (fortemiSubCmd === "status") {
49956
- const bridgeFile = join59(ctx.repoRoot, ".oa", "fortemi-bridge.json");
49957
- if (!existsSync43(bridgeFile)) {
50095
+ const bridgeFile = join60(ctx.repoRoot, ".oa", "fortemi-bridge.json");
50096
+ if (!existsSync44(bridgeFile)) {
49958
50097
  renderInfo("Fortemi bridge: not connected. Run /fortemi start");
49959
50098
  return "handled";
49960
50099
  }
49961
- const bridge = JSON.parse(readFileSync32(bridgeFile, "utf8"));
50100
+ const bridge = JSON.parse(readFileSync33(bridgeFile, "utf8"));
49962
50101
  let alive = false;
49963
50102
  try {
49964
50103
  process.kill(bridge.pid, 0);
@@ -49978,15 +50117,15 @@ async function handleSlashCommand(input, ctx) {
49978
50117
  lines.push(` Process: ${alive ? c2.green("running") : c2.yellow("not running")} (PID ${bridge.pid})`);
49979
50118
  lines.push(` HTTP: ${httpOk ? c2.green("connected") : c2.yellow("unreachable")}`);
49980
50119
  lines.push(` Started: ${bridge.startedAt}`);
49981
- lines.push(` JWT: ${existsSync43(bridge.jwtFile) ? c2.green("valid") : c2.yellow("missing")}`);
50120
+ lines.push(` JWT: ${existsSync44(bridge.jwtFile) ? c2.green("valid") : c2.yellow("missing")}`);
49982
50121
  lines.push("");
49983
50122
  safeLog(lines.join("\n"));
49984
50123
  return "handled";
49985
50124
  }
49986
50125
  if (fortemiSubCmd === "stop") {
49987
- const bridgeFile = join59(ctx.repoRoot, ".oa", "fortemi-bridge.json");
49988
- if (existsSync43(bridgeFile)) {
49989
- const bridge = JSON.parse(readFileSync32(bridgeFile, "utf8"));
50126
+ const bridgeFile = join60(ctx.repoRoot, ".oa", "fortemi-bridge.json");
50127
+ if (existsSync44(bridgeFile)) {
50128
+ const bridge = JSON.parse(readFileSync33(bridgeFile, "utf8"));
49990
50129
  try {
49991
50130
  process.kill(bridge.pid, "SIGTERM");
49992
50131
  } catch {
@@ -50749,10 +50888,10 @@ Clone a new voice: /voice clone <wav-file> [name]`);
50749
50888
  let sponsorName = (config.header.message || "").replace(/^\/+/, "").trim();
50750
50889
  if (!sponsorName || sponsorName.length < 2) {
50751
50890
  try {
50752
- const { homedir: homedir21 } = __require("os");
50753
- const namePath = __require("path").join(homedir21(), ".open-agents", "agent-name");
50754
- if (existsSync43(namePath))
50755
- sponsorName = readFileSync32(namePath, "utf8").trim();
50891
+ const { homedir: homedir22 } = __require("os");
50892
+ const namePath = __require("path").join(homedir22(), ".open-agents", "agent-name");
50893
+ if (existsSync44(namePath))
50894
+ sponsorName = readFileSync33(namePath, "utf8").trim();
50756
50895
  } catch {
50757
50896
  }
50758
50897
  if (!sponsorName)
@@ -51823,13 +51962,13 @@ async function showCohereDashboard(ctx) {
51823
51962
  } else if (idResult.key === "view") {
51824
51963
  await ik.execute({ operation: "hydrate" });
51825
51964
  } else if (idResult.key === "history") {
51826
- const snapDir = join59(ctx.repoRoot, ".oa", "identity", "snapshots");
51827
- if (existsSync43(snapDir)) {
51965
+ const snapDir = join60(ctx.repoRoot, ".oa", "identity", "snapshots");
51966
+ if (existsSync44(snapDir)) {
51828
51967
  const snaps = readdirSync13(snapDir).filter((f) => f.endsWith(".json")).sort().reverse();
51829
51968
  const snapItems = snaps.slice(0, 20).map((f) => ({
51830
51969
  key: f,
51831
51970
  label: f.replace(".json", ""),
51832
- detail: `${formatFileSize(statSync15(join59(snapDir, f)).size)}`
51971
+ detail: `${formatFileSize(statSync15(join60(snapDir, f)).size)}`
51833
51972
  }));
51834
51973
  if (snapItems.length > 0) {
51835
51974
  await tuiSelect({
@@ -52140,12 +52279,12 @@ async function handleVoiceMenu(ctx, save, hasLocal) {
52140
52279
  continue;
52141
52280
  }
52142
52281
  const { basename: basename18, join: pathJoin } = await import("node:path");
52143
- const { copyFileSync: copyFileSync3, mkdirSync: mkdirSync33, existsSync: exists } = await import("node:fs");
52144
- const { homedir: homedir21 } = await import("node:os");
52282
+ const { copyFileSync: copyFileSync3, mkdirSync: mkdirSync34, existsSync: exists } = await import("node:fs");
52283
+ const { homedir: homedir22 } = await import("node:os");
52145
52284
  const modelName = basename18(onnxDrop.path, ".onnx").replace(/[^a-zA-Z0-9_-]/g, "-");
52146
- const destDir = pathJoin(homedir21(), ".open-agents", "voice", "models", modelName);
52285
+ const destDir = pathJoin(homedir22(), ".open-agents", "voice", "models", modelName);
52147
52286
  if (!exists(destDir))
52148
- mkdirSync33(destDir, { recursive: true });
52287
+ mkdirSync34(destDir, { recursive: true });
52149
52288
  copyFileSync3(onnxDrop.path, pathJoin(destDir, "model.onnx"));
52150
52289
  copyFileSync3(jsonDrop.path, pathJoin(destDir, "config.json"));
52151
52290
  const { registerCustomOnnxModel: registerCustomOnnxModel2 } = await Promise.resolve().then(() => (init_voice(), voice_exports));
@@ -52772,11 +52911,11 @@ async function handleSponsoredEndpoint(ctx, local) {
52772
52911
  }
52773
52912
  } catch {
52774
52913
  }
52775
- const sponsorDir2 = join59(ctx.repoRoot ?? process.cwd(), ".oa", "sponsor");
52776
- const knownFile = join59(sponsorDir2, "known-sponsors.json");
52914
+ const sponsorDir2 = join60(ctx.repoRoot ?? process.cwd(), ".oa", "sponsor");
52915
+ const knownFile = join60(sponsorDir2, "known-sponsors.json");
52777
52916
  try {
52778
- if (existsSync43(knownFile)) {
52779
- const saved = JSON.parse(readFileSync32(knownFile, "utf8"));
52917
+ if (existsSync44(knownFile)) {
52918
+ const saved = JSON.parse(readFileSync33(knownFile, "utf8"));
52780
52919
  for (const s of saved) {
52781
52920
  if (!sponsors.some((sp) => sp.url === s.url)) {
52782
52921
  sponsors.push({ ...s, source: "saved" });
@@ -52911,11 +53050,11 @@ async function handleSponsoredEndpoint(ctx, local) {
52911
53050
  }
52912
53051
  const saveKey = selected.url || selected.peerId || selected.name;
52913
53052
  try {
52914
- mkdirSync19(sponsorDir2, { recursive: true });
52915
- const existing = existsSync43(knownFile) ? JSON.parse(readFileSync32(knownFile, "utf8")) : [];
53053
+ mkdirSync20(sponsorDir2, { recursive: true });
53054
+ const existing = existsSync44(knownFile) ? JSON.parse(readFileSync33(knownFile, "utf8")) : [];
52916
53055
  const updated = existing.filter((s) => (s.url || s.peerId || s.name) !== saveKey);
52917
53056
  updated.push(selected);
52918
- writeFileSync20(knownFile, JSON.stringify(updated, null, 2), "utf8");
53057
+ writeFileSync21(knownFile, JSON.stringify(updated, null, 2), "utf8");
52919
53058
  } catch {
52920
53059
  }
52921
53060
  renderInfo(`Connected to sponsored endpoint: ${selected.name}`);
@@ -52984,11 +53123,11 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
52984
53123
  const models = await fetchModels(peerUrl, authKey);
52985
53124
  if (models.length > 0) {
52986
53125
  try {
52987
- const { writeFileSync: writeFileSync31, mkdirSync: mkdirSync33 } = await import("node:fs");
52988
- const { join: join80, dirname: dirname24 } = await import("node:path");
52989
- const cachePath = join80(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
52990
- mkdirSync33(dirname24(cachePath), { recursive: true });
52991
- writeFileSync31(cachePath, JSON.stringify({
53126
+ const { writeFileSync: writeFileSync32, mkdirSync: mkdirSync34 } = await import("node:fs");
53127
+ const { join: join81, dirname: dirname24 } = await import("node:path");
53128
+ const cachePath = join81(ctx.repoRoot || process.cwd(), ".oa", "nexus", "peer-models-cache.json");
53129
+ mkdirSync34(dirname24(cachePath), { recursive: true });
53130
+ writeFileSync32(cachePath, JSON.stringify({
52992
53131
  peerId,
52993
53132
  cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
52994
53133
  models: models.map((m) => ({ name: m.name, size: m.size, parameterSize: m.parameterSize }))
@@ -53187,17 +53326,17 @@ async function handleUpdate(subcommand, ctx) {
53187
53326
  try {
53188
53327
  const { createRequire: createRequire6 } = await import("node:module");
53189
53328
  const { fileURLToPath: fileURLToPath16 } = await import("node:url");
53190
- const { dirname: dirname24, join: join80 } = await import("node:path");
53191
- const { existsSync: existsSync60 } = await import("node:fs");
53329
+ const { dirname: dirname24, join: join81 } = await import("node:path");
53330
+ const { existsSync: existsSync61 } = await import("node:fs");
53192
53331
  const req = createRequire6(import.meta.url);
53193
53332
  const thisDir = dirname24(fileURLToPath16(import.meta.url));
53194
53333
  const candidates = [
53195
- join80(thisDir, "..", "package.json"),
53196
- join80(thisDir, "..", "..", "package.json"),
53197
- join80(thisDir, "..", "..", "..", "package.json")
53334
+ join81(thisDir, "..", "package.json"),
53335
+ join81(thisDir, "..", "..", "package.json"),
53336
+ join81(thisDir, "..", "..", "..", "package.json")
53198
53337
  ];
53199
53338
  for (const pkgPath of candidates) {
53200
- if (existsSync60(pkgPath)) {
53339
+ if (existsSync61(pkgPath)) {
53201
53340
  const pkg = req(pkgPath);
53202
53341
  if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
53203
53342
  currentVersion = pkg.version ?? "0.0.0";
@@ -54045,10 +54184,10 @@ var init_commands = __esm({
54045
54184
  });
54046
54185
 
54047
54186
  // packages/cli/dist/tui/project-context.js
54048
- import { existsSync as existsSync44, readFileSync as readFileSync33, readdirSync as readdirSync14 } from "node:fs";
54049
- import { join as join60, basename as basename12 } from "node:path";
54187
+ import { existsSync as existsSync45, readFileSync as readFileSync34, readdirSync as readdirSync14 } from "node:fs";
54188
+ import { join as join61, basename as basename12 } from "node:path";
54050
54189
  import { execSync as execSync32 } from "node:child_process";
54051
- import { homedir as homedir17, platform as platform4, release } from "node:os";
54190
+ import { homedir as homedir18, platform as platform4, release } from "node:os";
54052
54191
  function getModelTier(modelName) {
54053
54192
  const m = modelName.toLowerCase();
54054
54193
  const sizeMatch = m.match(/\b(\d+)b\b/);
@@ -54081,10 +54220,10 @@ function loadProjectMap(repoRoot) {
54081
54220
  if (!hasOaDirectory(repoRoot)) {
54082
54221
  initOaDirectory(repoRoot);
54083
54222
  }
54084
- const mapPath2 = join60(repoRoot, OA_DIR, "context", "project-map.md");
54085
- if (existsSync44(mapPath2)) {
54223
+ const mapPath2 = join61(repoRoot, OA_DIR, "context", "project-map.md");
54224
+ if (existsSync45(mapPath2)) {
54086
54225
  try {
54087
- const content = readFileSync33(mapPath2, "utf-8");
54226
+ const content = readFileSync34(mapPath2, "utf-8");
54088
54227
  return content;
54089
54228
  } catch {
54090
54229
  }
@@ -54125,31 +54264,31 @@ ${log2}`);
54125
54264
  }
54126
54265
  function loadMemoryContext(repoRoot) {
54127
54266
  const sections = [];
54128
- const oaMemDir = join60(repoRoot, OA_DIR, "memory");
54267
+ const oaMemDir = join61(repoRoot, OA_DIR, "memory");
54129
54268
  const oaEntries = loadMemoryDir(oaMemDir, "project");
54130
54269
  if (oaEntries)
54131
54270
  sections.push(oaEntries);
54132
- const legacyMemDir = join60(repoRoot, ".open-agents", "memory");
54133
- if (legacyMemDir !== oaMemDir && existsSync44(legacyMemDir)) {
54271
+ const legacyMemDir = join61(repoRoot, ".open-agents", "memory");
54272
+ if (legacyMemDir !== oaMemDir && existsSync45(legacyMemDir)) {
54134
54273
  const legacyEntries = loadMemoryDir(legacyMemDir, "project/legacy");
54135
54274
  if (legacyEntries)
54136
54275
  sections.push(legacyEntries);
54137
54276
  }
54138
- const globalMemDir = join60(homedir17(), ".open-agents", "memory");
54277
+ const globalMemDir = join61(homedir18(), ".open-agents", "memory");
54139
54278
  const globalEntries = loadMemoryDir(globalMemDir, "global");
54140
54279
  if (globalEntries)
54141
54280
  sections.push(globalEntries);
54142
54281
  return sections.join("\n\n");
54143
54282
  }
54144
54283
  function loadMemoryDir(memDir, scope) {
54145
- if (!existsSync44(memDir))
54284
+ if (!existsSync45(memDir))
54146
54285
  return "";
54147
54286
  const lines = [];
54148
54287
  try {
54149
54288
  const files = readdirSync14(memDir).filter((f) => f.endsWith(".json"));
54150
54289
  for (const file of files.slice(0, 10)) {
54151
54290
  try {
54152
- const raw = readFileSync33(join60(memDir, file), "utf-8");
54291
+ const raw = readFileSync34(join61(memDir, file), "utf-8");
54153
54292
  const entries = JSON.parse(raw);
54154
54293
  const topic = basename12(file, ".json");
54155
54294
  const keys = Object.keys(entries);
@@ -55294,8 +55433,8 @@ __export(banner_exports, {
55294
55433
  saveBannerDesign: () => saveBannerDesign,
55295
55434
  setGridText: () => setGridText
55296
55435
  });
55297
- import { existsSync as existsSync45, readFileSync as readFileSync34, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20 } from "node:fs";
55298
- import { join as join61 } from "node:path";
55436
+ import { existsSync as existsSync46, readFileSync as readFileSync35, writeFileSync as writeFileSync22, mkdirSync as mkdirSync21 } from "node:fs";
55437
+ import { join as join62 } from "node:path";
55299
55438
  function generateMnemonic(seed) {
55300
55439
  let h = 2166136261;
55301
55440
  for (let i = 0; i < seed.length; i++) {
@@ -55490,23 +55629,23 @@ function createSponsorBanner(sponsorName, tagline, primaryColor = 214, bgColor =
55490
55629
  };
55491
55630
  }
55492
55631
  function saveBannerDesign(workDir, design) {
55493
- const dir = join61(workDir, ".oa", "banners");
55494
- mkdirSync20(dir, { recursive: true });
55495
- writeFileSync21(join61(dir, `${design.id}.json`), JSON.stringify(design, null, 2), "utf8");
55632
+ const dir = join62(workDir, ".oa", "banners");
55633
+ mkdirSync21(dir, { recursive: true });
55634
+ writeFileSync22(join62(dir, `${design.id}.json`), JSON.stringify(design, null, 2), "utf8");
55496
55635
  }
55497
55636
  function loadBannerDesign(workDir, id) {
55498
- const file = join61(workDir, ".oa", "banners", `${id}.json`);
55499
- if (!existsSync45(file))
55637
+ const file = join62(workDir, ".oa", "banners", `${id}.json`);
55638
+ if (!existsSync46(file))
55500
55639
  return null;
55501
55640
  try {
55502
- return JSON.parse(readFileSync34(file, "utf8"));
55641
+ return JSON.parse(readFileSync35(file, "utf8"));
55503
55642
  } catch {
55504
55643
  return null;
55505
55644
  }
55506
55645
  }
55507
55646
  function listBannerDesigns(workDir) {
55508
- const dir = join61(workDir, ".oa", "banners");
55509
- if (!existsSync45(dir))
55647
+ const dir = join62(workDir, ".oa", "banners");
55648
+ if (!existsSync46(dir))
55510
55649
  return [];
55511
55650
  try {
55512
55651
  const { readdirSync: readdirSync25 } = __require("node:fs");
@@ -55864,22 +56003,22 @@ var init_banner = __esm({
55864
56003
  });
55865
56004
 
55866
56005
  // packages/cli/dist/tui/carousel-descriptors.js
55867
- import { existsSync as existsSync46, readFileSync as readFileSync35, writeFileSync as writeFileSync22, mkdirSync as mkdirSync21, readdirSync as readdirSync15 } from "node:fs";
55868
- import { join as join62, basename as basename13 } from "node:path";
56006
+ import { existsSync as existsSync47, readFileSync as readFileSync36, writeFileSync as writeFileSync23, mkdirSync as mkdirSync22, readdirSync as readdirSync15 } from "node:fs";
56007
+ import { join as join63, basename as basename13 } from "node:path";
55869
56008
  function loadToolProfile(repoRoot) {
55870
- const filePath = join62(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
56009
+ const filePath = join63(repoRoot, OA_DIR, "context", TOOL_PROFILE_FILE);
55871
56010
  try {
55872
- if (!existsSync46(filePath))
56011
+ if (!existsSync47(filePath))
55873
56012
  return null;
55874
- return JSON.parse(readFileSync35(filePath, "utf-8"));
56013
+ return JSON.parse(readFileSync36(filePath, "utf-8"));
55875
56014
  } catch {
55876
56015
  return null;
55877
56016
  }
55878
56017
  }
55879
56018
  function saveToolProfile(repoRoot, profile) {
55880
- const contextDir = join62(repoRoot, OA_DIR, "context");
55881
- mkdirSync21(contextDir, { recursive: true });
55882
- writeFileSync22(join62(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
56019
+ const contextDir = join63(repoRoot, OA_DIR, "context");
56020
+ mkdirSync22(contextDir, { recursive: true });
56021
+ writeFileSync23(join63(contextDir, TOOL_PROFILE_FILE), JSON.stringify(profile, null, 2), "utf-8");
55883
56022
  }
55884
56023
  function categorizeToolCall(toolName) {
55885
56024
  for (const cat of TOOL_CATEGORIES) {
@@ -55937,25 +56076,25 @@ function weightedColor(profile) {
55937
56076
  return selectedCat.colors[Math.floor(Math.random() * selectedCat.colors.length)];
55938
56077
  }
55939
56078
  function loadCachedDescriptors(repoRoot) {
55940
- const filePath = join62(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
56079
+ const filePath = join63(repoRoot, OA_DIR, "context", DESCRIPTOR_FILE);
55941
56080
  try {
55942
- if (!existsSync46(filePath))
56081
+ if (!existsSync47(filePath))
55943
56082
  return null;
55944
- const cached = JSON.parse(readFileSync35(filePath, "utf-8"));
56083
+ const cached = JSON.parse(readFileSync36(filePath, "utf-8"));
55945
56084
  return cached.phrases.length > 0 ? cached.phrases : null;
55946
56085
  } catch {
55947
56086
  return null;
55948
56087
  }
55949
56088
  }
55950
56089
  function saveCachedDescriptors(repoRoot, phrases, sourceHash) {
55951
- const contextDir = join62(repoRoot, OA_DIR, "context");
55952
- mkdirSync21(contextDir, { recursive: true });
56090
+ const contextDir = join63(repoRoot, OA_DIR, "context");
56091
+ mkdirSync22(contextDir, { recursive: true });
55953
56092
  const cached = {
55954
56093
  phrases,
55955
56094
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
55956
56095
  sourceHash
55957
56096
  };
55958
- writeFileSync22(join62(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
56097
+ writeFileSync23(join63(contextDir, DESCRIPTOR_FILE), JSON.stringify(cached, null, 2), "utf-8");
55959
56098
  }
55960
56099
  function generateDescriptors(repoRoot) {
55961
56100
  const profile = loadToolProfile(repoRoot);
@@ -56003,11 +56142,11 @@ function generateDescriptors(repoRoot) {
56003
56142
  return phrases;
56004
56143
  }
56005
56144
  function extractFromPackageJson(repoRoot, tags) {
56006
- const pkgPath = join62(repoRoot, "package.json");
56145
+ const pkgPath = join63(repoRoot, "package.json");
56007
56146
  try {
56008
- if (!existsSync46(pkgPath))
56147
+ if (!existsSync47(pkgPath))
56009
56148
  return;
56010
- const pkg = JSON.parse(readFileSync35(pkgPath, "utf-8"));
56149
+ const pkg = JSON.parse(readFileSync36(pkgPath, "utf-8"));
56011
56150
  if (pkg.name && typeof pkg.name === "string") {
56012
56151
  const parts = pkg.name.replace(/^@/, "").split("/");
56013
56152
  for (const p of parts)
@@ -56051,7 +56190,7 @@ function extractFromManifests(repoRoot, tags) {
56051
56190
  { file: ".github/workflows", tag: "ci/cd" }
56052
56191
  ];
56053
56192
  for (const check of manifestChecks) {
56054
- if (existsSync46(join62(repoRoot, check.file))) {
56193
+ if (existsSync47(join63(repoRoot, check.file))) {
56055
56194
  tags.push(check.tag);
56056
56195
  }
56057
56196
  }
@@ -56073,16 +56212,16 @@ function extractFromSessions(repoRoot, tags) {
56073
56212
  }
56074
56213
  }
56075
56214
  function extractFromMemory(repoRoot, tags) {
56076
- const memoryDir = join62(repoRoot, OA_DIR, "memory");
56215
+ const memoryDir = join63(repoRoot, OA_DIR, "memory");
56077
56216
  try {
56078
- if (!existsSync46(memoryDir))
56217
+ if (!existsSync47(memoryDir))
56079
56218
  return;
56080
56219
  const files = readdirSync15(memoryDir).filter((f) => f.endsWith(".json"));
56081
56220
  for (const file of files) {
56082
56221
  const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
56083
56222
  tags.push(topic);
56084
56223
  try {
56085
- const data = JSON.parse(readFileSync35(join62(memoryDir, file), "utf-8"));
56224
+ const data = JSON.parse(readFileSync36(join63(memoryDir, file), "utf-8"));
56086
56225
  if (data && typeof data === "object") {
56087
56226
  const keys = Object.keys(data).slice(0, 3);
56088
56227
  for (const key of keys) {
@@ -56753,13 +56892,13 @@ var init_stream_renderer = __esm({
56753
56892
  });
56754
56893
 
56755
56894
  // packages/cli/dist/tui/edit-history.js
56756
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync22 } from "node:fs";
56757
- import { join as join63 } from "node:path";
56895
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync23 } from "node:fs";
56896
+ import { join as join64 } from "node:path";
56758
56897
  function createEditHistoryLogger(repoRoot, sessionId) {
56759
- const historyDir = join63(repoRoot, ".oa", "history");
56760
- const logPath2 = join63(historyDir, "edits.jsonl");
56898
+ const historyDir = join64(repoRoot, ".oa", "history");
56899
+ const logPath2 = join64(historyDir, "edits.jsonl");
56761
56900
  try {
56762
- mkdirSync22(historyDir, { recursive: true });
56901
+ mkdirSync23(historyDir, { recursive: true });
56763
56902
  } catch {
56764
56903
  }
56765
56904
  function logToolCall(toolName, toolArgs, success) {
@@ -56868,17 +57007,17 @@ var init_edit_history = __esm({
56868
57007
  });
56869
57008
 
56870
57009
  // packages/cli/dist/tui/promptLoader.js
56871
- import { readFileSync as readFileSync36, existsSync as existsSync47 } from "node:fs";
56872
- import { join as join64, dirname as dirname20 } from "node:path";
57010
+ import { readFileSync as readFileSync37, existsSync as existsSync48 } from "node:fs";
57011
+ import { join as join65, dirname as dirname20 } from "node:path";
56873
57012
  import { fileURLToPath as fileURLToPath12 } from "node:url";
56874
57013
  function loadPrompt3(promptPath, vars) {
56875
57014
  let content = cache3.get(promptPath);
56876
57015
  if (content === void 0) {
56877
- const fullPath = join64(PROMPTS_DIR3, promptPath);
56878
- if (!existsSync47(fullPath)) {
57016
+ const fullPath = join65(PROMPTS_DIR3, promptPath);
57017
+ if (!existsSync48(fullPath)) {
56879
57018
  throw new Error(`Prompt file not found: ${fullPath}`);
56880
57019
  }
56881
- content = readFileSync36(fullPath, "utf-8");
57020
+ content = readFileSync37(fullPath, "utf-8");
56882
57021
  cache3.set(promptPath, content);
56883
57022
  }
56884
57023
  if (!vars)
@@ -56891,23 +57030,23 @@ var init_promptLoader3 = __esm({
56891
57030
  "use strict";
56892
57031
  __filename3 = fileURLToPath12(import.meta.url);
56893
57032
  __dirname6 = dirname20(__filename3);
56894
- devPath2 = join64(__dirname6, "..", "..", "prompts");
56895
- publishedPath2 = join64(__dirname6, "..", "prompts");
56896
- PROMPTS_DIR3 = existsSync47(devPath2) ? devPath2 : publishedPath2;
57033
+ devPath2 = join65(__dirname6, "..", "..", "prompts");
57034
+ publishedPath2 = join65(__dirname6, "..", "prompts");
57035
+ PROMPTS_DIR3 = existsSync48(devPath2) ? devPath2 : publishedPath2;
56897
57036
  cache3 = /* @__PURE__ */ new Map();
56898
57037
  }
56899
57038
  });
56900
57039
 
56901
57040
  // packages/cli/dist/tui/dream-engine.js
56902
- import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync23, readFileSync as readFileSync37, existsSync as existsSync48, cpSync, rmSync as rmSync2, readdirSync as readdirSync16 } from "node:fs";
56903
- import { join as join65, basename as basename14 } from "node:path";
57041
+ import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync24, readFileSync as readFileSync38, existsSync as existsSync49, cpSync, rmSync as rmSync2, readdirSync as readdirSync16 } from "node:fs";
57042
+ import { join as join66, basename as basename14 } from "node:path";
56904
57043
  import { execSync as execSync33 } from "node:child_process";
56905
57044
  function loadAutoresearchMemory(repoRoot) {
56906
- const memoryPath = join65(repoRoot, ".oa", "memory", "autoresearch.json");
56907
- if (!existsSync48(memoryPath))
57045
+ const memoryPath = join66(repoRoot, ".oa", "memory", "autoresearch.json");
57046
+ if (!existsSync49(memoryPath))
56908
57047
  return "";
56909
57048
  try {
56910
- const raw = readFileSync37(memoryPath, "utf-8");
57049
+ const raw = readFileSync38(memoryPath, "utf-8");
56911
57050
  const data = JSON.parse(raw);
56912
57051
  const sections = [];
56913
57052
  for (const key of AUTORESEARCH_MEMORY_KEYS) {
@@ -57097,14 +57236,14 @@ var init_dream_engine = __esm({
57097
57236
  const content = String(args["content"] ?? "");
57098
57237
  if (!rawPath)
57099
57238
  return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
57100
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join65(this.autoresearchDir, basename14(rawPath)) : join65(this.autoresearchDir, rawPath);
57239
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join66(this.autoresearchDir, basename14(rawPath)) : join66(this.autoresearchDir, rawPath);
57101
57240
  if (!targetPath.startsWith(this.autoresearchDir)) {
57102
57241
  return { success: false, output: "", error: "Autoresearch mode: writes are confined to .oa/autoresearch/", durationMs: Date.now() - start };
57103
57242
  }
57104
57243
  try {
57105
- const dir = join65(targetPath, "..");
57106
- mkdirSync23(dir, { recursive: true });
57107
- writeFileSync23(targetPath, content, "utf-8");
57244
+ const dir = join66(targetPath, "..");
57245
+ mkdirSync24(dir, { recursive: true });
57246
+ writeFileSync24(targetPath, content, "utf-8");
57108
57247
  return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
57109
57248
  } catch (err) {
57110
57249
  return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
@@ -57132,20 +57271,20 @@ var init_dream_engine = __esm({
57132
57271
  const rawPath = String(args["path"] ?? "");
57133
57272
  const oldStr = String(args["old_string"] ?? "");
57134
57273
  const newStr = String(args["new_string"] ?? "");
57135
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join65(this.autoresearchDir, basename14(rawPath)) : join65(this.autoresearchDir, rawPath);
57274
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/autoresearch") ? join66(this.autoresearchDir, basename14(rawPath)) : join66(this.autoresearchDir, rawPath);
57136
57275
  if (!targetPath.startsWith(this.autoresearchDir)) {
57137
57276
  return { success: false, output: "", error: "Autoresearch mode: edits are confined to .oa/autoresearch/", durationMs: Date.now() - start };
57138
57277
  }
57139
57278
  try {
57140
- if (!existsSync48(targetPath)) {
57279
+ if (!existsSync49(targetPath)) {
57141
57280
  return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start };
57142
57281
  }
57143
- let content = readFileSync37(targetPath, "utf-8");
57282
+ let content = readFileSync38(targetPath, "utf-8");
57144
57283
  if (!content.includes(oldStr)) {
57145
57284
  return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start };
57146
57285
  }
57147
57286
  content = content.replace(oldStr, newStr);
57148
- writeFileSync23(targetPath, content, "utf-8");
57287
+ writeFileSync24(targetPath, content, "utf-8");
57149
57288
  return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start };
57150
57289
  } catch (err) {
57151
57290
  return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
@@ -57186,14 +57325,14 @@ var init_dream_engine = __esm({
57186
57325
  const content = String(args["content"] ?? "");
57187
57326
  if (!rawPath)
57188
57327
  return { success: false, output: "", error: "path is required", durationMs: Date.now() - start };
57189
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join65(this.dreamsDir, basename14(rawPath)) : join65(this.dreamsDir, rawPath);
57328
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join66(this.dreamsDir, basename14(rawPath)) : join66(this.dreamsDir, rawPath);
57190
57329
  if (!targetPath.startsWith(this.dreamsDir)) {
57191
57330
  return { success: false, output: "", error: "Dream mode: writes are confined to .oa/dreams/", durationMs: Date.now() - start };
57192
57331
  }
57193
57332
  try {
57194
- const dir = join65(targetPath, "..");
57195
- mkdirSync23(dir, { recursive: true });
57196
- writeFileSync23(targetPath, content, "utf-8");
57333
+ const dir = join66(targetPath, "..");
57334
+ mkdirSync24(dir, { recursive: true });
57335
+ writeFileSync24(targetPath, content, "utf-8");
57197
57336
  return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start };
57198
57337
  } catch (err) {
57199
57338
  return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
@@ -57221,20 +57360,20 @@ var init_dream_engine = __esm({
57221
57360
  const rawPath = String(args["path"] ?? "");
57222
57361
  const oldStr = String(args["old_string"] ?? "");
57223
57362
  const newStr = String(args["new_string"] ?? "");
57224
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join65(this.dreamsDir, basename14(rawPath)) : join65(this.dreamsDir, rawPath);
57363
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".oa/dreams") ? join66(this.dreamsDir, basename14(rawPath)) : join66(this.dreamsDir, rawPath);
57225
57364
  if (!targetPath.startsWith(this.dreamsDir)) {
57226
57365
  return { success: false, output: "", error: "Dream mode: edits are confined to .oa/dreams/", durationMs: Date.now() - start };
57227
57366
  }
57228
57367
  try {
57229
- if (!existsSync48(targetPath)) {
57368
+ if (!existsSync49(targetPath)) {
57230
57369
  return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start };
57231
57370
  }
57232
- let content = readFileSync37(targetPath, "utf-8");
57371
+ let content = readFileSync38(targetPath, "utf-8");
57233
57372
  if (!content.includes(oldStr)) {
57234
57373
  return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start };
57235
57374
  }
57236
57375
  content = content.replace(oldStr, newStr);
57237
- writeFileSync23(targetPath, content, "utf-8");
57376
+ writeFileSync24(targetPath, content, "utf-8");
57238
57377
  return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start };
57239
57378
  } catch (err) {
57240
57379
  return { success: false, output: "", error: String(err), durationMs: Date.now() - start };
@@ -57288,7 +57427,7 @@ var init_dream_engine = __esm({
57288
57427
  constructor(config, repoRoot) {
57289
57428
  this.config = config;
57290
57429
  this.repoRoot = repoRoot;
57291
- this.dreamsDir = join65(repoRoot, ".oa", "dreams");
57430
+ this.dreamsDir = join66(repoRoot, ".oa", "dreams");
57292
57431
  this.state = {
57293
57432
  mode: "default",
57294
57433
  active: false,
@@ -57319,7 +57458,7 @@ var init_dream_engine = __esm({
57319
57458
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
57320
57459
  results: []
57321
57460
  };
57322
- mkdirSync23(this.dreamsDir, { recursive: true });
57461
+ mkdirSync24(this.dreamsDir, { recursive: true });
57323
57462
  this.saveDreamState();
57324
57463
  try {
57325
57464
  for (let cycle = 1; cycle <= totalCycles; cycle++) {
@@ -57372,8 +57511,8 @@ ${result.summary}`;
57372
57511
  if (mode !== "default" || cycle === totalCycles) {
57373
57512
  renderDreamContraction(cycle);
57374
57513
  const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
57375
- const summaryPath = join65(this.dreamsDir, `cycle-${cycle}-summary.md`);
57376
- writeFileSync23(summaryPath, cycleSummary, "utf-8");
57514
+ const summaryPath = join66(this.dreamsDir, `cycle-${cycle}-summary.md`);
57515
+ writeFileSync24(summaryPath, cycleSummary, "utf-8");
57377
57516
  }
57378
57517
  if (mode === "lucid" && !this.abortController.signal.aborted) {
57379
57518
  this.saveVersionCheckpoint(cycle);
@@ -57585,7 +57724,7 @@ After synthesis, call task_complete with the final prioritized summary.`, toolMo
57585
57724
  }
57586
57725
  /** Build role-specific tool sets for swarm agents */
57587
57726
  buildSwarmTools(role, _workspace) {
57588
- const autoresearchDir = join65(this.repoRoot, ".oa", "autoresearch");
57727
+ const autoresearchDir = join66(this.repoRoot, ".oa", "autoresearch");
57589
57728
  const taskComplete = this.createSwarmTaskCompleteTool(role);
57590
57729
  switch (role) {
57591
57730
  case "researcher": {
@@ -57949,7 +58088,7 @@ INSTRUCTIONS:
57949
58088
  2. Summarize the key learnings and next steps
57950
58089
 
57951
58090
  Call task_complete with a human-readable summary of the autoresearch session.`, workspace, onEvent);
57952
- const reportPath = join65(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
58091
+ const reportPath = join66(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
57953
58092
  const report = `# Autoresearch Swarm Report \u2014 Cycle ${cycleNum}
57954
58093
 
57955
58094
  **Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
@@ -57971,8 +58110,8 @@ ${summaryResult}
57971
58110
  *Generated by open-agents autoresearch swarm*
57972
58111
  `;
57973
58112
  try {
57974
- mkdirSync23(this.dreamsDir, { recursive: true });
57975
- writeFileSync23(reportPath, report, "utf-8");
58113
+ mkdirSync24(this.dreamsDir, { recursive: true });
58114
+ writeFileSync24(reportPath, report, "utf-8");
57976
58115
  } catch {
57977
58116
  }
57978
58117
  renderSwarmComplete(workspace);
@@ -58038,9 +58177,9 @@ ${summaryResult}
58038
58177
  }
58039
58178
  /** Save workspace backup for lucid mode */
58040
58179
  saveVersionCheckpoint(cycle) {
58041
- const checkpointDir = join65(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
58180
+ const checkpointDir = join66(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
58042
58181
  try {
58043
- mkdirSync23(checkpointDir, { recursive: true });
58182
+ mkdirSync24(checkpointDir, { recursive: true });
58044
58183
  try {
58045
58184
  const gitStatus = execSync33("git status --porcelain", {
58046
58185
  cwd: this.repoRoot,
@@ -58057,10 +58196,10 @@ ${summaryResult}
58057
58196
  encoding: "utf-8",
58058
58197
  timeout: 5e3
58059
58198
  }).trim();
58060
- writeFileSync23(join65(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
58061
- writeFileSync23(join65(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
58062
- writeFileSync23(join65(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
58063
- writeFileSync23(join65(checkpointDir, "checkpoint.json"), JSON.stringify({
58199
+ writeFileSync24(join66(checkpointDir, "git-status.txt"), gitStatus, "utf-8");
58200
+ writeFileSync24(join66(checkpointDir, "git-diff.patch"), gitDiff, "utf-8");
58201
+ writeFileSync24(join66(checkpointDir, "git-hash.txt"), gitHash, "utf-8");
58202
+ writeFileSync24(join66(checkpointDir, "checkpoint.json"), JSON.stringify({
58064
58203
  cycle,
58065
58204
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
58066
58205
  gitHash,
@@ -58068,7 +58207,7 @@ ${summaryResult}
58068
58207
  }, null, 2), "utf-8");
58069
58208
  renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
58070
58209
  } catch {
58071
- writeFileSync23(join65(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
58210
+ writeFileSync24(join66(checkpointDir, "checkpoint.json"), JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2), "utf-8");
58072
58211
  renderInfo(`Checkpoint saved: cycle ${cycle} (no git)`);
58073
58212
  }
58074
58213
  } catch (err) {
@@ -58126,14 +58265,14 @@ ${files.map((f) => `- [\`${f}\`](./${f})`).join("\n")}
58126
58265
  ---
58127
58266
  *Auto-generated by open-agents dream engine*
58128
58267
  `;
58129
- writeFileSync23(join65(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
58268
+ writeFileSync24(join66(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
58130
58269
  } catch {
58131
58270
  }
58132
58271
  }
58133
58272
  /** Save dream state for resume/inspection */
58134
58273
  saveDreamState() {
58135
58274
  try {
58136
- writeFileSync23(join65(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
58275
+ writeFileSync24(join66(this.dreamsDir, "dream-state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
58137
58276
  } catch {
58138
58277
  }
58139
58278
  }
@@ -58507,8 +58646,8 @@ var init_bless_engine = __esm({
58507
58646
  });
58508
58647
 
58509
58648
  // packages/cli/dist/tui/dmn-engine.js
58510
- import { existsSync as existsSync49, readFileSync as readFileSync38, writeFileSync as writeFileSync24, mkdirSync as mkdirSync24, readdirSync as readdirSync17, unlinkSync as unlinkSync10 } from "node:fs";
58511
- import { join as join66, basename as basename15 } from "node:path";
58649
+ import { existsSync as existsSync50, readFileSync as readFileSync39, writeFileSync as writeFileSync25, mkdirSync as mkdirSync25, readdirSync as readdirSync17, unlinkSync as unlinkSync10 } from "node:fs";
58650
+ import { join as join67, basename as basename15 } from "node:path";
58512
58651
  function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
58513
58652
  const competenceReport = competence.length > 0 ? competence.map((c3) => {
58514
58653
  const rate = c3.attempts > 0 ? Math.round(c3.successes / c3.attempts * 100) : 0;
@@ -58628,9 +58767,9 @@ var init_dmn_engine = __esm({
58628
58767
  constructor(config, repoRoot) {
58629
58768
  this.config = config;
58630
58769
  this.repoRoot = repoRoot;
58631
- this.stateDir = join66(repoRoot, ".oa", "dmn");
58632
- this.historyDir = join66(repoRoot, ".oa", "dmn", "cycles");
58633
- mkdirSync24(this.historyDir, { recursive: true });
58770
+ this.stateDir = join67(repoRoot, ".oa", "dmn");
58771
+ this.historyDir = join67(repoRoot, ".oa", "dmn", "cycles");
58772
+ mkdirSync25(this.historyDir, { recursive: true });
58634
58773
  this.loadState();
58635
58774
  }
58636
58775
  get stats() {
@@ -59219,11 +59358,11 @@ OUTPUT: Call task_complete with JSON:
59219
59358
  async gatherMemoryTopics() {
59220
59359
  const topics = [];
59221
59360
  const dirs = [
59222
- join66(this.repoRoot, ".oa", "memory"),
59223
- join66(this.repoRoot, ".open-agents", "memory")
59361
+ join67(this.repoRoot, ".oa", "memory"),
59362
+ join67(this.repoRoot, ".open-agents", "memory")
59224
59363
  ];
59225
59364
  for (const dir of dirs) {
59226
- if (!existsSync49(dir))
59365
+ if (!existsSync50(dir))
59227
59366
  continue;
59228
59367
  try {
59229
59368
  const files = readdirSync17(dir).filter((f) => f.endsWith(".json"));
@@ -59239,29 +59378,29 @@ OUTPUT: Call task_complete with JSON:
59239
59378
  }
59240
59379
  // ── State persistence ─────────────────────────────────────────────────
59241
59380
  loadState() {
59242
- const path = join66(this.stateDir, "state.json");
59243
- if (existsSync49(path)) {
59381
+ const path = join67(this.stateDir, "state.json");
59382
+ if (existsSync50(path)) {
59244
59383
  try {
59245
- this.state = JSON.parse(readFileSync38(path, "utf-8"));
59384
+ this.state = JSON.parse(readFileSync39(path, "utf-8"));
59246
59385
  } catch {
59247
59386
  }
59248
59387
  }
59249
59388
  }
59250
59389
  saveState() {
59251
59390
  try {
59252
- writeFileSync24(join66(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
59391
+ writeFileSync25(join67(this.stateDir, "state.json"), JSON.stringify(this.state, null, 2) + "\n", "utf-8");
59253
59392
  } catch {
59254
59393
  }
59255
59394
  }
59256
59395
  saveCycleResult(result) {
59257
59396
  try {
59258
59397
  const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
59259
- writeFileSync24(join66(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
59398
+ writeFileSync25(join67(this.historyDir, filename), JSON.stringify(result, null, 2) + "\n", "utf-8");
59260
59399
  const files = readdirSync17(this.historyDir).filter((f) => f.startsWith("cycle-") && f.endsWith(".json")).sort();
59261
59400
  if (files.length > 50) {
59262
59401
  for (const old of files.slice(0, files.length - 50)) {
59263
59402
  try {
59264
- unlinkSync10(join66(this.historyDir, old));
59403
+ unlinkSync10(join67(this.historyDir, old));
59265
59404
  } catch {
59266
59405
  }
59267
59406
  }
@@ -59274,8 +59413,8 @@ OUTPUT: Call task_complete with JSON:
59274
59413
  });
59275
59414
 
59276
59415
  // packages/cli/dist/tui/snr-engine.js
59277
- import { existsSync as existsSync50, readdirSync as readdirSync18, readFileSync as readFileSync39 } from "node:fs";
59278
- import { join as join67, basename as basename16 } from "node:path";
59416
+ import { existsSync as existsSync51, readdirSync as readdirSync18, readFileSync as readFileSync40 } from "node:fs";
59417
+ import { join as join68, basename as basename16 } from "node:path";
59279
59418
  function computeDPrime(signalScores, noiseScores) {
59280
59419
  if (signalScores.length === 0 || noiseScores.length === 0)
59281
59420
  return 0;
@@ -59515,11 +59654,11 @@ Call task_complete with the JSON array when done.`, onEvent)
59515
59654
  loadMemoryEntries(topics) {
59516
59655
  const entries = [];
59517
59656
  const dirs = [
59518
- join67(this.repoRoot, ".oa", "memory"),
59519
- join67(this.repoRoot, ".open-agents", "memory")
59657
+ join68(this.repoRoot, ".oa", "memory"),
59658
+ join68(this.repoRoot, ".open-agents", "memory")
59520
59659
  ];
59521
59660
  for (const dir of dirs) {
59522
- if (!existsSync50(dir))
59661
+ if (!existsSync51(dir))
59523
59662
  continue;
59524
59663
  try {
59525
59664
  const files = readdirSync18(dir).filter((f) => f.endsWith(".json"));
@@ -59528,7 +59667,7 @@ Call task_complete with the JSON array when done.`, onEvent)
59528
59667
  if (topics.length > 0 && !topics.includes(topic))
59529
59668
  continue;
59530
59669
  try {
59531
- const data = JSON.parse(readFileSync39(join67(dir, f), "utf-8"));
59670
+ const data = JSON.parse(readFileSync40(join68(dir, f), "utf-8"));
59532
59671
  for (const [key, val] of Object.entries(data)) {
59533
59672
  const value = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
59534
59673
  entries.push({ topic, key, value });
@@ -60095,8 +60234,8 @@ var init_tool_policy = __esm({
60095
60234
  });
60096
60235
 
60097
60236
  // packages/cli/dist/tui/telegram-bridge.js
60098
- import { mkdirSync as mkdirSync25, existsSync as existsSync51, unlinkSync as unlinkSync11, readdirSync as readdirSync19, statSync as statSync16 } from "node:fs";
60099
- import { join as join68, resolve as resolve30 } from "node:path";
60237
+ import { mkdirSync as mkdirSync26, existsSync as existsSync52, unlinkSync as unlinkSync11, readdirSync as readdirSync19, statSync as statSync16 } from "node:fs";
60238
+ import { join as join69, resolve as resolve30 } from "node:path";
60100
60239
  import { writeFile as writeFileAsync } from "node:fs/promises";
60101
60240
  function convertMarkdownToTelegramHTML(md) {
60102
60241
  let html = md;
@@ -60424,7 +60563,7 @@ with summary "no_reply" to silently skip without responding.
60424
60563
  this.polling = true;
60425
60564
  this.abortController = new AbortController();
60426
60565
  try {
60427
- mkdirSync25(this.mediaCacheDir, { recursive: true });
60566
+ mkdirSync26(this.mediaCacheDir, { recursive: true });
60428
60567
  } catch {
60429
60568
  }
60430
60569
  this.mediaCacheCleanupTimer = setInterval(() => this.cleanupMediaCache(), 5 * 60 * 1e3);
@@ -60861,7 +61000,7 @@ Telegram admin: @${msg.username}` : `Telegram ${isGroup ? "group" : "public"} ch
60861
61000
  return null;
60862
61001
  const buffer = Buffer.from(await res.arrayBuffer());
60863
61002
  const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension}`;
60864
- const localPath = join68(this.mediaCacheDir, fileName);
61003
+ const localPath = join69(this.mediaCacheDir, fileName);
60865
61004
  await writeFileAsync(localPath, buffer);
60866
61005
  return localPath;
60867
61006
  } catch {
@@ -62217,7 +62356,7 @@ var init_text_selection = __esm({
62217
62356
  });
62218
62357
 
62219
62358
  // packages/cli/dist/tui/status-bar.js
62220
- import { readFileSync as readFileSync40 } from "node:fs";
62359
+ import { readFileSync as readFileSync41 } from "node:fs";
62221
62360
  function setTerminalTitle(task, version) {
62222
62361
  if (!process.stdout.isTTY)
62223
62362
  return;
@@ -62956,7 +63095,7 @@ var init_status_bar = __esm({
62956
63095
  if (nexusDir) {
62957
63096
  try {
62958
63097
  const metricsPath = nexusDir + "/remote-metrics.json";
62959
- const raw = readFileSync40(metricsPath, "utf8");
63098
+ const raw = readFileSync41(metricsPath, "utf8");
62960
63099
  const cached = JSON.parse(raw);
62961
63100
  if (cached && cached.ts && Date.now() - cached.ts < 6e4) {
62962
63101
  const m = cached.data;
@@ -65258,13 +65397,13 @@ var init_direct_input = __esm({
65258
65397
  });
65259
65398
 
65260
65399
  // packages/cli/dist/api/audit-log.js
65261
- import { mkdirSync as mkdirSync26, appendFileSync as appendFileSync4, readFileSync as readFileSync41, existsSync as existsSync52 } from "node:fs";
65262
- import { join as join69 } from "node:path";
65400
+ import { mkdirSync as mkdirSync27, appendFileSync as appendFileSync4, readFileSync as readFileSync42, existsSync as existsSync53 } from "node:fs";
65401
+ import { join as join70 } from "node:path";
65263
65402
  function initAuditLog(oaDir) {
65264
- auditDir = join69(oaDir, "audit");
65265
- auditFile = join69(auditDir, "audit.jsonl");
65403
+ auditDir = join70(oaDir, "audit");
65404
+ auditFile = join70(auditDir, "audit.jsonl");
65266
65405
  try {
65267
- mkdirSync26(auditDir, { recursive: true });
65406
+ mkdirSync27(auditDir, { recursive: true });
65268
65407
  initialized = true;
65269
65408
  } catch {
65270
65409
  }
@@ -65279,10 +65418,10 @@ function recordAudit(record) {
65279
65418
  }
65280
65419
  }
65281
65420
  function queryAudit(opts) {
65282
- if (!initialized || !existsSync52(auditFile))
65421
+ if (!initialized || !existsSync53(auditFile))
65283
65422
  return [];
65284
65423
  try {
65285
- const raw = readFileSync41(auditFile, "utf-8");
65424
+ const raw = readFileSync42(auditFile, "utf-8");
65286
65425
  const lines = raw.split("\n").filter(Boolean);
65287
65426
  let records = lines.map((l) => {
65288
65427
  try {
@@ -66536,29 +66675,29 @@ var init_auth_oidc = __esm({
66536
66675
 
66537
66676
  // packages/cli/dist/api/chat-session.js
66538
66677
  import { randomUUID as randomUUID4 } from "node:crypto";
66539
- import { existsSync as existsSync53, readFileSync as readFileSync42, readdirSync as readdirSync20 } from "node:fs";
66540
- import { join as join70 } from "node:path";
66678
+ import { existsSync as existsSync54, readFileSync as readFileSync43, readdirSync as readdirSync20 } from "node:fs";
66679
+ import { join as join71 } from "node:path";
66541
66680
  function buildSystemPrompt(cwd4) {
66542
66681
  const parts = [];
66543
66682
  parts.push("You are Open Agent (OA), an AI coding assistant running locally via Ollama. You have access to the user's workspace and can discuss code, files, and projects. Be helpful, concise, and technically precise. When asked about files or code, describe what you know from the conversation context.");
66544
66683
  parts.push(`\\nEnvironment: ${process.platform}, Node ${process.version}, CWD: ${cwd4}`);
66545
- const diaryPath = join70(cwd4, ".oa", "context", "session-diary.md");
66546
- if (existsSync53(diaryPath)) {
66684
+ const diaryPath = join71(cwd4, ".oa", "context", "session-diary.md");
66685
+ if (existsSync54(diaryPath)) {
66547
66686
  try {
66548
- const diary = readFileSync42(diaryPath, "utf-8").slice(0, 1e3);
66687
+ const diary = readFileSync43(diaryPath, "utf-8").slice(0, 1e3);
66549
66688
  parts.push(`\\nPrevious session history:\\n${diary}`);
66550
66689
  } catch {
66551
66690
  }
66552
66691
  }
66553
- const memDir = join70(cwd4, ".oa", "memory");
66554
- if (existsSync53(memDir)) {
66692
+ const memDir = join71(cwd4, ".oa", "memory");
66693
+ if (existsSync54(memDir)) {
66555
66694
  try {
66556
66695
  const files = readdirSync20(memDir).filter((f) => f.endsWith(".json")).slice(0, 5);
66557
66696
  if (files.length > 0) {
66558
66697
  parts.push("\\nPersistent memory topics: " + files.map((f) => f.replace(".json", "")).join(", "));
66559
66698
  for (const f of files.slice(0, 3)) {
66560
66699
  try {
66561
- const data = JSON.parse(readFileSync42(join70(memDir, f), "utf-8"));
66700
+ const data = JSON.parse(readFileSync43(join71(memDir, f), "utf-8"));
66562
66701
  const entries = Object.entries(data).slice(0, 3);
66563
66702
  if (entries.length > 0) {
66564
66703
  parts.push(`\\nMemory [${f.replace(".json", "")}]: ` + entries.map(([k, v]) => `${k}: ${String(v.value ?? v).slice(0, 100)}`).join("; "));
@@ -66571,10 +66710,10 @@ function buildSystemPrompt(cwd4) {
66571
66710
  }
66572
66711
  }
66573
66712
  for (const name of ["AGENTS.md", "OA.md", ".open-agents.md"]) {
66574
- const p = join70(cwd4, name);
66575
- if (existsSync53(p)) {
66713
+ const p = join71(cwd4, name);
66714
+ if (existsSync54(p)) {
66576
66715
  try {
66577
- const content = readFileSync42(p, "utf-8").slice(0, 500);
66716
+ const content = readFileSync43(p, "utf-8").slice(0, 500);
66578
66717
  parts.push(`\\nProject instructions (${name}):\\n${content}`);
66579
66718
  } catch {
66580
66719
  }
@@ -66652,15 +66791,15 @@ var init_chat_session = __esm({
66652
66791
  });
66653
66792
 
66654
66793
  // packages/cli/dist/api/usage-tracker.js
66655
- import { mkdirSync as mkdirSync27, readFileSync as readFileSync43, writeFileSync as writeFileSync25, existsSync as existsSync54 } from "node:fs";
66656
- import { join as join71 } from "node:path";
66794
+ import { mkdirSync as mkdirSync28, readFileSync as readFileSync44, writeFileSync as writeFileSync26, existsSync as existsSync55 } from "node:fs";
66795
+ import { join as join72 } from "node:path";
66657
66796
  function initUsageTracker(oaDir) {
66658
- const dir = join71(oaDir, "usage");
66659
- mkdirSync27(dir, { recursive: true });
66660
- usageFile = join71(dir, "token-usage.json");
66797
+ const dir = join72(oaDir, "usage");
66798
+ mkdirSync28(dir, { recursive: true });
66799
+ usageFile = join72(dir, "token-usage.json");
66661
66800
  try {
66662
- if (existsSync54(usageFile)) {
66663
- store = JSON.parse(readFileSync43(usageFile, "utf-8"));
66801
+ if (existsSync55(usageFile)) {
66802
+ store = JSON.parse(readFileSync44(usageFile, "utf-8"));
66664
66803
  }
66665
66804
  } catch {
66666
66805
  store = { providers: {}, lastSaved: "" };
@@ -66700,7 +66839,7 @@ function flush() {
66700
66839
  return;
66701
66840
  try {
66702
66841
  store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
66703
- writeFileSync25(usageFile, JSON.stringify(store, null, 2), "utf-8");
66842
+ writeFileSync26(usageFile, JSON.stringify(store, null, 2), "utf-8");
66704
66843
  dirty = false;
66705
66844
  } catch {
66706
66845
  }
@@ -66728,24 +66867,24 @@ var init_usage_tracker = __esm({
66728
66867
  });
66729
66868
 
66730
66869
  // packages/cli/dist/api/profiles.js
66731
- import { existsSync as existsSync55, readFileSync as readFileSync44, writeFileSync as writeFileSync26, mkdirSync as mkdirSync28, readdirSync as readdirSync21, unlinkSync as unlinkSync12 } from "node:fs";
66732
- import { join as join72 } from "node:path";
66733
- import { homedir as homedir18 } from "node:os";
66870
+ import { existsSync as existsSync56, readFileSync as readFileSync45, writeFileSync as writeFileSync27, mkdirSync as mkdirSync29, readdirSync as readdirSync21, unlinkSync as unlinkSync12 } from "node:fs";
66871
+ import { join as join73 } from "node:path";
66872
+ import { homedir as homedir19 } from "node:os";
66734
66873
  import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes15, scryptSync as scryptSync3, createHash as createHash5 } from "node:crypto";
66735
66874
  function globalProfileDir() {
66736
- return join72(homedir18(), ".open-agents", "profiles");
66875
+ return join73(homedir19(), ".open-agents", "profiles");
66737
66876
  }
66738
66877
  function projectProfileDir(projectDir) {
66739
- return join72(projectDir || process.cwd(), ".oa", "profiles");
66878
+ return join73(projectDir || process.cwd(), ".oa", "profiles");
66740
66879
  }
66741
66880
  function listProfiles(projectDir) {
66742
66881
  const result = [];
66743
66882
  const seen = /* @__PURE__ */ new Set();
66744
66883
  const projDir = projectProfileDir(projectDir);
66745
- if (existsSync55(projDir)) {
66884
+ if (existsSync56(projDir)) {
66746
66885
  for (const f of readdirSync21(projDir).filter((f2) => f2.endsWith(".json"))) {
66747
66886
  try {
66748
- const raw = JSON.parse(readFileSync44(join72(projDir, f), "utf8"));
66887
+ const raw = JSON.parse(readFileSync45(join73(projDir, f), "utf8"));
66749
66888
  const name = f.replace(".json", "");
66750
66889
  seen.add(name);
66751
66890
  result.push({
@@ -66759,13 +66898,13 @@ function listProfiles(projectDir) {
66759
66898
  }
66760
66899
  }
66761
66900
  const globDir = globalProfileDir();
66762
- if (existsSync55(globDir)) {
66901
+ if (existsSync56(globDir)) {
66763
66902
  for (const f of readdirSync21(globDir).filter((f2) => f2.endsWith(".json"))) {
66764
66903
  const name = f.replace(".json", "");
66765
66904
  if (seen.has(name))
66766
66905
  continue;
66767
66906
  try {
66768
- const raw = JSON.parse(readFileSync44(join72(globDir, f), "utf8"));
66907
+ const raw = JSON.parse(readFileSync45(join73(globDir, f), "utf8"));
66769
66908
  result.push({
66770
66909
  name,
66771
66910
  description: raw.description || "",
@@ -66780,12 +66919,12 @@ function listProfiles(projectDir) {
66780
66919
  }
66781
66920
  function loadProfile(name, password, projectDir) {
66782
66921
  const sanitized = name.replace(/[^a-zA-Z0-9_-]/g, "");
66783
- const projPath = join72(projectProfileDir(projectDir), `${sanitized}.json`);
66784
- const globPath = join72(globalProfileDir(), `${sanitized}.json`);
66785
- const filePath = existsSync55(projPath) ? projPath : existsSync55(globPath) ? globPath : null;
66922
+ const projPath = join73(projectProfileDir(projectDir), `${sanitized}.json`);
66923
+ const globPath = join73(globalProfileDir(), `${sanitized}.json`);
66924
+ const filePath = existsSync56(projPath) ? projPath : existsSync56(globPath) ? globPath : null;
66786
66925
  if (!filePath)
66787
66926
  return null;
66788
- const raw = JSON.parse(readFileSync44(filePath, "utf8"));
66927
+ const raw = JSON.parse(readFileSync45(filePath, "utf8"));
66789
66928
  if (raw.encrypted === true) {
66790
66929
  if (!password)
66791
66930
  return null;
@@ -66795,23 +66934,23 @@ function loadProfile(name, password, projectDir) {
66795
66934
  }
66796
66935
  function saveProfile(profile, password, scope = "global", projectDir) {
66797
66936
  const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
66798
- mkdirSync28(dir, { recursive: true });
66937
+ mkdirSync29(dir, { recursive: true });
66799
66938
  const sanitized = profile.name.replace(/[^a-zA-Z0-9_-]/g, "");
66800
- const filePath = join72(dir, `${sanitized}.json`);
66939
+ const filePath = join73(dir, `${sanitized}.json`);
66801
66940
  profile.modified = (/* @__PURE__ */ new Date()).toISOString();
66802
66941
  if (password) {
66803
66942
  const encrypted = encryptProfile(profile, password);
66804
- writeFileSync26(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
66943
+ writeFileSync27(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
66805
66944
  } else {
66806
66945
  profile.encrypted = false;
66807
- writeFileSync26(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
66946
+ writeFileSync27(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
66808
66947
  }
66809
66948
  }
66810
66949
  function deleteProfile(name, scope = "global", projectDir) {
66811
66950
  const sanitized = name.replace(/[^a-zA-Z0-9_-]/g, "");
66812
66951
  const dir = scope === "project" ? projectProfileDir(projectDir) : globalProfileDir();
66813
- const filePath = join72(dir, `${sanitized}.json`);
66814
- if (existsSync55(filePath)) {
66952
+ const filePath = join73(dir, `${sanitized}.json`);
66953
+ if (existsSync56(filePath)) {
66815
66954
  unlinkSync12(filePath);
66816
66955
  return true;
66817
66956
  }
@@ -66904,22 +67043,22 @@ import * as http from "node:http";
66904
67043
  import * as https from "node:https";
66905
67044
  import { createRequire as createRequire3 } from "node:module";
66906
67045
  import { fileURLToPath as fileURLToPath13 } from "node:url";
66907
- import { dirname as dirname21, join as join73, resolve as resolve31 } from "node:path";
67046
+ import { dirname as dirname21, join as join74, resolve as resolve31 } from "node:path";
66908
67047
  import { spawn as spawn21 } from "node:child_process";
66909
- import { mkdirSync as mkdirSync29, writeFileSync as writeFileSync27, readFileSync as readFileSync45, readdirSync as readdirSync22, existsSync as existsSync56 } from "node:fs";
67048
+ import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync28, readFileSync as readFileSync46, readdirSync as readdirSync22, existsSync as existsSync57 } from "node:fs";
66910
67049
  import { randomBytes as randomBytes16, randomUUID as randomUUID5 } from "node:crypto";
66911
67050
  function getVersion3() {
66912
67051
  try {
66913
67052
  const require2 = createRequire3(import.meta.url);
66914
67053
  const thisDir = dirname21(fileURLToPath13(import.meta.url));
66915
67054
  const candidates = [
66916
- join73(thisDir, "..", "package.json"),
66917
- join73(thisDir, "..", "..", "package.json"),
66918
- join73(thisDir, "..", "..", "..", "package.json")
67055
+ join74(thisDir, "..", "package.json"),
67056
+ join74(thisDir, "..", "..", "package.json"),
67057
+ join74(thisDir, "..", "..", "..", "package.json")
66919
67058
  ];
66920
67059
  for (const pkgPath of candidates) {
66921
67060
  try {
66922
- if (!existsSync56(pkgPath))
67061
+ if (!existsSync57(pkgPath))
66923
67062
  continue;
66924
67063
  const pkg = require2(pkgPath);
66925
67064
  if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
@@ -67220,29 +67359,29 @@ function ollamaStream(ollamaUrl, path, method, body, onData, onEnd, onError) {
67220
67359
  }
67221
67360
  function jobsDir() {
67222
67361
  const root = resolve31(process.cwd());
67223
- const dir = join73(root, ".oa", "jobs");
67224
- mkdirSync29(dir, { recursive: true });
67362
+ const dir = join74(root, ".oa", "jobs");
67363
+ mkdirSync30(dir, { recursive: true });
67225
67364
  return dir;
67226
67365
  }
67227
67366
  function loadJob(id) {
67228
- const file = join73(jobsDir(), `${id}.json`);
67229
- if (!existsSync56(file))
67367
+ const file = join74(jobsDir(), `${id}.json`);
67368
+ if (!existsSync57(file))
67230
67369
  return null;
67231
67370
  try {
67232
- return JSON.parse(readFileSync45(file, "utf-8"));
67371
+ return JSON.parse(readFileSync46(file, "utf-8"));
67233
67372
  } catch {
67234
67373
  return null;
67235
67374
  }
67236
67375
  }
67237
67376
  function listJobs() {
67238
67377
  const dir = jobsDir();
67239
- if (!existsSync56(dir))
67378
+ if (!existsSync57(dir))
67240
67379
  return [];
67241
67380
  const files = readdirSync22(dir).filter((f) => f.endsWith(".json")).sort();
67242
67381
  const jobs = [];
67243
67382
  for (const file of files) {
67244
67383
  try {
67245
- jobs.push(JSON.parse(readFileSync45(join73(dir, file), "utf-8")));
67384
+ jobs.push(JSON.parse(readFileSync46(join74(dir, file), "utf-8")));
67246
67385
  } catch {
67247
67386
  }
67248
67387
  }
@@ -67690,8 +67829,8 @@ async function handleV1Run(req, res) {
67690
67829
  if (workingDir) {
67691
67830
  cwd4 = resolve31(workingDir);
67692
67831
  } else if (isolate) {
67693
- const wsDir = join73(dir, "..", "workspaces", id);
67694
- mkdirSync29(wsDir, { recursive: true });
67832
+ const wsDir = join74(dir, "..", "workspaces", id);
67833
+ mkdirSync30(wsDir, { recursive: true });
67695
67834
  cwd4 = wsDir;
67696
67835
  } else {
67697
67836
  cwd4 = resolve31(process.cwd());
@@ -67763,7 +67902,7 @@ async function handleV1Run(req, res) {
67763
67902
  });
67764
67903
  child.unref();
67765
67904
  job.pid = child.pid ?? 0;
67766
- writeFileSync27(join73(dir, `${id}.json`), JSON.stringify(job, null, 2));
67905
+ writeFileSync28(join74(dir, `${id}.json`), JSON.stringify(job, null, 2));
67767
67906
  runningProcesses.set(id, child);
67768
67907
  if (streamMode) {
67769
67908
  res.writeHead(200, {
@@ -67790,7 +67929,7 @@ async function handleV1Run(req, res) {
67790
67929
  job.status = code === 0 ? "completed" : "failed";
67791
67930
  job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
67792
67931
  try {
67793
- writeFileSync27(join73(dir, `${id}.json`), JSON.stringify(job, null, 2));
67932
+ writeFileSync28(join74(dir, `${id}.json`), JSON.stringify(job, null, 2));
67794
67933
  } catch {
67795
67934
  }
67796
67935
  runningProcesses.delete(id);
@@ -67821,7 +67960,7 @@ async function handleV1Run(req, res) {
67821
67960
  job.completedAt = (/* @__PURE__ */ new Date()).toISOString();
67822
67961
  }
67823
67962
  try {
67824
- writeFileSync27(join73(dir, `${id}.json`), JSON.stringify(job, null, 2));
67963
+ writeFileSync28(join74(dir, `${id}.json`), JSON.stringify(job, null, 2));
67825
67964
  } catch {
67826
67965
  }
67827
67966
  runningProcesses.delete(id);
@@ -67870,7 +68009,7 @@ function handleV1RunsDelete(res, id) {
67870
68009
  job.error = "Aborted via API";
67871
68010
  const dir = jobsDir();
67872
68011
  try {
67873
- writeFileSync27(join73(dir, `${id}.json`), JSON.stringify(job, null, 2));
68012
+ writeFileSync28(join74(dir, `${id}.json`), JSON.stringify(job, null, 2));
67874
68013
  } catch {
67875
68014
  }
67876
68015
  runningProcesses.delete(id);
@@ -68507,20 +68646,20 @@ function startApiServer(options = {}) {
68507
68646
  const config = loadConfig();
68508
68647
  const ollamaUrl = options.ollamaUrl ?? config.backendUrl;
68509
68648
  const cwd4 = process.cwd();
68510
- initAuditLog(join73(cwd4, ".oa"));
68511
- initUsageTracker(join73(cwd4, ".oa"));
68649
+ initAuditLog(join74(cwd4, ".oa"));
68650
+ initUsageTracker(join74(cwd4, ".oa"));
68512
68651
  const retentionDays = parseInt(process.env["OA_JOB_RETENTION_DAYS"] ?? "30", 10);
68513
68652
  if (retentionDays > 0) {
68514
68653
  try {
68515
- const jobsDir3 = join73(cwd4, ".oa", "jobs");
68516
- if (existsSync56(jobsDir3)) {
68654
+ const jobsDir3 = join74(cwd4, ".oa", "jobs");
68655
+ if (existsSync57(jobsDir3)) {
68517
68656
  const cutoff = Date.now() - retentionDays * 864e5;
68518
68657
  for (const f of readdirSync22(jobsDir3)) {
68519
68658
  if (!f.endsWith(".json"))
68520
68659
  continue;
68521
68660
  try {
68522
- const jobPath = join73(jobsDir3, f);
68523
- const job = JSON.parse(readFileSync45(jobPath, "utf-8"));
68661
+ const jobPath = join74(jobsDir3, f);
68662
+ const job = JSON.parse(readFileSync46(jobPath, "utf-8"));
68524
68663
  const jobTime = new Date(job.startedAt ?? job.completedAt ?? 0).getTime();
68525
68664
  if (jobTime > 0 && jobTime < cutoff && job.status !== "running") {
68526
68665
  const { unlinkSync: unlinkSync13 } = __require("node:fs");
@@ -68540,8 +68679,8 @@ function startApiServer(options = {}) {
68540
68679
  if (useTls) {
68541
68680
  try {
68542
68681
  tlsOpts = {
68543
- cert: readFileSync45(resolve31(tlsCert)),
68544
- key: readFileSync45(resolve31(tlsKey))
68682
+ cert: readFileSync46(resolve31(tlsCert)),
68683
+ key: readFileSync46(resolve31(tlsKey))
68545
68684
  };
68546
68685
  } catch (e) {
68547
68686
  log2(`
@@ -68715,13 +68854,13 @@ var init_serve = __esm({
68715
68854
 
68716
68855
  // packages/cli/dist/tui/interactive.js
68717
68856
  import { cwd } from "node:process";
68718
- import { resolve as resolve32, join as join74, dirname as dirname22, extname as extname11 } from "node:path";
68857
+ import { resolve as resolve32, join as join75, dirname as dirname22, extname as extname11 } from "node:path";
68719
68858
  import { createRequire as createRequire4 } from "node:module";
68720
68859
  import { fileURLToPath as fileURLToPath14 } from "node:url";
68721
- import { readFileSync as readFileSync46, writeFileSync as writeFileSync28, appendFileSync as appendFileSync5, rmSync as rmSync3, readdirSync as readdirSync23, mkdirSync as mkdirSync30 } from "node:fs";
68722
- import { existsSync as existsSync57 } from "node:fs";
68860
+ import { readFileSync as readFileSync47, writeFileSync as writeFileSync29, appendFileSync as appendFileSync5, rmSync as rmSync3, readdirSync as readdirSync23, mkdirSync as mkdirSync31 } from "node:fs";
68861
+ import { existsSync as existsSync58 } from "node:fs";
68723
68862
  import { execSync as execSync35 } from "node:child_process";
68724
- import { homedir as homedir19 } from "node:os";
68863
+ import { homedir as homedir20 } from "node:os";
68725
68864
  function formatTimeAgo(date) {
68726
68865
  const seconds = Math.floor((Date.now() - date.getTime()) / 1e3);
68727
68866
  if (seconds < 60)
@@ -68740,12 +68879,12 @@ function getVersion4() {
68740
68879
  const require2 = createRequire4(import.meta.url);
68741
68880
  const thisDir = dirname22(fileURLToPath14(import.meta.url));
68742
68881
  const candidates = [
68743
- join74(thisDir, "..", "package.json"),
68744
- join74(thisDir, "..", "..", "package.json"),
68745
- join74(thisDir, "..", "..", "..", "package.json")
68882
+ join75(thisDir, "..", "package.json"),
68883
+ join75(thisDir, "..", "..", "package.json"),
68884
+ join75(thisDir, "..", "..", "..", "package.json")
68746
68885
  ];
68747
68886
  for (const pkgPath of candidates) {
68748
- if (existsSync57(pkgPath)) {
68887
+ if (existsSync58(pkgPath)) {
68749
68888
  const pkg = require2(pkgPath);
68750
68889
  if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
68751
68890
  return pkg.version ?? "0.0.0";
@@ -68984,15 +69123,15 @@ Use task_status("${taskId}") or task_output("${taskId}") to check progress.`
68984
69123
  function gatherMemorySnippets(root) {
68985
69124
  const snippets = [];
68986
69125
  const dirs = [
68987
- join74(root, ".oa", "memory"),
68988
- join74(root, ".open-agents", "memory")
69126
+ join75(root, ".oa", "memory"),
69127
+ join75(root, ".open-agents", "memory")
68989
69128
  ];
68990
69129
  for (const dir of dirs) {
68991
- if (!existsSync57(dir))
69130
+ if (!existsSync58(dir))
68992
69131
  continue;
68993
69132
  try {
68994
69133
  for (const f of readdirSync23(dir).filter((f2) => f2.endsWith(".json"))) {
68995
- const data = JSON.parse(readFileSync46(join74(dir, f), "utf-8"));
69134
+ const data = JSON.parse(readFileSync47(join75(dir, f), "utf-8"));
68996
69135
  for (const val of Object.values(data)) {
68997
69136
  const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
68998
69137
  if (v.length > 10)
@@ -69149,9 +69288,9 @@ ${metabolismMemories}
69149
69288
  } catch {
69150
69289
  }
69151
69290
  try {
69152
- const archeFile = join74(repoRoot, ".oa", "arche", "variants.json");
69153
- if (existsSync57(archeFile)) {
69154
- const variants = JSON.parse(readFileSync46(archeFile, "utf8"));
69291
+ const archeFile = join75(repoRoot, ".oa", "arche", "variants.json");
69292
+ if (existsSync58(archeFile)) {
69293
+ const variants = JSON.parse(readFileSync47(archeFile, "utf8"));
69155
69294
  if (variants.length > 0) {
69156
69295
  let filtered = variants;
69157
69296
  if (taskType) {
@@ -69320,9 +69459,9 @@ RULES:
69320
69459
  const compactionThreshold = modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4;
69321
69460
  let identityInjection = "";
69322
69461
  try {
69323
- const ikStateFile = join74(repoRoot, ".oa", "identity", "self-state.json");
69324
- if (existsSync57(ikStateFile)) {
69325
- const selfState = JSON.parse(readFileSync46(ikStateFile, "utf8"));
69462
+ const ikStateFile = join75(repoRoot, ".oa", "identity", "self-state.json");
69463
+ if (existsSync58(ikStateFile)) {
69464
+ const selfState = JSON.parse(readFileSync47(ikStateFile, "utf8"));
69326
69465
  const lines = [
69327
69466
  `[Identity State v${selfState.version}]`,
69328
69467
  `Self: ${selfState.narrative_summary}`,
@@ -69973,13 +70112,13 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
69973
70112
  });
69974
70113
  }
69975
70114
  try {
69976
- const ikDir = join74(repoRoot, ".oa", "identity");
69977
- const ikFile = join74(ikDir, "self-state.json");
70115
+ const ikDir = join75(repoRoot, ".oa", "identity");
70116
+ const ikFile = join75(ikDir, "self-state.json");
69978
70117
  let ikState;
69979
- if (existsSync57(ikFile)) {
69980
- ikState = JSON.parse(readFileSync46(ikFile, "utf8"));
70118
+ if (existsSync58(ikFile)) {
70119
+ ikState = JSON.parse(readFileSync47(ikFile, "utf8"));
69981
70120
  } else {
69982
- mkdirSync30(ikDir, { recursive: true });
70121
+ mkdirSync31(ikDir, { recursive: true });
69983
70122
  const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
69984
70123
  ikState = {
69985
70124
  self_id: `oa-${machineId}`,
@@ -70005,7 +70144,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
70005
70144
  }
70006
70145
  ikState.session_count = (ikState.session_count || 0) + 1;
70007
70146
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
70008
- writeFileSync28(ikFile, JSON.stringify(ikState, null, 2));
70147
+ writeFileSync29(ikFile, JSON.stringify(ikState, null, 2));
70009
70148
  } catch (ikErr) {
70010
70149
  try {
70011
70150
  console.error("[IK-OBSERVE]", ikErr);
@@ -70020,14 +70159,14 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
70020
70159
  } else {
70021
70160
  renderTaskIncomplete(result.turns, result.toolCalls, result.durationMs, tokens);
70022
70161
  try {
70023
- const ikFile = join74(repoRoot, ".oa", "identity", "self-state.json");
70024
- if (existsSync57(ikFile)) {
70025
- const ikState = JSON.parse(readFileSync46(ikFile, "utf8"));
70162
+ const ikFile = join75(repoRoot, ".oa", "identity", "self-state.json");
70163
+ if (existsSync58(ikFile)) {
70164
+ const ikState = JSON.parse(readFileSync47(ikFile, "utf8"));
70026
70165
  ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
70027
70166
  ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
70028
70167
  ikState.session_count = (ikState.session_count || 0) + 1;
70029
70168
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
70030
- writeFileSync28(ikFile, JSON.stringify(ikState, null, 2));
70169
+ writeFileSync29(ikFile, JSON.stringify(ikState, null, 2));
70031
70170
  }
70032
70171
  } catch {
70033
70172
  }
@@ -70124,10 +70263,10 @@ async function startInteractive(config, repoPath) {
70124
70263
  process.stdin.pause();
70125
70264
  }
70126
70265
  try {
70127
- const oaDir = join74(repoRoot, ".oa");
70128
- const nexusPidFile = join74(oaDir, "nexus", "daemon.pid");
70129
- if (existsSync57(nexusPidFile)) {
70130
- const pid = parseInt(readFileSync46(nexusPidFile, "utf8").trim(), 10);
70266
+ const oaDir = join75(repoRoot, ".oa");
70267
+ const nexusPidFile = join75(oaDir, "nexus", "daemon.pid");
70268
+ if (existsSync58(nexusPidFile)) {
70269
+ const pid = parseInt(readFileSync47(nexusPidFile, "utf8").trim(), 10);
70131
70270
  if (pid > 0) {
70132
70271
  try {
70133
70272
  process.kill(pid, 0);
@@ -70464,7 +70603,7 @@ Review its full output in the [${id}] tab or via full_sub_agent(action='output',
70464
70603
  let p2pGateway = null;
70465
70604
  let peerMesh = null;
70466
70605
  let inferenceRouter = null;
70467
- const secretVault = new SecretVault(join74(repoRoot, ".oa", "vault.enc"));
70606
+ const secretVault = new SecretVault(join75(repoRoot, ".oa", "vault.enc"));
70468
70607
  let adminSessionKey = null;
70469
70608
  const callSubAgents = /* @__PURE__ */ new Map();
70470
70609
  const streamRenderer = new StreamRenderer();
@@ -70687,13 +70826,13 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
70687
70826
  const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
70688
70827
  return [hits, line];
70689
70828
  }
70690
- const HISTORY_DIR = join74(homedir19(), ".open-agents");
70691
- const HISTORY_FILE = join74(HISTORY_DIR, "repl-history");
70829
+ const HISTORY_DIR = join75(homedir20(), ".open-agents");
70830
+ const HISTORY_FILE = join75(HISTORY_DIR, "repl-history");
70692
70831
  const MAX_HISTORY_LINES = 500;
70693
70832
  let savedHistory = [];
70694
70833
  try {
70695
- if (existsSync57(HISTORY_FILE)) {
70696
- const raw = readFileSync46(HISTORY_FILE, "utf8").trim();
70834
+ if (existsSync58(HISTORY_FILE)) {
70835
+ const raw = readFileSync47(HISTORY_FILE, "utf8").trim();
70697
70836
  if (raw)
70698
70837
  savedHistory = raw.split("\n").reverse();
70699
70838
  }
@@ -70796,12 +70935,12 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
70796
70935
  if (!line.trim())
70797
70936
  return;
70798
70937
  try {
70799
- mkdirSync30(HISTORY_DIR, { recursive: true });
70938
+ mkdirSync31(HISTORY_DIR, { recursive: true });
70800
70939
  appendFileSync5(HISTORY_FILE, line + "\n", "utf8");
70801
70940
  if (Math.random() < 0.02) {
70802
- const all = readFileSync46(HISTORY_FILE, "utf8").trim().split("\n");
70941
+ const all = readFileSync47(HISTORY_FILE, "utf8").trim().split("\n");
70803
70942
  if (all.length > MAX_HISTORY_LINES) {
70804
- writeFileSync28(HISTORY_FILE, all.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
70943
+ writeFileSync29(HISTORY_FILE, all.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
70805
70944
  }
70806
70945
  }
70807
70946
  } catch {
@@ -70985,7 +71124,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
70985
71124
  } catch {
70986
71125
  }
70987
71126
  try {
70988
- const oaDir = join74(repoRoot, ".oa");
71127
+ const oaDir = join75(repoRoot, ".oa");
70989
71128
  const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
70990
71129
  onInfo: (msg) => writeContent(() => renderInfo(msg)),
70991
71130
  onError: (msg) => writeContent(() => renderWarning(msg))
@@ -71017,7 +71156,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
71017
71156
  } catch {
71018
71157
  }
71019
71158
  try {
71020
- const oaDir = join74(repoRoot, ".oa");
71159
+ const oaDir = join75(repoRoot, ".oa");
71021
71160
  const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
71022
71161
  onInfo: (msg) => writeContent(() => renderInfo(msg)),
71023
71162
  onError: (msg) => writeContent(() => renderWarning(msg))
@@ -71058,11 +71197,11 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
71058
71197
  }
71059
71198
  try {
71060
71199
  const { homedir: _hd, hostname: _hn, userInfo: _ui } = await import("node:os");
71061
- const globalNamePath = join74(_hd(), ".open-agents", "agent-name");
71200
+ const globalNamePath = join75(_hd(), ".open-agents", "agent-name");
71062
71201
  let agName = "";
71063
71202
  try {
71064
- if (existsSync57(globalNamePath))
71065
- agName = readFileSync46(globalNamePath, "utf8").trim();
71203
+ if (existsSync58(globalNamePath))
71204
+ agName = readFileSync47(globalNamePath, "utf8").trim();
71066
71205
  } catch {
71067
71206
  }
71068
71207
  if (!agName) {
@@ -72038,7 +72177,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72038
72177
  kind,
72039
72178
  targetUrl,
72040
72179
  authKey,
72041
- stateDir: join74(repoRoot, ".oa"),
72180
+ stateDir: join75(repoRoot, ".oa"),
72042
72181
  passthrough: passthrough ?? false,
72043
72182
  loadbalance: loadbalance ?? false,
72044
72183
  endpointAuth: passthrough ? currentConfig.apiKey : void 0,
@@ -72084,7 +72223,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72084
72223
  await tunnelGateway.stop();
72085
72224
  tunnelGateway = null;
72086
72225
  }
72087
- const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join74(repoRoot, ".oa") });
72226
+ const newTunnel = new ExposeGateway({ kind, targetUrl, authKey, fullAccess, stateDir: join75(repoRoot, ".oa") });
72088
72227
  newTunnel.on("stats", (stats) => {
72089
72228
  statusBar.setExposeStatus({
72090
72229
  status: stats.status,
@@ -72173,9 +72312,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72173
72312
  if (!result.success)
72174
72313
  throw new Error(result.error || "Connect failed");
72175
72314
  try {
72176
- const nexusPidFile = join74(repoRoot, ".oa", "nexus", "daemon.pid");
72177
- if (existsSync57(nexusPidFile)) {
72178
- const pid = parseInt(readFileSync46(nexusPidFile, "utf8").trim(), 10);
72315
+ const nexusPidFile = join75(repoRoot, ".oa", "nexus", "daemon.pid");
72316
+ if (existsSync58(nexusPidFile)) {
72317
+ const pid = parseInt(readFileSync47(nexusPidFile, "utf8").trim(), 10);
72179
72318
  if (pid > 0) {
72180
72319
  registry.register({
72181
72320
  name: "Nexus",
@@ -72371,10 +72510,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72371
72510
  writeContent(() => renderInfo(`Killed ${bgKilled} background task(s).`));
72372
72511
  }
72373
72512
  try {
72374
- const nexusDir = join74(repoRoot, OA_DIR, "nexus");
72375
- const pidFile = join74(nexusDir, "daemon.pid");
72376
- if (existsSync57(pidFile)) {
72377
- const pid = parseInt(readFileSync46(pidFile, "utf8").trim(), 10);
72513
+ const nexusDir = join75(repoRoot, OA_DIR, "nexus");
72514
+ const pidFile = join75(nexusDir, "daemon.pid");
72515
+ if (existsSync58(pidFile)) {
72516
+ const pid = parseInt(readFileSync47(pidFile, "utf8").trim(), 10);
72378
72517
  if (pid > 0) {
72379
72518
  try {
72380
72519
  if (process.platform === "win32") {
@@ -72396,13 +72535,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72396
72535
  } catch {
72397
72536
  }
72398
72537
  try {
72399
- const voiceDir2 = join74(homedir19(), ".open-agents", "voice");
72538
+ const voiceDir2 = join75(homedir20(), ".open-agents", "voice");
72400
72539
  const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
72401
72540
  for (const pf of voicePidFiles) {
72402
- const pidPath = join74(voiceDir2, pf);
72403
- if (existsSync57(pidPath)) {
72541
+ const pidPath = join75(voiceDir2, pf);
72542
+ if (existsSync58(pidPath)) {
72404
72543
  try {
72405
- const pid = parseInt(readFileSync46(pidPath, "utf8").trim(), 10);
72544
+ const pid = parseInt(readFileSync47(pidPath, "utf8").trim(), 10);
72406
72545
  if (pid > 0) {
72407
72546
  if (process.platform === "win32") {
72408
72547
  try {
@@ -72426,8 +72565,8 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72426
72565
  execSync35(process.platform === "win32" ? "timeout /t 1 /nobreak >nul" : "sleep 0.5", { timeout: 3e3, stdio: "ignore" });
72427
72566
  } catch {
72428
72567
  }
72429
- const oaPath = join74(repoRoot, OA_DIR);
72430
- if (existsSync57(oaPath)) {
72568
+ const oaPath = join75(repoRoot, OA_DIR);
72569
+ if (existsSync58(oaPath)) {
72431
72570
  let deleted = false;
72432
72571
  for (let attempt = 0; attempt < 3; attempt++) {
72433
72572
  try {
@@ -72510,19 +72649,19 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
72510
72649
  try {
72511
72650
  const { isPersonaPlexRunning: isPersonaPlexRunning2 } = await Promise.resolve().then(() => (init_personaplex(), personaplex_exports));
72512
72651
  if (isPersonaPlexRunning2()) {
72513
- const ppPidFile = join74(homedir19(), ".open-agents", "voice", "personaplex", "daemon.pid");
72514
- const ppPortFile = join74(homedir19(), ".open-agents", "voice", "personaplex", "daemon.port");
72515
- if (existsSync57(ppPidFile)) {
72516
- const ppPid = parseInt(readFileSync46(ppPidFile, "utf8").trim(), 10);
72517
- const ppPort = existsSync57(ppPortFile) ? parseInt(readFileSync46(ppPortFile, "utf8").trim(), 10) : void 0;
72652
+ const ppPidFile = join75(homedir20(), ".open-agents", "voice", "personaplex", "daemon.pid");
72653
+ const ppPortFile = join75(homedir20(), ".open-agents", "voice", "personaplex", "daemon.port");
72654
+ if (existsSync58(ppPidFile)) {
72655
+ const ppPid = parseInt(readFileSync47(ppPidFile, "utf8").trim(), 10);
72656
+ const ppPort = existsSync58(ppPortFile) ? parseInt(readFileSync47(ppPortFile, "utf8").trim(), 10) : void 0;
72518
72657
  if (ppPid > 0 && !registry.daemons.has("PersonaPlex")) {
72519
72658
  registry.register({ name: "PersonaPlex", pid: ppPid, port: ppPort, startedAt: Date.now(), status: "running" });
72520
72659
  }
72521
72660
  }
72522
72661
  }
72523
- const nexusPidFile = join74(repoRoot, ".oa", "nexus", "daemon.pid");
72524
- if (existsSync57(nexusPidFile)) {
72525
- const nPid = parseInt(readFileSync46(nexusPidFile, "utf8").trim(), 10);
72662
+ const nexusPidFile = join75(repoRoot, ".oa", "nexus", "daemon.pid");
72663
+ if (existsSync58(nexusPidFile)) {
72664
+ const nPid = parseInt(readFileSync47(nexusPidFile, "utf8").trim(), 10);
72526
72665
  if (nPid > 0 && !registry.daemons.has("Nexus")) {
72527
72666
  try {
72528
72667
  process.kill(nPid, 0);
@@ -72864,8 +73003,8 @@ Execute this skill now. Follow the behavioral guidance above.`;
72864
73003
  }
72865
73004
  }
72866
73005
  const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
72867
- const isImage = isImagePath(cleanPath) && existsSync57(resolve32(repoRoot, cleanPath));
72868
- const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync57(resolve32(repoRoot, cleanPath));
73006
+ const isImage = isImagePath(cleanPath) && existsSync58(resolve32(repoRoot, cleanPath));
73007
+ const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync58(resolve32(repoRoot, cleanPath));
72869
73008
  if (activeTask) {
72870
73009
  if (activeTask.runner.isPaused) {
72871
73010
  activeTask.runner.resume();
@@ -72874,7 +73013,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
72874
73013
  if (isImage) {
72875
73014
  try {
72876
73015
  const imgPath = resolve32(repoRoot, cleanPath);
72877
- const imgBuffer = readFileSync46(imgPath);
73016
+ const imgBuffer = readFileSync47(imgPath);
72878
73017
  const base64 = imgBuffer.toString("base64");
72879
73018
  const ext = extname11(cleanPath).toLowerCase();
72880
73019
  const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
@@ -73089,7 +73228,7 @@ Summarize or analyze this transcription as appropriate.`;
73089
73228
 
73090
73229
  NEW TASK: ${fullInput}`;
73091
73230
  restoredSessionContext = null;
73092
- } else if (existsSync57(join74(repoRoot, ".oa", "context", "session-diary.md"))) {
73231
+ } else if (existsSync58(join75(repoRoot, ".oa", "context", "session-diary.md"))) {
73093
73232
  taskInput = `[Previous sessions exist \u2014 file_read(".oa/context/session-diary.md") to recall]
73094
73233
 
73095
73234
  ${fullInput}`;
@@ -73407,13 +73546,13 @@ async function runWithTUI(task, config, repoPath, callbacks) {
73407
73546
  const handle = startTask(task, config, repoRoot);
73408
73547
  await handle.promise;
73409
73548
  try {
73410
- const ikDir = join74(repoRoot, ".oa", "identity");
73411
- const ikFile = join74(ikDir, "self-state.json");
73549
+ const ikDir = join75(repoRoot, ".oa", "identity");
73550
+ const ikFile = join75(ikDir, "self-state.json");
73412
73551
  let ikState;
73413
- if (existsSync57(ikFile)) {
73414
- ikState = JSON.parse(readFileSync46(ikFile, "utf8"));
73552
+ if (existsSync58(ikFile)) {
73553
+ ikState = JSON.parse(readFileSync47(ikFile, "utf8"));
73415
73554
  } else {
73416
- mkdirSync30(ikDir, { recursive: true });
73555
+ mkdirSync31(ikDir, { recursive: true });
73417
73556
  ikState = {
73418
73557
  self_id: `oa-${Date.now().toString(36)}`,
73419
73558
  version: 1,
@@ -73435,7 +73574,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
73435
73574
  ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
73436
73575
  ikState.session_count = (ikState.session_count || 0) + 1;
73437
73576
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
73438
- writeFileSync28(ikFile, JSON.stringify(ikState, null, 2));
73577
+ writeFileSync29(ikFile, JSON.stringify(ikState, null, 2));
73439
73578
  } catch (ikErr) {
73440
73579
  }
73441
73580
  try {
@@ -73444,12 +73583,12 @@ async function runWithTUI(task, config, repoPath, callbacks) {
73444
73583
  ec.archiveVariantSync(`Task: ${task.slice(0, 200)}`, "success \u2014 completed", ["general"]);
73445
73584
  } catch {
73446
73585
  try {
73447
- const archeDir = join74(repoRoot, ".oa", "arche");
73448
- const archeFile = join74(archeDir, "variants.json");
73586
+ const archeDir = join75(repoRoot, ".oa", "arche");
73587
+ const archeFile = join75(archeDir, "variants.json");
73449
73588
  let variants = [];
73450
73589
  try {
73451
- if (existsSync57(archeFile))
73452
- variants = JSON.parse(readFileSync46(archeFile, "utf8"));
73590
+ if (existsSync58(archeFile))
73591
+ variants = JSON.parse(readFileSync47(archeFile, "utf8"));
73453
73592
  } catch {
73454
73593
  }
73455
73594
  variants.push({
@@ -73464,15 +73603,15 @@ async function runWithTUI(task, config, repoPath, callbacks) {
73464
73603
  });
73465
73604
  if (variants.length > 50)
73466
73605
  variants = variants.slice(-50);
73467
- mkdirSync30(archeDir, { recursive: true });
73468
- writeFileSync28(archeFile, JSON.stringify(variants, null, 2));
73606
+ mkdirSync31(archeDir, { recursive: true });
73607
+ writeFileSync29(archeFile, JSON.stringify(variants, null, 2));
73469
73608
  } catch {
73470
73609
  }
73471
73610
  }
73472
73611
  try {
73473
- const metaFile = join74(repoRoot, ".oa", "memory", "metabolism", "store.json");
73474
- if (existsSync57(metaFile)) {
73475
- const store2 = JSON.parse(readFileSync46(metaFile, "utf8"));
73612
+ const metaFile = join75(repoRoot, ".oa", "memory", "metabolism", "store.json");
73613
+ if (existsSync58(metaFile)) {
73614
+ const store2 = JSON.parse(readFileSync47(metaFile, "utf8"));
73476
73615
  const surfaced = store2.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
73477
73616
  let updated = false;
73478
73617
  for (const item of surfaced) {
@@ -73483,7 +73622,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
73483
73622
  updated = true;
73484
73623
  }
73485
73624
  if (updated) {
73486
- writeFileSync28(metaFile, JSON.stringify(store2, null, 2));
73625
+ writeFileSync29(metaFile, JSON.stringify(store2, null, 2));
73487
73626
  }
73488
73627
  }
73489
73628
  } catch {
@@ -73536,9 +73675,9 @@ Rules:
73536
73675
  try {
73537
73676
  const { initDb: initDb2 } = __require("@open-agents/memory");
73538
73677
  const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
73539
- const dbDir = join74(repoRoot, ".oa", "memory");
73540
- mkdirSync30(dbDir, { recursive: true });
73541
- const db = initDb2(join74(dbDir, "structured.db"));
73678
+ const dbDir = join75(repoRoot, ".oa", "memory");
73679
+ mkdirSync31(dbDir, { recursive: true });
73680
+ const db = initDb2(join75(dbDir, "structured.db"));
73542
73681
  const memStore = new ProceduralMemoryStore2(db);
73543
73682
  memStore.createWithEmbedding({
73544
73683
  content: content.slice(0, 600),
@@ -73553,12 +73692,12 @@ Rules:
73553
73692
  db.close();
73554
73693
  } catch {
73555
73694
  }
73556
- const metaDir = join74(repoRoot, ".oa", "memory", "metabolism");
73557
- const storeFile = join74(metaDir, "store.json");
73695
+ const metaDir = join75(repoRoot, ".oa", "memory", "metabolism");
73696
+ const storeFile = join75(metaDir, "store.json");
73558
73697
  let store2 = [];
73559
73698
  try {
73560
- if (existsSync57(storeFile))
73561
- store2 = JSON.parse(readFileSync46(storeFile, "utf8"));
73699
+ if (existsSync58(storeFile))
73700
+ store2 = JSON.parse(readFileSync47(storeFile, "utf8"));
73562
73701
  } catch {
73563
73702
  }
73564
73703
  store2.push({
@@ -73574,26 +73713,26 @@ Rules:
73574
73713
  });
73575
73714
  if (store2.length > 100)
73576
73715
  store2 = store2.slice(-100);
73577
- mkdirSync30(metaDir, { recursive: true });
73578
- writeFileSync28(storeFile, JSON.stringify(store2, null, 2));
73716
+ mkdirSync31(metaDir, { recursive: true });
73717
+ writeFileSync29(storeFile, JSON.stringify(store2, null, 2));
73579
73718
  }
73580
73719
  }
73581
73720
  } catch {
73582
73721
  }
73583
73722
  try {
73584
- const cohereSettingsFile = join74(repoRoot, ".oa", "settings.json");
73723
+ const cohereSettingsFile = join75(repoRoot, ".oa", "settings.json");
73585
73724
  let cohereActive = false;
73586
73725
  try {
73587
- if (existsSync57(cohereSettingsFile)) {
73588
- const settings = JSON.parse(readFileSync46(cohereSettingsFile, "utf8"));
73726
+ if (existsSync58(cohereSettingsFile)) {
73727
+ const settings = JSON.parse(readFileSync47(cohereSettingsFile, "utf8"));
73589
73728
  cohereActive = settings.cohere === true;
73590
73729
  }
73591
73730
  } catch {
73592
73731
  }
73593
73732
  if (cohereActive) {
73594
- const metaFile = join74(repoRoot, ".oa", "memory", "metabolism", "store.json");
73595
- if (existsSync57(metaFile)) {
73596
- const store2 = JSON.parse(readFileSync46(metaFile, "utf8"));
73733
+ const metaFile = join75(repoRoot, ".oa", "memory", "metabolism", "store.json");
73734
+ if (existsSync58(metaFile)) {
73735
+ const store2 = JSON.parse(readFileSync47(metaFile, "utf8"));
73597
73736
  const latest = store2.filter((m) => m.sourceTrace === "trajectory-extraction" || m.sourceTrace === "llm-trajectory-extraction").slice(-1)[0];
73598
73737
  if (latest && latest.scores?.confidence >= 0.6) {
73599
73738
  try {
@@ -73618,18 +73757,18 @@ Rules:
73618
73757
  }
73619
73758
  } catch (err) {
73620
73759
  try {
73621
- const ikFile = join74(repoRoot, ".oa", "identity", "self-state.json");
73622
- if (existsSync57(ikFile)) {
73623
- const ikState = JSON.parse(readFileSync46(ikFile, "utf8"));
73760
+ const ikFile = join75(repoRoot, ".oa", "identity", "self-state.json");
73761
+ if (existsSync58(ikFile)) {
73762
+ const ikState = JSON.parse(readFileSync47(ikFile, "utf8"));
73624
73763
  ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
73625
73764
  ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
73626
73765
  ikState.session_count = (ikState.session_count || 0) + 1;
73627
73766
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
73628
- writeFileSync28(ikFile, JSON.stringify(ikState, null, 2));
73767
+ writeFileSync29(ikFile, JSON.stringify(ikState, null, 2));
73629
73768
  }
73630
- const metaFile = join74(repoRoot, ".oa", "memory", "metabolism", "store.json");
73631
- if (existsSync57(metaFile)) {
73632
- const store2 = JSON.parse(readFileSync46(metaFile, "utf8"));
73769
+ const metaFile = join75(repoRoot, ".oa", "memory", "metabolism", "store.json");
73770
+ if (existsSync58(metaFile)) {
73771
+ const store2 = JSON.parse(readFileSync47(metaFile, "utf8"));
73633
73772
  const surfaced = store2.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
73634
73773
  for (const item of surfaced) {
73635
73774
  item.accessCount = (item.accessCount || 0) + 1;
@@ -73637,15 +73776,15 @@ Rules:
73637
73776
  item.scores.utility = Math.max(0, (item.scores.utility || 0.5) - 0.05);
73638
73777
  item.scores.confidence = Math.max(0, (item.scores.confidence || 0.5) - 0.02);
73639
73778
  }
73640
- writeFileSync28(metaFile, JSON.stringify(store2, null, 2));
73779
+ writeFileSync29(metaFile, JSON.stringify(store2, null, 2));
73641
73780
  }
73642
73781
  try {
73643
- const archeDir = join74(repoRoot, ".oa", "arche");
73644
- const archeFile = join74(archeDir, "variants.json");
73782
+ const archeDir = join75(repoRoot, ".oa", "arche");
73783
+ const archeFile = join75(archeDir, "variants.json");
73645
73784
  let variants = [];
73646
73785
  try {
73647
- if (existsSync57(archeFile))
73648
- variants = JSON.parse(readFileSync46(archeFile, "utf8"));
73786
+ if (existsSync58(archeFile))
73787
+ variants = JSON.parse(readFileSync47(archeFile, "utf8"));
73649
73788
  } catch {
73650
73789
  }
73651
73790
  variants.push({
@@ -73660,8 +73799,8 @@ Rules:
73660
73799
  });
73661
73800
  if (variants.length > 50)
73662
73801
  variants = variants.slice(-50);
73663
- mkdirSync30(archeDir, { recursive: true });
73664
- writeFileSync28(archeFile, JSON.stringify(variants, null, 2));
73802
+ mkdirSync31(archeDir, { recursive: true });
73803
+ writeFileSync29(archeFile, JSON.stringify(variants, null, 2));
73665
73804
  } catch {
73666
73805
  }
73667
73806
  } catch {
@@ -73732,13 +73871,13 @@ __export(run_exports, {
73732
73871
  });
73733
73872
  import { resolve as resolve33 } from "node:path";
73734
73873
  import { spawn as spawn22 } from "node:child_process";
73735
- import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync29, readFileSync as readFileSync47, readdirSync as readdirSync24, existsSync as existsSync58 } from "node:fs";
73874
+ import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync30, readFileSync as readFileSync48, readdirSync as readdirSync24, existsSync as existsSync59 } from "node:fs";
73736
73875
  import { randomBytes as randomBytes17 } from "node:crypto";
73737
- import { join as join75 } from "node:path";
73876
+ import { join as join76 } from "node:path";
73738
73877
  function jobsDir2(repoPath) {
73739
73878
  const root = resolve33(repoPath ?? process.cwd());
73740
- const dir = join75(root, ".oa", "jobs");
73741
- mkdirSync31(dir, { recursive: true });
73879
+ const dir = join76(root, ".oa", "jobs");
73880
+ mkdirSync32(dir, { recursive: true });
73742
73881
  return dir;
73743
73882
  }
73744
73883
  async function runCommand(opts, config) {
@@ -73846,7 +73985,7 @@ async function runBackground(task, config, opts) {
73846
73985
  });
73847
73986
  child.unref();
73848
73987
  job.pid = child.pid ?? 0;
73849
- writeFileSync29(join75(dir, `${id}.json`), JSON.stringify(job, null, 2));
73988
+ writeFileSync30(join76(dir, `${id}.json`), JSON.stringify(job, null, 2));
73850
73989
  let output = "";
73851
73990
  child.stdout?.on("data", (chunk) => {
73852
73991
  output += chunk.toString();
@@ -73862,7 +74001,7 @@ async function runBackground(task, config, opts) {
73862
74001
  job.summary = result.summary;
73863
74002
  job.durationMs = result.durationMs;
73864
74003
  job.error = result.error;
73865
- writeFileSync29(join75(dir, `${id}.json`), JSON.stringify(job, null, 2));
74004
+ writeFileSync30(join76(dir, `${id}.json`), JSON.stringify(job, null, 2));
73866
74005
  } catch {
73867
74006
  }
73868
74007
  });
@@ -73878,13 +74017,13 @@ async function runBackground(task, config, opts) {
73878
74017
  }
73879
74018
  function statusCommand(jobId, repoPath) {
73880
74019
  const dir = jobsDir2(repoPath);
73881
- const file = join75(dir, `${jobId}.json`);
73882
- if (!existsSync58(file)) {
74020
+ const file = join76(dir, `${jobId}.json`);
74021
+ if (!existsSync59(file)) {
73883
74022
  console.error(`Job not found: ${jobId}`);
73884
74023
  console.log(`Available jobs: oa jobs`);
73885
74024
  process.exit(1);
73886
74025
  }
73887
- const job = JSON.parse(readFileSync47(file, "utf-8"));
74026
+ const job = JSON.parse(readFileSync48(file, "utf-8"));
73888
74027
  const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
73889
74028
  const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
73890
74029
  console.log(`${icon} ${job.id} [${job.status}] ${runtime}`);
@@ -73907,7 +74046,7 @@ function jobsCommand(repoPath) {
73907
74046
  console.log("Jobs:");
73908
74047
  for (const file of files) {
73909
74048
  try {
73910
- const job = JSON.parse(readFileSync47(join75(dir, file), "utf-8"));
74049
+ const job = JSON.parse(readFileSync48(join76(dir, file), "utf-8"));
73911
74050
  const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
73912
74051
  const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
73913
74052
  console.log(` ${icon} ${job.id} [${job.status}] ${runtime} \u2014 ${job.task.slice(0, 60)}`);
@@ -73927,7 +74066,7 @@ import { glob } from "glob";
73927
74066
  import ignore from "ignore";
73928
74067
  import { readFile as readFile23, stat as stat4 } from "node:fs/promises";
73929
74068
  import { createHash as createHash6 } from "node:crypto";
73930
- import { join as join76, relative as relative4, extname as extname12, basename as basename17 } from "node:path";
74069
+ import { join as join77, relative as relative4, extname as extname12, basename as basename17 } from "node:path";
73931
74070
  var DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
73932
74071
  var init_codebase_indexer = __esm({
73933
74072
  "packages/indexer/dist/codebase-indexer.js"() {
@@ -73971,7 +74110,7 @@ var init_codebase_indexer = __esm({
73971
74110
  const ig = ignore.default();
73972
74111
  if (this.config.respectGitignore) {
73973
74112
  try {
73974
- const gitignoreContent = await readFile23(join76(this.config.rootDir, ".gitignore"), "utf-8");
74113
+ const gitignoreContent = await readFile23(join77(this.config.rootDir, ".gitignore"), "utf-8");
73975
74114
  ig.add(gitignoreContent);
73976
74115
  } catch {
73977
74116
  }
@@ -73986,7 +74125,7 @@ var init_codebase_indexer = __esm({
73986
74125
  for (const relativePath of files) {
73987
74126
  if (ig.ignores(relativePath))
73988
74127
  continue;
73989
- const fullPath = join76(this.config.rootDir, relativePath);
74128
+ const fullPath = join77(this.config.rootDir, relativePath);
73990
74129
  try {
73991
74130
  const fileStat = await stat4(fullPath);
73992
74131
  if (fileStat.size > this.config.maxFileSize)
@@ -74032,7 +74171,7 @@ var init_codebase_indexer = __esm({
74032
74171
  if (!child) {
74033
74172
  child = {
74034
74173
  name: part,
74035
- path: join76(current.path, part),
74174
+ path: join77(current.path, part),
74036
74175
  type: "directory",
74037
74176
  children: []
74038
74177
  };
@@ -74115,13 +74254,13 @@ __export(index_repo_exports, {
74115
74254
  indexRepoCommand: () => indexRepoCommand
74116
74255
  });
74117
74256
  import { resolve as resolve34 } from "node:path";
74118
- import { existsSync as existsSync59, statSync as statSync17 } from "node:fs";
74257
+ import { existsSync as existsSync60, statSync as statSync17 } from "node:fs";
74119
74258
  import { cwd as cwd2 } from "node:process";
74120
74259
  async function indexRepoCommand(opts, _config) {
74121
74260
  const repoRoot = resolve34(opts.repoPath ?? cwd2());
74122
74261
  printHeader("Index Repository");
74123
74262
  printInfo(`Indexing: ${repoRoot}`);
74124
- if (!existsSync59(repoRoot)) {
74263
+ if (!existsSync60(repoRoot)) {
74125
74264
  printError(`Path does not exist: ${repoRoot}`);
74126
74265
  process.exit(1);
74127
74266
  }
@@ -74373,8 +74512,8 @@ var config_exports2 = {};
74373
74512
  __export(config_exports2, {
74374
74513
  configCommand: () => configCommand
74375
74514
  });
74376
- import { join as join77, resolve as resolve35 } from "node:path";
74377
- import { homedir as homedir20 } from "node:os";
74515
+ import { join as join78, resolve as resolve35 } from "node:path";
74516
+ import { homedir as homedir21 } from "node:os";
74378
74517
  import { cwd as cwd3 } from "node:process";
74379
74518
  function redactIfSensitive(key, value) {
74380
74519
  if (SENSITIVE_KEYS.has(key) && typeof value === "string" && value.length > 0) {
@@ -74456,7 +74595,7 @@ function handleShow(opts, config) {
74456
74595
  }
74457
74596
  }
74458
74597
  printSection("Config File");
74459
- printInfo(`~/.open-agents/config.json (${join77(homedir20(), ".open-agents", "config.json")})`);
74598
+ printInfo(`~/.open-agents/config.json (${join78(homedir21(), ".open-agents", "config.json")})`);
74460
74599
  printSection("Priority Chain");
74461
74600
  printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
74462
74601
  printInfo(" 2. Project .oa/settings.json (--local)");
@@ -74495,7 +74634,7 @@ function handleSet(opts, _config) {
74495
74634
  const coerced = coerceForSettings(key, value);
74496
74635
  saveProjectSettings(repoRoot, { [key]: coerced });
74497
74636
  printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value)}`);
74498
- printInfo(`Saved to ${join77(repoRoot, ".oa", "settings.json")}`);
74637
+ printInfo(`Saved to ${join78(repoRoot, ".oa", "settings.json")}`);
74499
74638
  printInfo("This override applies only when running in this workspace.");
74500
74639
  } catch (err) {
74501
74640
  printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
@@ -74638,8 +74777,8 @@ __export(eval_exports, {
74638
74777
  evalCommand: () => evalCommand
74639
74778
  });
74640
74779
  import { tmpdir as tmpdir10 } from "node:os";
74641
- import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync30 } from "node:fs";
74642
- import { join as join78 } from "node:path";
74780
+ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync31 } from "node:fs";
74781
+ import { join as join79 } from "node:path";
74643
74782
  async function evalCommand(opts, config) {
74644
74783
  const suiteName = opts.suite ?? "basic";
74645
74784
  const suite = SUITES[suiteName];
@@ -74764,9 +74903,9 @@ async function evalCommand(opts, config) {
74764
74903
  process.exit(failed > 0 ? 1 : 0);
74765
74904
  }
74766
74905
  function createTempEvalRepo() {
74767
- const dir = join78(tmpdir10(), `open-agents-eval-${Date.now()}`);
74768
- mkdirSync32(dir, { recursive: true });
74769
- writeFileSync30(join78(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
74906
+ const dir = join79(tmpdir10(), `open-agents-eval-${Date.now()}`);
74907
+ mkdirSync33(dir, { recursive: true });
74908
+ writeFileSync31(join79(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
74770
74909
  return dir;
74771
74910
  }
74772
74911
  var BASIC_SUITE, FULL_SUITE, SUITES;
@@ -74826,7 +74965,7 @@ init_updater();
74826
74965
  import { parseArgs as nodeParseArgs2 } from "node:util";
74827
74966
  import { createRequire as createRequire5 } from "node:module";
74828
74967
  import { fileURLToPath as fileURLToPath15 } from "node:url";
74829
- import { dirname as dirname23, join as join79 } from "node:path";
74968
+ import { dirname as dirname23, join as join80 } from "node:path";
74830
74969
 
74831
74970
  // packages/cli/dist/cli.js
74832
74971
  import { createInterface } from "node:readline";
@@ -74933,7 +75072,7 @@ init_output();
74933
75072
  function getVersion5() {
74934
75073
  try {
74935
75074
  const require2 = createRequire5(import.meta.url);
74936
- const pkgPath = join79(dirname23(fileURLToPath15(import.meta.url)), "..", "package.json");
75075
+ const pkgPath = join80(dirname23(fileURLToPath15(import.meta.url)), "..", "package.json");
74937
75076
  const pkg = require2(pkgPath);
74938
75077
  return pkg.version;
74939
75078
  } catch {
@@ -75208,12 +75347,12 @@ function crashLog(label, err) {
75208
75347
  const logLine = `[${timestamp}] ${label}: ${msg}
75209
75348
  `;
75210
75349
  try {
75211
- const { appendFileSync: appendFileSync6, mkdirSync: mkdirSync33 } = __require("node:fs");
75212
- const { join: join80 } = __require("node:path");
75213
- const { homedir: homedir21 } = __require("node:os");
75214
- const logDir = join80(homedir21(), ".open-agents");
75215
- mkdirSync33(logDir, { recursive: true });
75216
- appendFileSync6(join80(logDir, "crash.log"), logLine);
75350
+ const { appendFileSync: appendFileSync6, mkdirSync: mkdirSync34 } = __require("node:fs");
75351
+ const { join: join81 } = __require("node:path");
75352
+ const { homedir: homedir22 } = __require("node:os");
75353
+ const logDir = join81(homedir22(), ".open-agents");
75354
+ mkdirSync34(logDir, { recursive: true });
75355
+ appendFileSync6(join81(logDir, "crash.log"), logLine);
75217
75356
  } catch {
75218
75357
  }
75219
75358
  try {