open-agents-ai 0.187.591 → 0.187.593

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15477,8 +15477,8 @@ function deleteCustomToolDefinition(name10, scope, repoRoot) {
15477
15477
  const dir = scope === "project" && repoRoot ? projectToolsDir(repoRoot) : globalToolsDir();
15478
15478
  const filePath = join24(dir, `${name10}.json`);
15479
15479
  if (existsSync19(filePath)) {
15480
- const { unlinkSync: unlinkSync25 } = __require("node:fs");
15481
- unlinkSync25(filePath);
15480
+ const { unlinkSync: unlinkSync26 } = __require("node:fs");
15481
+ unlinkSync26(filePath);
15482
15482
  return true;
15483
15483
  }
15484
15484
  return false;
@@ -248930,7 +248930,7 @@ print("${sentinel}")
248930
248930
  if (!this.proc || this.proc.killed) {
248931
248931
  return { success: false, path: "" };
248932
248932
  }
248933
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = await import("node:fs");
248933
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = await import("node:fs");
248934
248934
  const sessionDir = join31(this.cwd, ".oa", "rlm");
248935
248935
  mkdirSync74(sessionDir, { recursive: true });
248936
248936
  const sessionPath2 = join31(sessionDir, "session.json");
@@ -248956,7 +248956,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
248956
248956
  trajectoryCount: this.trajectory.length,
248957
248957
  subCallCount: this.subCallCount
248958
248958
  };
248959
- writeFileSync67(sessionPath2, JSON.stringify(sessionData, null, 2), "utf8");
248959
+ writeFileSync68(sessionPath2, JSON.stringify(sessionData, null, 2), "utf8");
248960
248960
  return { success: true, path: sessionPath2 };
248961
248961
  }
248962
248962
  } catch {
@@ -248968,11 +248968,11 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
248968
248968
  * what was previously computed. */
248969
248969
  async loadSessionInfo() {
248970
248970
  try {
248971
- const { readFileSync: readFileSync98, existsSync: existsSync118 } = await import("node:fs");
248971
+ const { readFileSync: readFileSync99, existsSync: existsSync119 } = await import("node:fs");
248972
248972
  const sessionPath2 = join31(this.cwd, ".oa", "rlm", "session.json");
248973
- if (!existsSync118(sessionPath2))
248973
+ if (!existsSync119(sessionPath2))
248974
248974
  return null;
248975
- return JSON.parse(readFileSync98(sessionPath2, "utf8"));
248975
+ return JSON.parse(readFileSync99(sessionPath2, "utf8"));
248976
248976
  } catch {
248977
248977
  return null;
248978
248978
  }
@@ -249149,10 +249149,10 @@ var init_memory_metabolism = __esm({
249149
249149
  const trajDir = join32(this.cwd, ".oa", "rlm-trajectories");
249150
249150
  let lessons = [];
249151
249151
  try {
249152
- const { readdirSync: readdirSync42, readFileSync: readFileSync98 } = await import("node:fs");
249152
+ const { readdirSync: readdirSync42, readFileSync: readFileSync99 } = await import("node:fs");
249153
249153
  const files = readdirSync42(trajDir).filter((f2) => f2.endsWith(".jsonl")).sort().reverse().slice(0, 3);
249154
249154
  for (const file of files) {
249155
- const lines = readFileSync98(join32(trajDir, file), "utf8").split("\n").filter((l2) => l2.trim());
249155
+ const lines = readFileSync99(join32(trajDir, file), "utf8").split("\n").filter((l2) => l2.trim());
249156
249156
  for (const line of lines) {
249157
249157
  try {
249158
249158
  const entry = JSON.parse(line);
@@ -249536,14 +249536,14 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
249536
249536
  * Optionally filter by task type for phase-aware context (FSM paper insight).
249537
249537
  */
249538
249538
  getTopMemoriesSync(k = 5, taskType) {
249539
- const { readFileSync: readFileSync98, existsSync: existsSync118 } = __require("node:fs");
249539
+ const { readFileSync: readFileSync99, existsSync: existsSync119 } = __require("node:fs");
249540
249540
  const metaDir = join32(this.cwd, ".oa", "memory", "metabolism");
249541
249541
  const storeFile = join32(metaDir, "store.json");
249542
- if (!existsSync118(storeFile))
249542
+ if (!existsSync119(storeFile))
249543
249543
  return "";
249544
249544
  let store2 = [];
249545
249545
  try {
249546
- store2 = JSON.parse(readFileSync98(storeFile, "utf8"));
249546
+ store2 = JSON.parse(readFileSync99(storeFile, "utf8"));
249547
249547
  } catch {
249548
249548
  return "";
249549
249549
  }
@@ -249565,14 +249565,14 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
249565
249565
  /** Update memory scores based on task outcome. Called after task completion.
249566
249566
  * Memories used in successful tasks get boosted. Memories present during failures get decayed. */
249567
249567
  updateFromOutcomeSync(surfacedMemoryText, succeeded) {
249568
- const { readFileSync: readFileSync98, writeFileSync: writeFileSync67, existsSync: existsSync118, mkdirSync: mkdirSync74 } = __require("node:fs");
249568
+ const { readFileSync: readFileSync99, writeFileSync: writeFileSync68, existsSync: existsSync119, mkdirSync: mkdirSync74 } = __require("node:fs");
249569
249569
  const metaDir = join32(this.cwd, ".oa", "memory", "metabolism");
249570
249570
  const storeFile = join32(metaDir, "store.json");
249571
- if (!existsSync118(storeFile))
249571
+ if (!existsSync119(storeFile))
249572
249572
  return;
249573
249573
  let store2 = [];
249574
249574
  try {
249575
- store2 = JSON.parse(readFileSync98(storeFile, "utf8"));
249575
+ store2 = JSON.parse(readFileSync99(storeFile, "utf8"));
249576
249576
  } catch {
249577
249577
  return;
249578
249578
  }
@@ -249597,7 +249597,7 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
249597
249597
  }
249598
249598
  if (updated) {
249599
249599
  mkdirSync74(metaDir, { recursive: true });
249600
- writeFileSync67(storeFile, JSON.stringify(store2, null, 2));
249600
+ writeFileSync68(storeFile, JSON.stringify(store2, null, 2));
249601
249601
  }
249602
249602
  }
249603
249603
  // ── Storage ──────────────────────────────────────────────────────────
@@ -250019,13 +250019,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
250019
250019
  // Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
250020
250020
  /** Retrieve top-K strategies for context injection. Returns "" if none. */
250021
250021
  getRelevantStrategiesSync(k = 3, taskType) {
250022
- const { readFileSync: readFileSync98, existsSync: existsSync118 } = __require("node:fs");
250022
+ const { readFileSync: readFileSync99, existsSync: existsSync119 } = __require("node:fs");
250023
250023
  const archiveFile = join34(this.cwd, ".oa", "arche", "variants.json");
250024
- if (!existsSync118(archiveFile))
250024
+ if (!existsSync119(archiveFile))
250025
250025
  return "";
250026
250026
  let variants = [];
250027
250027
  try {
250028
- variants = JSON.parse(readFileSync98(archiveFile, "utf8"));
250028
+ variants = JSON.parse(readFileSync99(archiveFile, "utf8"));
250029
250029
  } catch {
250030
250030
  return "";
250031
250031
  }
@@ -250043,13 +250043,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
250043
250043
  }
250044
250044
  /** Archive a strategy variant synchronously (for task completion path) */
250045
250045
  archiveVariantSync(strategy, outcome, tags = []) {
250046
- const { readFileSync: readFileSync98, writeFileSync: writeFileSync67, existsSync: existsSync118, mkdirSync: mkdirSync74 } = __require("node:fs");
250046
+ const { readFileSync: readFileSync99, writeFileSync: writeFileSync68, existsSync: existsSync119, mkdirSync: mkdirSync74 } = __require("node:fs");
250047
250047
  const dir = join34(this.cwd, ".oa", "arche");
250048
250048
  const archiveFile = join34(dir, "variants.json");
250049
250049
  let variants = [];
250050
250050
  try {
250051
- if (existsSync118(archiveFile))
250052
- variants = JSON.parse(readFileSync98(archiveFile, "utf8"));
250051
+ if (existsSync119(archiveFile))
250052
+ variants = JSON.parse(readFileSync99(archiveFile, "utf8"));
250053
250053
  } catch {
250054
250054
  }
250055
250055
  variants.push({
@@ -250065,7 +250065,7 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
250065
250065
  if (variants.length > 50)
250066
250066
  variants = variants.slice(-50);
250067
250067
  mkdirSync74(dir, { recursive: true });
250068
- writeFileSync67(archiveFile, JSON.stringify(variants, null, 2));
250068
+ writeFileSync68(archiveFile, JSON.stringify(variants, null, 2));
250069
250069
  }
250070
250070
  async saveArchive(variants) {
250071
250071
  const dir = join34(this.cwd, ".oa", "arche");
@@ -252940,8 +252940,8 @@ var init_browser_action = __esm({
252940
252940
  const afterDom = await apiCall("/dom", "GET");
252941
252941
  const afterTitle = (afterDom.dom || "").match(/<title[^>]*>([^<]*)<\/title>/i)?.[1] || "";
252942
252942
  try {
252943
- const { unlinkSync: unlinkSync25 } = await import("node:fs");
252944
- unlinkSync25(imagePath);
252943
+ const { unlinkSync: unlinkSync26 } = await import("node:fs");
252944
+ unlinkSync26(imagePath);
252945
252945
  } catch {
252946
252946
  }
252947
252947
  return {
@@ -258329,7 +258329,7 @@ var require_util9 = __commonJS({
258329
258329
  return path11;
258330
258330
  }
258331
258331
  exports.normalize = normalize2;
258332
- function join137(aRoot, aPath) {
258332
+ function join138(aRoot, aPath) {
258333
258333
  if (aRoot === "") {
258334
258334
  aRoot = ".";
258335
258335
  }
@@ -258361,7 +258361,7 @@ var require_util9 = __commonJS({
258361
258361
  }
258362
258362
  return joined;
258363
258363
  }
258364
- exports.join = join137;
258364
+ exports.join = join138;
258365
258365
  exports.isAbsolute = function(aPath) {
258366
258366
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
258367
258367
  };
@@ -258534,7 +258534,7 @@ var require_util9 = __commonJS({
258534
258534
  parsed.path = parsed.path.substring(0, index + 1);
258535
258535
  }
258536
258536
  }
258537
- sourceURL = join137(urlGenerate(parsed), sourceURL);
258537
+ sourceURL = join138(urlGenerate(parsed), sourceURL);
258538
258538
  }
258539
258539
  return normalize2(sourceURL);
258540
258540
  }
@@ -473954,7 +473954,7 @@ var require_path_browserify = __commonJS({
473954
473954
  assertPath(path11);
473955
473955
  return path11.length > 0 && path11.charCodeAt(0) === 47;
473956
473956
  },
473957
- join: function join137() {
473957
+ join: function join138() {
473958
473958
  if (arguments.length === 0)
473959
473959
  return ".";
473960
473960
  var joined;
@@ -524221,9 +524221,9 @@ var init_reflectionBuffer = __esm({
524221
524221
  this.persistPath = persistPath ?? null;
524222
524222
  if (this.persistPath) {
524223
524223
  try {
524224
- const { readFileSync: readFileSync98, existsSync: existsSync118 } = __require("node:fs");
524225
- if (existsSync118(this.persistPath)) {
524226
- this.state = JSON.parse(readFileSync98(this.persistPath, "utf-8"));
524224
+ const { readFileSync: readFileSync99, existsSync: existsSync119 } = __require("node:fs");
524225
+ if (existsSync119(this.persistPath)) {
524226
+ this.state = JSON.parse(readFileSync99(this.persistPath, "utf-8"));
524227
524227
  return;
524228
524228
  }
524229
524229
  } catch {
@@ -524456,12 +524456,12 @@ var init_reflectionBuffer = __esm({
524456
524456
  if (!this.persistPath)
524457
524457
  return;
524458
524458
  try {
524459
- const { writeFileSync: writeFileSync67, mkdirSync: mkdirSync74, existsSync: existsSync118 } = __require("node:fs");
524460
- const { join: join137 } = __require("node:path");
524461
- const dir = join137(this.persistPath, "..");
524462
- if (!existsSync118(dir))
524459
+ const { writeFileSync: writeFileSync68, mkdirSync: mkdirSync74, existsSync: existsSync119 } = __require("node:fs");
524460
+ const { join: join138 } = __require("node:path");
524461
+ const dir = join138(this.persistPath, "..");
524462
+ if (!existsSync119(dir))
524463
524463
  mkdirSync74(dir, { recursive: true });
524464
- writeFileSync67(this.persistPath, JSON.stringify(this.state, null, 2));
524464
+ writeFileSync68(this.persistPath, JSON.stringify(this.state, null, 2));
524465
524465
  } catch {
524466
524466
  }
524467
524467
  }
@@ -527374,9 +527374,11 @@ RECOVERY: cd to the directory containing '${file}', run a plain install with no
527374
527374
  });
527375
527375
 
527376
527376
  // packages/orchestrator/dist/agenticRunner.js
527377
- import { existsSync as _fsExistsSync, readFileSync as _fsReadFileSync, writeFileSync as _fsWriteFileSync, mkdirSync as _fsMkdirSync } from "node:fs";
527377
+ import { existsSync as _fsExistsSync, readFileSync as _fsReadFileSync, writeFileSync as _fsWriteFileSync, unlinkSync as _fsUnlinkSync, mkdirSync as _fsMkdirSync } from "node:fs";
527378
+ import { execFile as _execFile } from "node:child_process";
527378
527379
  import { createHash as _createHash } from "node:crypto";
527379
527380
  import { join as _pathJoin } from "node:path";
527381
+ import { tmpdir as _osTmpdir } from "node:os";
527380
527382
  import { homedir as _osHomedir } from "node:os";
527381
527383
  import { z as z15 } from "zod";
527382
527384
  function repairJson(raw) {
@@ -532289,45 +532291,7 @@ ${_staleSamples.join("\n")}` : ``,
532289
532291
  }
532290
532292
  while (this.pendingUserMessages.length > 0) {
532291
532293
  const userMsg = this.pendingUserMessages.shift();
532292
- const imagePattern = /\[IMAGE_BASE64:([^:]+):([^\]]+)\]/;
532293
- const imgMatch = userMsg.match(imagePattern);
532294
- if (imgMatch) {
532295
- const mime = imgMatch[1];
532296
- const base642 = imgMatch[2];
532297
- const textContent = userMsg.replace(imagePattern, "").trim();
532298
- const parts = [];
532299
- if (textContent) {
532300
- parts.push({
532301
- type: "text",
532302
- text: `[User added context]: ${textContent}
532303
-
532304
- Describe what you see and integrate this into your current approach.`
532305
- });
532306
- } else {
532307
- parts.push({
532308
- type: "text",
532309
- text: "[User shared an image]. Describe what you see and integrate this into your current approach."
532310
- });
532311
- }
532312
- parts.push({
532313
- type: "image_url",
532314
- image_url: { url: `data:${mime};base64,${base642}` }
532315
- });
532316
- messages2.push({ role: "user", content: parts });
532317
- } else {
532318
- messages2.push({
532319
- role: "user",
532320
- content: `[User added context]: ${userMsg}
532321
-
532322
- Integrate this guidance into your current approach. Continue working on the task.`
532323
- });
532324
- }
532325
- this.emit({
532326
- type: "user_interrupt",
532327
- content: userMsg.replace(/\[IMAGE_BASE64:[^\]]+\]/, "[image]").slice(0, 200),
532328
- turn,
532329
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
532330
- });
532294
+ await this.appendInjectedUserMessage(userMsg, messages2, turn);
532331
532295
  }
532332
532296
  {
532333
532297
  const maybeReminder = this.getTodoReminderContent(turn);
@@ -532648,12 +532612,28 @@ ${memoryLines.join("\n")}`
532648
532612
  timeoutMs: this.options.requestTimeoutMs
532649
532613
  };
532650
532614
  {
532615
+ const _imgB64Pat = /\[IMAGE_BASE64:[^\]]+\]/g;
532651
532616
  const ctxChars = compacted.reduce((s2, m2) => {
532652
- let c9 = typeof m2.content === "string" ? m2.content.length : 100;
532617
+ let c9 = 0;
532618
+ let imgCount = 0;
532619
+ if (typeof m2.content === "string") {
532620
+ const imgMatches = m2.content.match(_imgB64Pat);
532621
+ imgCount = imgMatches ? imgMatches.length : 0;
532622
+ c9 = m2.content.replace(_imgB64Pat, "").length;
532623
+ } else if (Array.isArray(m2.content)) {
532624
+ for (const p2 of m2.content) {
532625
+ if (p2.type === "text" && p2.text)
532626
+ c9 += p2.text.length;
532627
+ else if (p2.type === "image_url")
532628
+ imgCount++;
532629
+ }
532630
+ } else {
532631
+ c9 = 100;
532632
+ }
532653
532633
  if (m2.tool_calls)
532654
532634
  for (const tc of m2.tool_calls)
532655
532635
  c9 += tc.function.arguments?.length ?? 0;
532656
- return s2 + c9;
532636
+ return s2 + c9 + imgCount * 1500 * 4;
532657
532637
  }, 0);
532658
532638
  const estTokens = Math.ceil(ctxChars / 4);
532659
532639
  const limits = this.contextLimits();
@@ -532867,13 +532847,31 @@ ${memoryLines.join("\n")}`
532867
532847
  const choiceContent = response.choices[0]?.message?.content ?? "";
532868
532848
  const choiceArgs = response.choices[0]?.message?.toolCalls?.map((tc) => JSON.stringify(tc.arguments)).join("") ?? "";
532869
532849
  estimatedTokens += Math.ceil((choiceContent.length + choiceArgs.length) / 4);
532850
+ const IMAGE_TOKEN_ESTIMATE = 1500;
532851
+ const imageBase64Pattern = /\[IMAGE_BASE64:[^\]]+\]/g;
532870
532852
  const estimatedContextTokens = Math.ceil(compacted.reduce((sum, m2) => {
532871
- let chars = typeof m2.content === "string" ? m2.content.length : 100;
532853
+ let chars = 0;
532854
+ let imageCount = 0;
532855
+ if (typeof m2.content === "string") {
532856
+ const imageMatches = m2.content.match(imageBase64Pattern);
532857
+ imageCount = imageMatches ? imageMatches.length : 0;
532858
+ chars = m2.content.replace(imageBase64Pattern, "").length;
532859
+ } else if (Array.isArray(m2.content)) {
532860
+ for (const part of m2.content) {
532861
+ if (part.type === "text" && part.text) {
532862
+ chars += part.text.length;
532863
+ } else if (part.type === "image_url") {
532864
+ imageCount++;
532865
+ }
532866
+ }
532867
+ } else {
532868
+ chars = 100;
532869
+ }
532872
532870
  if (m2.tool_calls) {
532873
532871
  for (const tc of m2.tool_calls)
532874
532872
  chars += tc.function.arguments?.length ?? 0;
532875
532873
  }
532876
- return sum + chars;
532874
+ return sum + chars + imageCount * IMAGE_TOKEN_ESTIMATE * 4;
532877
532875
  }, 0) / 4);
532878
532876
  this.emit({
532879
532877
  type: "token_usage",
@@ -535327,45 +535325,7 @@ You have ${this.options.maxTurns} more turns. Continue making progress. Call tas
535327
535325
  }
535328
535326
  while (this.pendingUserMessages.length > 0) {
535329
535327
  const userMsg = this.pendingUserMessages.shift();
535330
- const imagePattern = /\[IMAGE_BASE64:([^:]+):([^\]]+)\]/;
535331
- const imgMatch = userMsg.match(imagePattern);
535332
- if (imgMatch) {
535333
- const mime = imgMatch[1];
535334
- const base642 = imgMatch[2];
535335
- const textContent = userMsg.replace(imagePattern, "").trim();
535336
- const parts = [];
535337
- if (textContent) {
535338
- parts.push({
535339
- type: "text",
535340
- text: `[User added context]: ${textContent}
535341
-
535342
- Describe what you see and integrate this into your current approach.`
535343
- });
535344
- } else {
535345
- parts.push({
535346
- type: "text",
535347
- text: "[User shared an image]. Describe what you see and integrate this into your current approach."
535348
- });
535349
- }
535350
- parts.push({
535351
- type: "image_url",
535352
- image_url: { url: `data:${mime};base64,${base642}` }
535353
- });
535354
- messages2.push({ role: "user", content: parts });
535355
- } else {
535356
- messages2.push({
535357
- role: "user",
535358
- content: `[User added context]: ${userMsg}
535359
-
535360
- Integrate this guidance into your current approach. Continue working on the task.`
535361
- });
535362
- }
535363
- this.emit({
535364
- type: "user_interrupt",
535365
- content: userMsg.replace(/\[IMAGE_BASE64:[^\]]+\]/, "[image]").slice(0, 200),
535366
- turn,
535367
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
535368
- });
535328
+ await this.appendInjectedUserMessage(userMsg, messages2, turn);
535369
535329
  }
535370
535330
  let compactedMsgs;
535371
535331
  if (this._pendingCompaction) {
@@ -535440,13 +535400,29 @@ Integrate this guidance into your current approach. Continue working on the task
535440
535400
  const choiceContent2 = response.choices[0]?.message?.content ?? "";
535441
535401
  const choiceArgs2 = response.choices[0]?.message?.toolCalls?.map((tc) => JSON.stringify(tc.arguments)).join("") ?? "";
535442
535402
  estimatedTokens += Math.ceil((choiceContent2.length + choiceArgs2.length) / 4);
535403
+ const _bfImgPat = /\[IMAGE_BASE64:[^\]]+\]/g;
535443
535404
  const bfEstCtx = Math.ceil(compactedMsgs.reduce((sum, m2) => {
535444
- let chars = typeof m2.content === "string" ? m2.content.length : 100;
535405
+ let chars = 0;
535406
+ let imgCount = 0;
535407
+ if (typeof m2.content === "string") {
535408
+ const imgMatches = m2.content.match(_bfImgPat);
535409
+ imgCount = imgMatches ? imgMatches.length : 0;
535410
+ chars = m2.content.replace(_bfImgPat, "").length;
535411
+ } else if (Array.isArray(m2.content)) {
535412
+ for (const p2 of m2.content) {
535413
+ if (p2.type === "text" && p2.text)
535414
+ chars += p2.text.length;
535415
+ else if (p2.type === "image_url")
535416
+ imgCount++;
535417
+ }
535418
+ } else {
535419
+ chars = 100;
535420
+ }
535445
535421
  if (m2.tool_calls) {
535446
535422
  for (const tc of m2.tool_calls)
535447
535423
  chars += tc.function.arguments?.length ?? 0;
535448
535424
  }
535449
- return sum + chars;
535425
+ return sum + chars + imgCount * 1500 * 4;
535450
535426
  }, 0) / 4);
535451
535427
  this.emit({
535452
535428
  type: "token_usage",
@@ -536240,9 +536216,9 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
536240
536216
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
536241
536217
  });
536242
536218
  try {
536243
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = __require("node:fs");
536244
- const { join: join137 } = __require("node:path");
536245
- const contextDir = join137(this._workingDirectory || process.cwd(), ".oa", "context");
536219
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = __require("node:fs");
536220
+ const { join: join138 } = __require("node:path");
536221
+ const contextDir = join138(this._workingDirectory || process.cwd(), ".oa", "context");
536246
536222
  mkdirSync74(contextDir, { recursive: true });
536247
536223
  const topEntities = this._temporalGraph.nodesByType("entity", 3);
536248
536224
  const topFiles = this._temporalGraph.nodesByType("file", 3);
@@ -536283,9 +536259,9 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
536283
536259
  section("Top Files", topFiles);
536284
536260
  section("Top Concepts", topConcepts);
536285
536261
  lines.push("(Use file_read on this file for quick recall. See provenance JSON for full edge detail.)");
536286
- const outPath = join137(contextDir, `kg-summary-${this._sessionId}.md`);
536287
- writeFileSync67(outPath, lines.join("\n"), "utf-8");
536288
- writeFileSync67(join137(contextDir, `kg-summary-latest.md`), lines.join("\n"), "utf-8");
536262
+ const outPath = join138(contextDir, `kg-summary-${this._sessionId}.md`);
536263
+ writeFileSync68(outPath, lines.join("\n"), "utf-8");
536264
+ writeFileSync68(join138(contextDir, `kg-summary-latest.md`), lines.join("\n"), "utf-8");
536289
536265
  } catch {
536290
536266
  }
536291
536267
  }
@@ -536469,11 +536445,11 @@ ${errOutput}`;
536469
536445
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
536470
536446
  });
536471
536447
  try {
536472
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = __require("node:fs");
536473
- const { join: join137 } = __require("node:path");
536474
- const resultsDir = join137(process.cwd(), ".oa", "tool-results");
536448
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = __require("node:fs");
536449
+ const { join: join138 } = __require("node:path");
536450
+ const resultsDir = join138(process.cwd(), ".oa", "tool-results");
536475
536451
  mkdirSync74(resultsDir, { recursive: true });
536476
- writeFileSync67(join137(resultsDir, `${handleId}.txt`), `# Tool: ${toolName}
536452
+ writeFileSync68(join138(resultsDir, `${handleId}.txt`), `# Tool: ${toolName}
536477
536453
  # Turn: ${turn}
536478
536454
  # Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}
536479
536455
  # Size: ${result.output.length} chars, ${lineCount} lines
@@ -536834,9 +536810,9 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
536834
536810
  if (!this._workingDirectory)
536835
536811
  return;
536836
536812
  try {
536837
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = __require("node:fs");
536838
- const { join: join137 } = __require("node:path");
536839
- const sessionDir = join137(this._workingDirectory, ".oa", "session", this._sessionId);
536813
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = __require("node:fs");
536814
+ const { join: join138 } = __require("node:path");
536815
+ const sessionDir = join138(this._workingDirectory, ".oa", "session", this._sessionId);
536840
536816
  mkdirSync74(sessionDir, { recursive: true });
536841
536817
  const checkpoint = {
536842
536818
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -536849,7 +536825,7 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
536849
536825
  memexEntryCount: this._memexArchive.size,
536850
536826
  fileRegistrySize: this._fileRegistry.size
536851
536827
  };
536852
- writeFileSync67(join137(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
536828
+ writeFileSync68(join138(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
536853
536829
  } catch {
536854
536830
  }
536855
536831
  }
@@ -536874,18 +536850,187 @@ ${tail}`;
536874
536850
  }
536875
536851
  return folded;
536876
536852
  }
536853
+ async appendInjectedUserMessage(userMsg, messages2, turn) {
536854
+ const imagePattern = /\[IMAGE_BASE64:([^:]+):([^\]]+)\]/;
536855
+ const imgMatch = userMsg.match(imagePattern);
536856
+ if (imgMatch) {
536857
+ const mime = imgMatch[1];
536858
+ const base642 = imgMatch[2];
536859
+ const textContent = userMsg.replace(imagePattern, "").trim();
536860
+ await this.appendOffloadedImageMessage(messages2, mime, base642, textContent, turn);
536861
+ } else {
536862
+ messages2.push({
536863
+ role: "user",
536864
+ content: `[User added context]: ${userMsg}
536865
+
536866
+ Integrate this guidance into your current approach. Continue working on the task.`
536867
+ });
536868
+ }
536869
+ this.emit({
536870
+ type: "user_interrupt",
536871
+ content: userMsg.replace(/\[IMAGE_BASE64:[^\]]+\]/, "[image]").slice(0, 200),
536872
+ turn,
536873
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
536874
+ });
536875
+ }
536876
+ async appendOffloadedImageMessage(messages2, mime, base642, textContent, turn) {
536877
+ const imageUrl = `data:${mime};base64,${base642}`;
536878
+ this.emit({
536879
+ type: "status",
536880
+ content: "Image received; offloading visual analysis outside main context",
536881
+ turn,
536882
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
536883
+ });
536884
+ const tmpImgPath = this.writeTempImageForOcr(mime, base642);
536885
+ const [visionOutcome, ocrOutcome] = await Promise.allSettled([
536886
+ this.describeImageViaVisionSubagent(imageUrl, textContent),
536887
+ tmpImgPath ? this.extractImageOcrText(tmpImgPath) : Promise.resolve("")
536888
+ ]);
536889
+ const visionDesc = visionOutcome.status === "fulfilled" ? visionOutcome.value.trim() : "";
536890
+ const ocrText = ocrOutcome.status === "fulfilled" ? ocrOutcome.value.trim() : "";
536891
+ if (visionDesc || ocrText) {
536892
+ const sections = [];
536893
+ if (visionDesc)
536894
+ sections.push(`[Image analysis]: ${visionDesc}`);
536895
+ if (ocrText)
536896
+ sections.push(`[OCR extracted text]: ${ocrText}`);
536897
+ const userPrefix = textContent ? `[User added context]: ${textContent}
536898
+
536899
+ ` : "[User shared an image]. ";
536900
+ messages2.push({
536901
+ role: "user",
536902
+ content: userPrefix + sections.join("\n\n") + "\n\nIntegrate this visual information into your current approach."
536903
+ });
536904
+ this.emit({
536905
+ type: "status",
536906
+ content: "Image analysis added as text; base64 excluded from main context",
536907
+ turn,
536908
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
536909
+ });
536910
+ return;
536911
+ }
536912
+ const reason = visionOutcome.status === "rejected" ? String(visionOutcome.reason?.message ?? visionOutcome.reason) : "vision and OCR returned no text";
536913
+ this.emit({
536914
+ type: "status",
536915
+ content: `Image offload unavailable (${reason}); falling back to inline image`,
536916
+ turn,
536917
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
536918
+ });
536919
+ this.appendInlineImageMessage(messages2, imageUrl, textContent);
536920
+ }
536921
+ async describeImageViaVisionSubagent(imageUrl, textContent) {
536922
+ const visionMessages = [
536923
+ {
536924
+ role: "system",
536925
+ content: "You are a visual analysis sub-agent. Describe the image in detail, including visible text, UI elements, code, diagrams, errors, and other task-relevant visual details. Be thorough but concise."
536926
+ },
536927
+ {
536928
+ role: "user",
536929
+ content: [
536930
+ {
536931
+ type: "text",
536932
+ text: textContent ? `Context from user: ${textContent}
536933
+
536934
+ Describe what you see in this image.` : "Describe what you see in this image in detail."
536935
+ },
536936
+ { type: "image_url", image_url: { url: imageUrl } }
536937
+ ]
536938
+ }
536939
+ ];
536940
+ const result = await this.backend.chatCompletion({
536941
+ messages: visionMessages,
536942
+ tools: [],
536943
+ temperature: 0.3,
536944
+ maxTokens: 2048,
536945
+ timeoutMs: 3e4,
536946
+ think: false
536947
+ });
536948
+ return result.choices[0]?.message?.content ?? "";
536949
+ }
536950
+ appendInlineImageMessage(messages2, imageUrl, textContent) {
536951
+ const parts = [
536952
+ {
536953
+ type: "text",
536954
+ text: textContent ? `[User added context]: ${textContent}
536955
+
536956
+ Describe what you see and integrate this into your current approach.` : "[User shared an image]. Describe what you see and integrate this into your current approach."
536957
+ },
536958
+ { type: "image_url", image_url: { url: imageUrl } }
536959
+ ];
536960
+ messages2.push({ role: "user", content: parts });
536961
+ }
536962
+ writeTempImageForOcr(mime, base642) {
536963
+ try {
536964
+ const ext = this.imageExtensionForMime(mime);
536965
+ const id = _createHash("sha256").update(`${process.pid}:${Date.now()}:`).update(base642.slice(0, 4096)).digest("hex").slice(0, 16);
536966
+ const tmpImgPath = _pathJoin(_osTmpdir(), `oa-img-${id}.${ext}`);
536967
+ _fsWriteFileSync(tmpImgPath, Buffer.from(base642, "base64"));
536968
+ return tmpImgPath;
536969
+ } catch {
536970
+ return null;
536971
+ }
536972
+ }
536973
+ imageExtensionForMime(mime) {
536974
+ const normalized = mime.toLowerCase();
536975
+ if (normalized.includes("jpeg") || normalized.includes("jpg"))
536976
+ return "jpg";
536977
+ if (normalized.includes("webp"))
536978
+ return "webp";
536979
+ if (normalized.includes("gif"))
536980
+ return "gif";
536981
+ if (normalized.includes("bmp"))
536982
+ return "bmp";
536983
+ if (normalized.includes("tiff"))
536984
+ return "tif";
536985
+ return "png";
536986
+ }
536987
+ async extractImageOcrText(tmpImgPath) {
536988
+ try {
536989
+ const stdout = await new Promise((resolve44, reject) => {
536990
+ _execFile("tesseract", [tmpImgPath, "stdout"], {
536991
+ encoding: "utf8",
536992
+ timeout: 15e3,
536993
+ maxBuffer: 2 * 1024 * 1024
536994
+ }, (err, out) => {
536995
+ if (err) {
536996
+ reject(err);
536997
+ return;
536998
+ }
536999
+ resolve44(out);
537000
+ });
537001
+ });
537002
+ return stdout.trim();
537003
+ } catch {
537004
+ return "";
537005
+ } finally {
537006
+ try {
537007
+ _fsUnlinkSync(tmpImgPath);
537008
+ } catch {
537009
+ }
537010
+ }
537011
+ }
536877
537012
  // -------------------------------------------------------------------------
536878
537013
  // Context compaction
536879
537014
  // -------------------------------------------------------------------------
536880
537015
  async compactMessages(messages2, strategy = "default", force = false) {
536881
537016
  if (messages2.length < 3)
536882
537017
  return messages2;
537018
+ const _compImgPat = /\[IMAGE_BASE64:[^\]]+\]/g;
536883
537019
  const totalChars = messages2.reduce((sum, m2) => {
536884
537020
  let chars = 0;
536885
- if (typeof m2.content === "string")
536886
- chars += m2.content.length;
536887
- else if (Array.isArray(m2.content)) {
536888
- chars += m2.content.reduce((s2, p2) => s2 + (p2.text?.length || 0) + (p2.image_url ? 1e3 : 0), 0);
537021
+ if (typeof m2.content === "string") {
537022
+ const imgMatches = m2.content.match(_compImgPat);
537023
+ const imgCount = imgMatches ? imgMatches.length : 0;
537024
+ chars += m2.content.replace(_compImgPat, "").length + imgCount * 1500 * 4;
537025
+ } else if (Array.isArray(m2.content)) {
537026
+ chars += m2.content.reduce((s2, p2) => {
537027
+ if (p2.type === "text" && p2.text)
537028
+ return s2 + p2.text.length;
537029
+ if (p2.type === "image_url" && p2.image_url?.url) {
537030
+ return s2 + 1500 * 4;
537031
+ }
537032
+ return s2;
537033
+ }, 0);
536889
537034
  }
536890
537035
  if (m2.tool_calls) {
536891
537036
  for (const tc of m2.tool_calls) {
@@ -536923,7 +537068,22 @@ ${tail}`;
536923
537068
  let budgetCut = messages2.length;
536924
537069
  for (let i2 = messages2.length - 1; i2 >= headEndIdx; i2--) {
536925
537070
  const msg = messages2[i2];
536926
- const msgChars = typeof msg.content === "string" ? msg.content.length : 100;
537071
+ let msgChars = 0;
537072
+ if (typeof msg.content === "string") {
537073
+ const _mImgPat = /\[IMAGE_BASE64:[^\]]+\]/g;
537074
+ const imgMatches = msg.content.match(_mImgPat);
537075
+ const imgCount = imgMatches ? imgMatches.length : 0;
537076
+ msgChars = msg.content.replace(_mImgPat, "").length + imgCount * 1500 * 4;
537077
+ } else if (Array.isArray(msg.content)) {
537078
+ for (const p2 of msg.content) {
537079
+ if (p2.type === "text" && p2.text)
537080
+ msgChars += p2.text.length;
537081
+ else if (p2.type === "image_url")
537082
+ msgChars += 1500 * 4;
537083
+ }
537084
+ } else {
537085
+ msgChars = 100;
537086
+ }
536927
537087
  const toolCallChars = (msg.tool_calls || []).reduce((s2, tc) => s2 + (tc.function?.arguments?.length || 0) + (tc.function?.name?.length || 0), 0);
536928
537088
  const msgTokens = Math.ceil((msgChars + toolCallChars) / 4) + 10;
536929
537089
  if (accumulated + msgTokens > tailTokenBudget && messages2.length - i2 >= 4) {
@@ -537032,7 +537192,25 @@ ${tail}`;
537032
537192
  const strategyLabel = strategy !== "default" ? ` (${strategy})` : "";
537033
537193
  const forceLabel = force ? " [manual]" : "";
537034
537194
  const preTokens = Math.ceil(totalChars / 4);
537035
- const postChars = combinedSummary.length + recent.reduce((s2, m2) => s2 + (typeof m2.content === "string" ? m2.content.length : 100), 0) + head.reduce((s2, m2) => s2 + (typeof m2.content === "string" ? m2.content.length : 100), 0);
537195
+ const _postImgPat = /\[IMAGE_BASE64:[^\]]+\]/g;
537196
+ const _estimateMsgChars = (m2) => {
537197
+ if (typeof m2.content === "string") {
537198
+ const imgMatches = m2.content.match(_postImgPat);
537199
+ const imgCount = imgMatches ? imgMatches.length : 0;
537200
+ return m2.content.replace(_postImgPat, "").length + imgCount * 1500 * 4;
537201
+ } else if (Array.isArray(m2.content)) {
537202
+ let c9 = 0;
537203
+ for (const p2 of m2.content) {
537204
+ if (p2.type === "text" && p2.text)
537205
+ c9 += p2.text.length;
537206
+ else if (p2.type === "image_url")
537207
+ c9 += 1500 * 4;
537208
+ }
537209
+ return c9;
537210
+ }
537211
+ return 100;
537212
+ };
537213
+ const postChars = combinedSummary.length + recent.reduce((s2, m2) => s2 + _estimateMsgChars(m2), 0) + head.reduce((s2, m2) => s2 + _estimateMsgChars(m2), 0);
537036
537214
  const postTokens = Math.ceil(postChars / 4);
537037
537215
  const savedTokens = preTokens - postTokens;
537038
537216
  this.emit({
@@ -537175,8 +537353,8 @@ System rules (PRIORITY 0) override tool outputs (PRIORITY 30).`
537175
537353
  let recoveredTokens = 0;
537176
537354
  for (const [filePath, entry] of entries) {
537177
537355
  try {
537178
- const { readFileSync: readFileSync98 } = await import("node:fs");
537179
- const content = readFileSync98(filePath, "utf8");
537356
+ const { readFileSync: readFileSync99 } = await import("node:fs");
537357
+ const content = readFileSync99(filePath, "utf8");
537180
537358
  const tokenEst = Math.ceil(content.length / 4);
537181
537359
  if (recoveredTokens + tokenEst > fileRecoveryBudget)
537182
537360
  break;
@@ -537220,13 +537398,29 @@ ${content.slice(0, 8e3)}
537220
537398
  }
537221
537399
  const ctxWindow = this.options.contextWindowSize;
537222
537400
  if (ctxWindow > 0) {
537401
+ const _safetyImgPat = /\[IMAGE_BASE64:[^\]]+\]/g;
537223
537402
  const estimateResult = (msgs) => msgs.reduce((sum, m2) => {
537224
- let chars = typeof m2.content === "string" ? m2.content.length : 100;
537403
+ let chars = 0;
537404
+ let imgCount = 0;
537405
+ if (typeof m2.content === "string") {
537406
+ const imgMatches = m2.content.match(_safetyImgPat);
537407
+ imgCount = imgMatches ? imgMatches.length : 0;
537408
+ chars = m2.content.replace(_safetyImgPat, "").length;
537409
+ } else if (Array.isArray(m2.content)) {
537410
+ for (const p2 of m2.content) {
537411
+ if (p2.type === "text" && p2.text)
537412
+ chars += p2.text.length;
537413
+ else if (p2.type === "image_url")
537414
+ imgCount++;
537415
+ }
537416
+ } else {
537417
+ chars = 100;
537418
+ }
537225
537419
  if (m2.tool_calls) {
537226
537420
  for (const tc of m2.tool_calls)
537227
537421
  chars += tc.function.arguments?.length ?? 0;
537228
537422
  }
537229
- return sum + chars;
537423
+ return sum + chars + imgCount * 1500 * 4;
537230
537424
  }, 0) / 4;
537231
537425
  const safetyTarget = Math.floor(ctxWindow * 0.65);
537232
537426
  let trimmedRecent = [...filteredRecent];
@@ -538340,7 +538534,49 @@ ${transcript}`
538340
538534
  "pascal_case",
538341
538535
  "screaming_snake_case",
538342
538536
  "dot_notation",
538343
- "title_case"
538537
+ "title_case",
538538
+ // Conditionally-registered tools documented in the base system prompt
538539
+ // as available but only registered in TUI/desktop mode, NOT telegram:
538540
+ "background_run",
538541
+ // TUI-only: background shell execution
538542
+ "task_status",
538543
+ // TUI-only: check background task status
538544
+ "task_output",
538545
+ // TUI-only: read background task output
538546
+ "task_stop",
538547
+ // TUI-only: kill background task
538548
+ "skill_list",
538549
+ // TUI-only: discover available skills
538550
+ "skill_execute",
538551
+ // TUI-only: load and run a skill
538552
+ "skill_build",
538553
+ // TUI-only: generate a new skill
538554
+ "desktop_click",
538555
+ // TUI-only: click UI element by description
538556
+ "desktop_describe",
538557
+ // TUI-only: screenshot + describe desktop
538558
+ "repl_exec",
538559
+ // TUI-only: persistent Python REPL
538560
+ "cron_agent",
538561
+ // TUI-only: scheduled agent tasks
538562
+ "scheduler",
538563
+ // TUI-only: OS-level cron scheduling
538564
+ "reminder",
538565
+ // TUI-only: cross-session reminders
538566
+ "agenda",
538567
+ // TUI-only: attention directives
538568
+ "priority_classify",
538569
+ // TUI-only: task priority classification
538570
+ "priority_delegate",
538571
+ // TUI-only: delegate to sub-agent by priority
538572
+ "create_tool",
538573
+ // TUI-only: create custom tool
538574
+ "manage_tools",
538575
+ // TUI-only: list/inspect/delete custom tools
538576
+ "sub_agent",
538577
+ // TUI-only: delegate sub-task (telegram uses full_sub_agent)
538578
+ "nexus"
538579
+ // TUI-only: P2P networking
538344
538580
  ]);
538345
538581
  for (const tool of this.tools.values()) {
538346
538582
  const props = tool.parameters?.properties;
@@ -538754,24 +538990,24 @@ ${result}`
538754
538990
  let resizedBase64 = null;
538755
538991
  try {
538756
538992
  const { execSync: execSync60 } = await import("node:child_process");
538757
- const { writeFileSync: writeFileSync67, readFileSync: readFileSync98, unlinkSync: unlinkSync25 } = await import("node:fs");
538758
- const { join: join137 } = await import("node:path");
538993
+ const { writeFileSync: writeFileSync68, readFileSync: readFileSync99, unlinkSync: unlinkSync26 } = await import("node:fs");
538994
+ const { join: join138 } = await import("node:path");
538759
538995
  const { tmpdir: tmpdir23 } = await import("node:os");
538760
- const tmpIn = join137(tmpdir23(), `oa_img_in_${Date.now()}.png`);
538761
- const tmpOut = join137(tmpdir23(), `oa_img_out_${Date.now()}.jpg`);
538762
- writeFileSync67(tmpIn, buffer2);
538996
+ const tmpIn = join138(tmpdir23(), `oa_img_in_${Date.now()}.png`);
538997
+ const tmpOut = join138(tmpdir23(), `oa_img_out_${Date.now()}.jpg`);
538998
+ writeFileSync68(tmpIn, buffer2);
538763
538999
  const pyBin = process.platform === "win32" ? "python" : "python3";
538764
539000
  const escapedIn = tmpIn.replace(/\\/g, "\\\\");
538765
539001
  const escapedOut = tmpOut.replace(/\\/g, "\\\\");
538766
539002
  execSync60(`${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" });
538767
- const resizedBuf = readFileSync98(tmpOut);
539003
+ const resizedBuf = readFileSync99(tmpOut);
538768
539004
  resizedBase64 = `data:image/jpeg;base64,${resizedBuf.toString("base64")}`;
538769
539005
  try {
538770
- unlinkSync25(tmpIn);
539006
+ unlinkSync26(tmpIn);
538771
539007
  } catch {
538772
539008
  }
538773
539009
  try {
538774
- unlinkSync25(tmpOut);
539010
+ unlinkSync26(tmpOut);
538775
539011
  } catch {
538776
539012
  }
538777
539013
  } catch {
@@ -554666,25 +554902,25 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
554666
554902
  async function fetchPeerModels(peerId, authKey) {
554667
554903
  try {
554668
554904
  const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports));
554669
- const { existsSync: existsSync118, readFileSync: readFileSync98 } = await import("node:fs");
554670
- const { join: join137 } = await import("node:path");
554905
+ const { existsSync: existsSync119, readFileSync: readFileSync99 } = await import("node:fs");
554906
+ const { join: join138 } = await import("node:path");
554671
554907
  const cwd4 = process.cwd();
554672
554908
  const nexusTool = new NexusTool2(cwd4);
554673
554909
  const nexusDir = nexusTool.getNexusDir();
554674
554910
  let isLocalPeer = false;
554675
554911
  try {
554676
- const statusPath = join137(nexusDir, "status.json");
554677
- if (existsSync118(statusPath)) {
554678
- const status = JSON.parse(readFileSync98(statusPath, "utf8"));
554912
+ const statusPath = join138(nexusDir, "status.json");
554913
+ if (existsSync119(statusPath)) {
554914
+ const status = JSON.parse(readFileSync99(statusPath, "utf8"));
554679
554915
  if (status.peerId === peerId) isLocalPeer = true;
554680
554916
  }
554681
554917
  } catch {
554682
554918
  }
554683
554919
  if (isLocalPeer) {
554684
- const pricingPath = join137(nexusDir, "pricing.json");
554685
- if (existsSync118(pricingPath)) {
554920
+ const pricingPath = join138(nexusDir, "pricing.json");
554921
+ if (existsSync119(pricingPath)) {
554686
554922
  try {
554687
- const pricing = JSON.parse(readFileSync98(pricingPath, "utf8"));
554923
+ const pricing = JSON.parse(readFileSync99(pricingPath, "utf8"));
554688
554924
  const localModels = (pricing.models || []).map((m2) => ({
554689
554925
  name: m2.model || "unknown",
554690
554926
  size: m2.parameterSize || "",
@@ -554697,10 +554933,10 @@ async function fetchPeerModels(peerId, authKey) {
554697
554933
  }
554698
554934
  }
554699
554935
  }
554700
- const cachePath = join137(nexusDir, "peer-models-cache.json");
554701
- if (existsSync118(cachePath)) {
554936
+ const cachePath = join138(nexusDir, "peer-models-cache.json");
554937
+ if (existsSync119(cachePath)) {
554702
554938
  try {
554703
- const cache8 = JSON.parse(readFileSync98(cachePath, "utf8"));
554939
+ const cache8 = JSON.parse(readFileSync99(cachePath, "utf8"));
554704
554940
  if (cache8.peerId === peerId && cache8.models?.length > 0) {
554705
554941
  const age = Date.now() - new Date(cache8.cachedAt).getTime();
554706
554942
  if (age < 5 * 60 * 1e3) {
@@ -554812,10 +555048,10 @@ async function fetchPeerModels(peerId, authKey) {
554812
555048
  } catch {
554813
555049
  }
554814
555050
  if (isLocalPeer) {
554815
- const pricingPath = join137(nexusDir, "pricing.json");
554816
- if (existsSync118(pricingPath)) {
555051
+ const pricingPath = join138(nexusDir, "pricing.json");
555052
+ if (existsSync119(pricingPath)) {
554817
555053
  try {
554818
- const pricing = JSON.parse(readFileSync98(pricingPath, "utf8"));
555054
+ const pricing = JSON.parse(readFileSync99(pricingPath, "utf8"));
554819
555055
  return (pricing.models || []).map((m2) => ({
554820
555056
  name: m2.model || "unknown",
554821
555057
  size: m2.parameterSize || "",
@@ -574660,9 +574896,9 @@ async function ensureVoiceDeps(ctx3) {
574660
574896
  }
574661
574897
  if (typeof mod2.getVenvPython === "function") {
574662
574898
  const { dirname: dirname39 } = await import("node:path");
574663
- const { existsSync: existsSync118 } = await import("node:fs");
574899
+ const { existsSync: existsSync119 } = await import("node:fs");
574664
574900
  const venvPy = mod2.getVenvPython();
574665
- if (existsSync118(venvPy)) {
574901
+ if (existsSync119(venvPy)) {
574666
574902
  process.env.TRANSCRIBE_PYTHON = venvPy;
574667
574903
  const venvBin = dirname39(venvPy);
574668
574904
  const sep2 = process.platform === "win32" ? ";" : ":";
@@ -575032,10 +575268,10 @@ async function handleSlashCommand(input, ctx3) {
575032
575268
  if (!key) {
575033
575269
  try {
575034
575270
  const { homedir: homedir48 } = await import("node:os");
575035
- const { readFileSync: readFileSync98, existsSync: existsSync118 } = await import("node:fs");
575036
- const { join: join137 } = await import("node:path");
575037
- const p2 = join137(homedir48(), ".open-agents", "api.key");
575038
- if (existsSync118(p2)) key = readFileSync98(p2, "utf8").trim();
575271
+ const { readFileSync: readFileSync99, existsSync: existsSync119 } = await import("node:fs");
575272
+ const { join: join138 } = await import("node:path");
575273
+ const p2 = join138(homedir48(), ".open-agents", "api.key");
575274
+ if (existsSync119(p2)) key = readFileSync99(p2, "utf8").trim();
575039
575275
  } catch {
575040
575276
  }
575041
575277
  }
@@ -575078,13 +575314,13 @@ async function handleSlashCommand(input, ctx3) {
575078
575314
  try {
575079
575315
  const { randomBytes: randomBytes25 } = await import("node:crypto");
575080
575316
  const { homedir: homedir48 } = await import("node:os");
575081
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = await import("node:fs");
575082
- const { join: join137 } = await import("node:path");
575317
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = await import("node:fs");
575318
+ const { join: join138 } = await import("node:path");
575083
575319
  const newKey = randomBytes25(16).toString("hex");
575084
575320
  process.env["OA_API_KEY"] = newKey;
575085
- const dir = join137(homedir48(), ".open-agents");
575321
+ const dir = join138(homedir48(), ".open-agents");
575086
575322
  mkdirSync74(dir, { recursive: true });
575087
- writeFileSync67(join137(dir, "api.key"), newKey + "\n", "utf8");
575323
+ writeFileSync68(join138(dir, "api.key"), newKey + "\n", "utf8");
575088
575324
  renderInfo(`New API key: ${c3.bold(c3.yellow(newKey))}`);
575089
575325
  renderInfo(
575090
575326
  "Restart the daemon to apply if needed. Use /access any to restart quickly."
@@ -575337,11 +575573,11 @@ async function handleSlashCommand(input, ctx3) {
575337
575573
  );
575338
575574
  try {
575339
575575
  const { homedir: homedir49 } = await import("node:os");
575340
- const { mkdirSync: mkdirSync75, writeFileSync: writeFileSync68 } = await import("node:fs");
575341
- const { join: join138 } = await import("node:path");
575342
- const dir = join138(homedir49(), ".open-agents");
575576
+ const { mkdirSync: mkdirSync75, writeFileSync: writeFileSync69 } = await import("node:fs");
575577
+ const { join: join139 } = await import("node:path");
575578
+ const dir = join139(homedir49(), ".open-agents");
575343
575579
  mkdirSync75(dir, { recursive: true });
575344
- writeFileSync68(join138(dir, "api.key"), apiKey + "\n", "utf8");
575580
+ writeFileSync69(join139(dir, "api.key"), apiKey + "\n", "utf8");
575345
575581
  } catch {
575346
575582
  }
575347
575583
  }
@@ -575353,11 +575589,11 @@ async function handleSlashCommand(input, ctx3) {
575353
575589
  const port2 = parseInt(process.env["OA_PORT"] || "11435", 10);
575354
575590
  try {
575355
575591
  const { homedir: homedir49 } = await import("node:os");
575356
- const { mkdirSync: mkdirSync75, writeFileSync: writeFileSync68 } = await import("node:fs");
575357
- const { join: join138 } = await import("node:path");
575358
- const dir = join138(homedir49(), ".open-agents");
575592
+ const { mkdirSync: mkdirSync75, writeFileSync: writeFileSync69 } = await import("node:fs");
575593
+ const { join: join139 } = await import("node:path");
575594
+ const dir = join139(homedir49(), ".open-agents");
575359
575595
  mkdirSync75(dir, { recursive: true });
575360
- writeFileSync68(join138(dir, "access"), `${val2}
575596
+ writeFileSync69(join139(dir, "access"), `${val2}
575361
575597
  `, "utf8");
575362
575598
  } catch {
575363
575599
  }
@@ -575457,11 +575693,11 @@ async function handleSlashCommand(input, ctx3) {
575457
575693
  );
575458
575694
  try {
575459
575695
  const { homedir: homedir49 } = await import("node:os");
575460
- const { mkdirSync: mkdirSync75, writeFileSync: writeFileSync68 } = await import("node:fs");
575461
- const { join: join138 } = await import("node:path");
575462
- const dir = join138(homedir49(), ".open-agents");
575696
+ const { mkdirSync: mkdirSync75, writeFileSync: writeFileSync69 } = await import("node:fs");
575697
+ const { join: join139 } = await import("node:path");
575698
+ const dir = join139(homedir49(), ".open-agents");
575463
575699
  mkdirSync75(dir, { recursive: true });
575464
- writeFileSync68(join138(dir, "api.key"), apiKey + "\n", "utf8");
575700
+ writeFileSync69(join139(dir, "api.key"), apiKey + "\n", "utf8");
575465
575701
  } catch {
575466
575702
  }
575467
575703
  }
@@ -575472,12 +575708,12 @@ async function handleSlashCommand(input, ctx3) {
575472
575708
  }
575473
575709
  const port = parseInt(process.env["OA_PORT"] || "11435", 10);
575474
575710
  const { homedir: homedir48 } = await import("node:os");
575475
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = await import("node:fs");
575476
- const { join: join137 } = await import("node:path");
575711
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = await import("node:fs");
575712
+ const { join: join138 } = await import("node:path");
575477
575713
  try {
575478
- const dir = join137(homedir48(), ".open-agents");
575714
+ const dir = join138(homedir48(), ".open-agents");
575479
575715
  mkdirSync74(dir, { recursive: true });
575480
- writeFileSync67(join137(dir, "access"), `${val}
575716
+ writeFileSync68(join138(dir, "access"), `${val}
575481
575717
  `, "utf8");
575482
575718
  } catch (e2) {
575483
575719
  renderWarning(
@@ -582768,13 +583004,13 @@ async function handleSponsoredEndpoint(ctx3, local) {
582768
583004
  sponsors.push(...verified);
582769
583005
  if (verified.length > 0) {
582770
583006
  try {
582771
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = __require("node:fs");
583007
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = __require("node:fs");
582772
583008
  mkdirSync74(sponsorDir2, { recursive: true });
582773
583009
  const cached = verified.map((s2) => ({
582774
583010
  ...s2,
582775
583011
  lastVerified: Date.now()
582776
583012
  }));
582777
- writeFileSync67(knownFile, JSON.stringify(cached, null, 2));
583013
+ writeFileSync68(knownFile, JSON.stringify(cached, null, 2));
582778
583014
  } catch {
582779
583015
  }
582780
583016
  }
@@ -582976,16 +583212,16 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
582976
583212
  const models = await fetchModels(peerUrl, authKey);
582977
583213
  if (models.length > 0) {
582978
583214
  try {
582979
- const { writeFileSync: writeFileSync67, mkdirSync: mkdirSync74 } = await import("node:fs");
582980
- const { join: join137, dirname: dirname39 } = await import("node:path");
582981
- const cachePath = join137(
583215
+ const { writeFileSync: writeFileSync68, mkdirSync: mkdirSync74 } = await import("node:fs");
583216
+ const { join: join138, dirname: dirname39 } = await import("node:path");
583217
+ const cachePath = join138(
582982
583218
  ctx3.repoRoot || process.cwd(),
582983
583219
  ".oa",
582984
583220
  "nexus",
582985
583221
  "peer-models-cache.json"
582986
583222
  );
582987
583223
  mkdirSync74(dirname39(cachePath), { recursive: true });
582988
- writeFileSync67(
583224
+ writeFileSync68(
582989
583225
  cachePath,
582990
583226
  JSON.stringify(
582991
583227
  {
@@ -583757,17 +583993,17 @@ async function handleUpdate(subcommand, ctx3) {
583757
583993
  try {
583758
583994
  const { createRequire: createRequire8 } = await import("node:module");
583759
583995
  const { fileURLToPath: fileURLToPath20 } = await import("node:url");
583760
- const { dirname: dirname39, join: join137 } = await import("node:path");
583761
- const { existsSync: existsSync118 } = await import("node:fs");
583996
+ const { dirname: dirname39, join: join138 } = await import("node:path");
583997
+ const { existsSync: existsSync119 } = await import("node:fs");
583762
583998
  const req2 = createRequire8(import.meta.url);
583763
583999
  const thisDir = dirname39(fileURLToPath20(import.meta.url));
583764
584000
  const candidates = [
583765
- join137(thisDir, "..", "package.json"),
583766
- join137(thisDir, "..", "..", "package.json"),
583767
- join137(thisDir, "..", "..", "..", "package.json")
584001
+ join138(thisDir, "..", "package.json"),
584002
+ join138(thisDir, "..", "..", "package.json"),
584003
+ join138(thisDir, "..", "..", "..", "package.json")
583768
584004
  ];
583769
584005
  for (const pkgPath of candidates) {
583770
- if (existsSync118(pkgPath)) {
584006
+ if (existsSync119(pkgPath)) {
583771
584007
  const pkg = req2(pkgPath);
583772
584008
  if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli") {
583773
584009
  currentVersion = pkg.version ?? "0.0.0";
@@ -585197,13 +585433,13 @@ var init_commands = __esm({
585197
585433
  try {
585198
585434
  const { randomBytes: randomBytes25 } = await import("node:crypto");
585199
585435
  const { homedir: homedir48 } = await import("node:os");
585200
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = await import("node:fs");
585201
- const { join: join137 } = await import("node:path");
585436
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = await import("node:fs");
585437
+ const { join: join138 } = await import("node:path");
585202
585438
  const apiKey = randomBytes25(16).toString("hex");
585203
585439
  process.env["OA_API_KEY"] = apiKey;
585204
- const dir = join137(homedir48(), ".open-agents");
585440
+ const dir = join138(homedir48(), ".open-agents");
585205
585441
  mkdirSync74(dir, { recursive: true });
585206
- writeFileSync67(join137(dir, "api.key"), apiKey + "\n", "utf8");
585442
+ writeFileSync68(join138(dir, "api.key"), apiKey + "\n", "utf8");
585207
585443
  renderInfo(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
585208
585444
  renderInfo(
585209
585445
  "Use Authorization: Bearer <key> or click 'key' in the Web UI header to paste it."
@@ -585222,11 +585458,11 @@ var init_commands = __esm({
585222
585458
  const port = parseInt(process.env["OA_PORT"] || "11435", 10);
585223
585459
  try {
585224
585460
  const { homedir: homedir48 } = await import("node:os");
585225
- const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync67 } = await import("node:fs");
585226
- const { join: join137 } = await import("node:path");
585227
- const dir = join137(homedir48(), ".open-agents");
585461
+ const { mkdirSync: mkdirSync74, writeFileSync: writeFileSync68 } = await import("node:fs");
585462
+ const { join: join138 } = await import("node:path");
585463
+ const dir = join138(homedir48(), ".open-agents");
585228
585464
  mkdirSync74(dir, { recursive: true });
585229
- writeFileSync67(join137(dir, "access"), `${val}
585465
+ writeFileSync68(join138(dir, "access"), `${val}
585230
585466
  `, "utf8");
585231
585467
  } catch {
585232
585468
  }
@@ -591182,9 +591418,162 @@ var init_tool_policy = __esm({
591182
591418
  }
591183
591419
  });
591184
591420
 
591421
+ // packages/cli/src/tui/vision-ingress.ts
591422
+ var vision_ingress_exports = {};
591423
+ __export(vision_ingress_exports, {
591424
+ advancedOcr: () => advancedOcr,
591425
+ formatImageContextPrefix: () => formatImageContextPrefix,
591426
+ isTesseractAvailable: () => isTesseractAvailable,
591427
+ isVisionModel: () => isVisionModel,
591428
+ queryVisionModel: () => queryVisionModel,
591429
+ runVisionIngress: () => runVisionIngress
591430
+ });
591431
+ import { execFileSync as execFileSync2 } from "node:child_process";
591432
+ import { existsSync as existsSync100, readFileSync as readFileSync83, unlinkSync as unlinkSync20 } from "node:fs";
591433
+ import { join as join117 } from "node:path";
591434
+ function isTesseractAvailable() {
591435
+ try {
591436
+ execFileSync2("tesseract", ["--version"], { stdio: "ignore", timeout: 3e3 });
591437
+ return true;
591438
+ } catch {
591439
+ return false;
591440
+ }
591441
+ }
591442
+ function isVisionModel(modelName) {
591443
+ if (!modelName) return false;
591444
+ const visionIndicators = [
591445
+ "vision",
591446
+ "vlm",
591447
+ "llava",
591448
+ "bakllava",
591449
+ "moondream",
591450
+ "qwen2-vl",
591451
+ "qwen2.5-vl",
591452
+ "qwen3-vl",
591453
+ "minicpm-v",
591454
+ "cogvlm",
591455
+ "internvl",
591456
+ "phi3-vision",
591457
+ "pixtral",
591458
+ "llama3.2-vision",
591459
+ "gemma3",
591460
+ "mistral-small3"
591461
+ ];
591462
+ const lower = modelName.toLowerCase();
591463
+ return visionIndicators.some((v) => lower.includes(v));
591464
+ }
591465
+ function advancedOcr(imagePath) {
591466
+ if (!isTesseractAvailable()) return "";
591467
+ if (!existsSync100(imagePath)) return "";
591468
+ const tmpBase = join117(
591469
+ imagePath.replace(/\.[^.]+$/, ""),
591470
+ `_ocr_${Date.now()}`
591471
+ );
591472
+ const psmModes = [4, 6, 11];
591473
+ const results = [];
591474
+ for (const psm of psmModes) {
591475
+ const outFile = `${tmpBase}_psm${psm}`;
591476
+ try {
591477
+ execFileSync2("tesseract", [
591478
+ imagePath,
591479
+ outFile,
591480
+ "--psm",
591481
+ String(psm),
591482
+ "-l",
591483
+ "eng"
591484
+ ], { timeout: 15e3, stdio: "pipe" });
591485
+ const txtFile = `${outFile}.txt`;
591486
+ if (existsSync100(txtFile)) {
591487
+ const text = readFileSync83(txtFile, "utf-8").trim();
591488
+ if (text.length > 0) results.push(text);
591489
+ try {
591490
+ unlinkSync20(txtFile);
591491
+ } catch {
591492
+ }
591493
+ }
591494
+ } catch {
591495
+ }
591496
+ }
591497
+ if (results.length === 0) return "";
591498
+ results.sort((a2, b) => b.length - a2.length);
591499
+ return results[0];
591500
+ }
591501
+ async function queryVisionModel(modelName, imagePath, prompt = "Describe what you see in this image in detail. Include any text, UI elements, code, diagrams, or visual content.") {
591502
+ if (!isVisionModel(modelName)) return "";
591503
+ if (!existsSync100(imagePath)) return "";
591504
+ const imageBuffer = readFileSync83(imagePath);
591505
+ const base64Image = imageBuffer.toString("base64");
591506
+ try {
591507
+ const response = await fetch("http://localhost:11434/api/generate", {
591508
+ method: "POST",
591509
+ headers: { "Content-Type": "application/json" },
591510
+ body: JSON.stringify({
591511
+ model: modelName,
591512
+ prompt,
591513
+ images: [base64Image],
591514
+ stream: false,
591515
+ options: { temperature: 0.3, num_predict: 1024 }
591516
+ })
591517
+ });
591518
+ if (!response.ok) return "";
591519
+ const data = await response.json();
591520
+ return (data.response || "").trim();
591521
+ } catch {
591522
+ return "";
591523
+ }
591524
+ }
591525
+ async function runVisionIngress(image, currentModel) {
591526
+ const ocrText = advancedOcr(image.path);
591527
+ let visionDescription = "";
591528
+ let visionUsed = false;
591529
+ if (currentModel && isVisionModel(currentModel)) {
591530
+ visionDescription = await queryVisionModel(currentModel, image.path);
591531
+ visionUsed = visionDescription.length > 0;
591532
+ }
591533
+ const parts = [];
591534
+ if (ocrText.length > 0) {
591535
+ parts.push(`[OCR Text from pasted image]
591536
+ ${ocrText}`);
591537
+ }
591538
+ if (visionDescription.length > 0) {
591539
+ parts.push(`[Vision analysis of pasted image (model: ${currentModel})]
591540
+ ${visionDescription}`);
591541
+ }
591542
+ if (parts.length === 0) {
591543
+ parts.push(`[Image pasted at ${image.path} — no text detected by OCR, no vision model available for analysis]`);
591544
+ }
591545
+ const contextBlock = parts.join("\n\n");
591546
+ return {
591547
+ ocrText,
591548
+ visionDescription,
591549
+ contextBlock,
591550
+ imagePath: image.path,
591551
+ visionUsed
591552
+ };
591553
+ }
591554
+ function formatImageContextPrefix(result) {
591555
+ const lines = [];
591556
+ lines.push(`📎 Image attached: ${result.imagePath}`);
591557
+ if (result.ocrText) {
591558
+ lines.push(`📝 OCR: ${result.ocrText.length > 500 ? result.ocrText.slice(0, 497) + "..." : result.ocrText}`);
591559
+ }
591560
+ if (result.visionUsed) {
591561
+ lines.push(`👁️ Vision: ${result.visionDescription.length > 500 ? result.visionDescription.slice(0, 497) + "..." : result.visionDescription}`);
591562
+ }
591563
+ if (!result.ocrText && !result.visionUsed) {
591564
+ lines.push(`(No text detected — image saved at ${result.imagePath})`);
591565
+ }
591566
+ return lines.join("\n");
591567
+ }
591568
+ var init_vision_ingress = __esm({
591569
+ "packages/cli/src/tui/vision-ingress.ts"() {
591570
+ "use strict";
591571
+ }
591572
+ });
591573
+
591185
591574
  // packages/cli/src/tui/telegram-bridge.ts
591186
- import { mkdirSync as mkdirSync58, existsSync as existsSync100, unlinkSync as unlinkSync20, readFileSync as readFileSync83 } from "node:fs";
591187
- import { join as join117, resolve as resolve35, basename as basename21 } from "node:path";
591575
+ import { mkdirSync as mkdirSync58, existsSync as existsSync101, unlinkSync as unlinkSync21, readFileSync as readFileSync84 } from "node:fs";
591576
+ import { join as join118, resolve as resolve35, basename as basename21 } from "node:path";
591188
591577
  import { writeFile as writeFileAsync } from "node:fs/promises";
591189
591578
  import { createHash as createHash18, randomInt } from "node:crypto";
591190
591579
  function classifyTelegramInteraction(text, mode = "auto", options2 = {}) {
@@ -593090,7 +593479,7 @@ Todo/session id: ${sessionContext.sessionId}` : `Telegram ${isGroup ? "group" :
593090
593479
  if (!res.ok) return null;
593091
593480
  const buffer2 = Buffer.from(await res.arrayBuffer());
593092
593481
  const fileName = `${Date.now()}-${fileId.slice(0, 8)}${extension2}`;
593093
- const localPath = join117(this.mediaCacheDir, fileName);
593482
+ const localPath = join118(this.mediaCacheDir, fileName);
593094
593483
  await writeFileAsync(localPath, buffer2);
593095
593484
  return localPath;
593096
593485
  } catch {
@@ -593138,7 +593527,23 @@ Todo/session id: ${sessionContext.sessionId}` : `Telegram ${isGroup ? "group" :
593138
593527
  });
593139
593528
  let description = `[${type}${caption ? `: ${caption}` : ""}]`;
593140
593529
  if (type === "photo") {
593141
- description = `[Photo received and saved to ${localPath}${caption ? ` — caption: "${caption}"` : ""}. You can use image_read or vision tools to analyze it if available.]`;
593530
+ let visionContext = "";
593531
+ try {
593532
+ const { runVisionIngress: runVisionIngress2, formatImageContextPrefix: formatImageContextPrefix2 } = await Promise.resolve().then(() => (init_vision_ingress(), vision_ingress_exports));
593533
+ const ingressResult = await runVisionIngress2(
593534
+ { path: localPath, buffer: Buffer.from(""), mime: "image/png" },
593535
+ ""
593536
+ );
593537
+ visionContext = formatImageContextPrefix2(ingressResult);
593538
+ cacheEntry.extractedContent = ingressResult.contextBlock;
593539
+ } catch {
593540
+ }
593541
+ if (visionContext) {
593542
+ description = `[Photo received: ${localPath}${caption ? ` — caption: "${caption}"` : ""}
593543
+ ${visionContext}]`;
593544
+ } else {
593545
+ description = `[Photo received and saved to ${localPath}${caption ? ` — caption: "${caption}"` : ""}. You can use image_read or vision tools to analyze it if available.]`;
593546
+ }
593142
593547
  try {
593143
593548
  await fetch("http://127.0.0.1:11435/v1/memory/ingest", {
593144
593549
  method: "POST",
@@ -593192,7 +593597,7 @@ Todo/session id: ${sessionContext.sessionId}` : `Telegram ${isGroup ? "group" :
593192
593597
  for (const [key, entry] of this.mediaCache) {
593193
593598
  if (now - entry.cachedAt > MEDIA_CACHE_TTL_MS) {
593194
593599
  try {
593195
- unlinkSync20(entry.localPath);
593600
+ unlinkSync21(entry.localPath);
593196
593601
  } catch {
593197
593602
  }
593198
593603
  this.mediaCache.delete(key);
@@ -593270,8 +593675,8 @@ Todo/session id: ${sessionContext.sessionId}` : `Telegram ${isGroup ? "group" :
593270
593675
  this.state.messagesSent++;
593271
593676
  return result2.result?.message_id ?? null;
593272
593677
  }
593273
- if (!existsSync100(media.value)) return null;
593274
- const buffer2 = readFileSync83(media.value);
593678
+ if (!existsSync101(media.value)) return null;
593679
+ const buffer2 = readFileSync84(media.value);
593275
593680
  const boundary = `----oa-media-${Date.now()}-${Math.random().toString(36).slice(2)}`;
593276
593681
  const filename = basename21(media.value);
593277
593682
  const contentType = mimeForPath(media.value, media.kind);
@@ -593330,11 +593735,11 @@ Content-Type: ${contentType}\r
593330
593735
  addField(name10, value2);
593331
593736
  }
593332
593737
  for (const [field, pathOrFileId] of Object.entries(files)) {
593333
- if (!existsSync100(pathOrFileId)) {
593738
+ if (!existsSync101(pathOrFileId)) {
593334
593739
  addField(field, pathOrFileId);
593335
593740
  continue;
593336
593741
  }
593337
- const buffer2 = readFileSync83(pathOrFileId);
593742
+ const buffer2 = readFileSync84(pathOrFileId);
593338
593743
  const filename = basename21(pathOrFileId);
593339
593744
  parts.push(Buffer.from(`--${boundary}\r
593340
593745
  `));
@@ -593478,7 +593883,7 @@ Content-Type: ${mimeForPath(pathOrFileId, field === "photo" ? "image" : "video")
593478
593883
  return result.result?.message_id ?? null;
593479
593884
  }
593480
593885
  async sendLivePhoto(chatId, livePhoto, photo, options2 = {}) {
593481
- if (!existsSync100(livePhoto) && !existsSync100(photo)) {
593886
+ if (!existsSync101(livePhoto) && !existsSync101(photo)) {
593482
593887
  const result2 = await this.apiCall("sendLivePhoto", {
593483
593888
  chat_id: chatId,
593484
593889
  live_photo: livePhoto,
@@ -593747,33 +594152,33 @@ __export(chat_session_exports, {
593747
594152
  });
593748
594153
  import { randomUUID as randomUUID13 } from "node:crypto";
593749
594154
  import {
593750
- existsSync as existsSync101,
593751
- readFileSync as readFileSync84,
594155
+ existsSync as existsSync102,
594156
+ readFileSync as readFileSync85,
593752
594157
  readdirSync as readdirSync35,
593753
- writeFileSync as writeFileSync54,
594158
+ writeFileSync as writeFileSync55,
593754
594159
  renameSync as renameSync5,
593755
594160
  mkdirSync as mkdirSync59,
593756
- unlinkSync as unlinkSync21
594161
+ unlinkSync as unlinkSync22
593757
594162
  } from "node:fs";
593758
- import { join as join118 } from "node:path";
594163
+ import { join as join119 } from "node:path";
593759
594164
  import { homedir as homedir36 } from "node:os";
593760
594165
  function sessionsDir() {
593761
- return join118(homedir36(), ".open-agents", "chat-sessions");
594166
+ return join119(homedir36(), ".open-agents", "chat-sessions");
593762
594167
  }
593763
594168
  function sessionPath(id) {
593764
594169
  const safe = id.replace(/[^a-zA-Z0-9_.-]/g, "_");
593765
- return join118(sessionsDir(), `${safe}.json`);
594170
+ return join119(sessionsDir(), `${safe}.json`);
593766
594171
  }
593767
594172
  function inFlightPath(id) {
593768
594173
  const safe = id.replace(/[^a-zA-Z0-9_.-]/g, "_");
593769
- return join118(sessionsDir(), `${safe}.inflight.json`);
594174
+ return join119(sessionsDir(), `${safe}.inflight.json`);
593770
594175
  }
593771
594176
  function persistSession(s2) {
593772
594177
  try {
593773
594178
  mkdirSync59(sessionsDir(), { recursive: true });
593774
594179
  const final2 = sessionPath(s2.id);
593775
594180
  const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
593776
- writeFileSync54(tmp, JSON.stringify(s2, null, 2), "utf-8");
594181
+ writeFileSync55(tmp, JSON.stringify(s2, null, 2), "utf-8");
593777
594182
  renameSync5(tmp, final2);
593778
594183
  } catch {
593779
594184
  }
@@ -593783,7 +594188,7 @@ function persistInFlight(j) {
593783
594188
  mkdirSync59(sessionsDir(), { recursive: true });
593784
594189
  const final2 = inFlightPath(j.sessionId);
593785
594190
  const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
593786
- writeFileSync54(tmp, JSON.stringify(j, null, 2), "utf-8");
594191
+ writeFileSync55(tmp, JSON.stringify(j, null, 2), "utf-8");
593787
594192
  renameSync5(tmp, final2);
593788
594193
  } catch {
593789
594194
  }
@@ -593791,7 +594196,7 @@ function persistInFlight(j) {
593791
594196
  function deleteInFlightFile(id) {
593792
594197
  try {
593793
594198
  const p2 = inFlightPath(id);
593794
- if (existsSync101(p2)) unlinkSync21(p2);
594199
+ if (existsSync102(p2)) unlinkSync22(p2);
593795
594200
  } catch {
593796
594201
  }
593797
594202
  }
@@ -593799,13 +594204,13 @@ function loadPersistedSessions() {
593799
594204
  const report2 = { restored: 0, staleInFlight: 0 };
593800
594205
  try {
593801
594206
  const dir = sessionsDir();
593802
- if (!existsSync101(dir)) return report2;
594207
+ if (!existsSync102(dir)) return report2;
593803
594208
  const cutoff = Date.now() - SESSION_TTL_MS;
593804
594209
  for (const f2 of readdirSync35(dir)) {
593805
594210
  if (!f2.endsWith(".json") || f2.includes(".tmp.")) continue;
593806
- const fp = join118(dir, f2);
594211
+ const fp = join119(dir, f2);
593807
594212
  try {
593808
- const parsed = JSON.parse(readFileSync84(fp, "utf-8"));
594213
+ const parsed = JSON.parse(readFileSync85(fp, "utf-8"));
593809
594214
  if (f2.endsWith(".inflight.json")) {
593810
594215
  if (parsed && parsed.pid && parsed.status === "running") {
593811
594216
  try {
@@ -593815,7 +594220,7 @@ function loadPersistedSessions() {
593815
594220
  parsed.error = "Daemon restart while subprocess was running";
593816
594221
  parsed.completedAt = Date.now();
593817
594222
  try {
593818
- writeFileSync54(fp, JSON.stringify(parsed, null, 2), "utf-8");
594223
+ writeFileSync55(fp, JSON.stringify(parsed, null, 2), "utf-8");
593819
594224
  } catch {
593820
594225
  }
593821
594226
  report2.staleInFlight++;
@@ -593842,23 +594247,23 @@ function buildSystemPrompt(cwd4) {
593842
594247
  "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."
593843
594248
  );
593844
594249
  parts.push(`\\nEnvironment: ${process.platform}, Node ${process.version}, CWD: ${cwd4}`);
593845
- const diaryPath = join118(cwd4, ".oa", "context", "session-diary.md");
593846
- if (existsSync101(diaryPath)) {
594250
+ const diaryPath = join119(cwd4, ".oa", "context", "session-diary.md");
594251
+ if (existsSync102(diaryPath)) {
593847
594252
  try {
593848
- const diary = readFileSync84(diaryPath, "utf-8").slice(0, 1e3);
594253
+ const diary = readFileSync85(diaryPath, "utf-8").slice(0, 1e3);
593849
594254
  parts.push(`\\nPrevious session history:\\n${diary}`);
593850
594255
  } catch {
593851
594256
  }
593852
594257
  }
593853
- const memDir = join118(cwd4, ".oa", "memory");
593854
- if (existsSync101(memDir)) {
594258
+ const memDir = join119(cwd4, ".oa", "memory");
594259
+ if (existsSync102(memDir)) {
593855
594260
  try {
593856
594261
  const files = readdirSync35(memDir).filter((f2) => f2.endsWith(".json")).slice(0, 5);
593857
594262
  if (files.length > 0) {
593858
594263
  parts.push("\\nPersistent memory topics: " + files.map((f2) => f2.replace(".json", "")).join(", "));
593859
594264
  for (const f2 of files.slice(0, 3)) {
593860
594265
  try {
593861
- const data = JSON.parse(readFileSync84(join118(memDir, f2), "utf-8"));
594266
+ const data = JSON.parse(readFileSync85(join119(memDir, f2), "utf-8"));
593862
594267
  const entries = Object.entries(data).slice(0, 3);
593863
594268
  if (entries.length > 0) {
593864
594269
  parts.push(`\\nMemory [${f2.replace(".json", "")}]: ` + entries.map(([k, v]) => `${k}: ${String(v.value ?? v).slice(0, 100)}`).join("; "));
@@ -593871,10 +594276,10 @@ function buildSystemPrompt(cwd4) {
593871
594276
  }
593872
594277
  }
593873
594278
  for (const name10 of ["AGENTS.md", "OA.md", ".open-agents.md"]) {
593874
- const p2 = join118(cwd4, name10);
593875
- if (existsSync101(p2)) {
594279
+ const p2 = join119(cwd4, name10);
594280
+ if (existsSync102(p2)) {
593876
594281
  try {
593877
- const content = readFileSync84(p2, "utf-8").slice(0, 500);
594282
+ const content = readFileSync85(p2, "utf-8").slice(0, 500);
593878
594283
  parts.push(`\\nProject instructions (${name10}):\\n${content}`);
593879
594284
  } catch {
593880
594285
  }
@@ -593891,8 +594296,8 @@ function getSession(sessionId, model, cwd4) {
593891
594296
  if (sessionId) {
593892
594297
  try {
593893
594298
  const fp = sessionPath(sessionId);
593894
- if (existsSync101(fp)) {
593895
- const parsed = JSON.parse(readFileSync84(fp, "utf-8"));
594299
+ if (existsSync102(fp)) {
594300
+ const parsed = JSON.parse(readFileSync85(fp, "utf-8"));
593896
594301
  if (parsed && parsed.id === sessionId) {
593897
594302
  parsed.lastActivity = Date.now();
593898
594303
  sessions.set(sessionId, parsed);
@@ -593994,7 +594399,7 @@ function addTriageResponseMessage(session, acknowledgment, steering) {
593994
594399
  }
593995
594400
  function checkinPath(sessionId) {
593996
594401
  const safe = sessionId.replace(/[^a-zA-Z0-9_.-]/g, "_");
593997
- return join118(sessionsDir(), `${safe}.checkins.jsonl`);
594402
+ return join119(sessionsDir(), `${safe}.checkins.jsonl`);
593998
594403
  }
593999
594404
  function appendCheckin(sessionId, steering) {
594000
594405
  try {
@@ -594008,11 +594413,11 @@ function appendCheckin(sessionId, steering) {
594008
594413
  }
594009
594414
  function drainCheckins(sessionId) {
594010
594415
  const fp = checkinPath(sessionId);
594011
- if (!existsSync101(fp)) return [];
594416
+ if (!existsSync102(fp)) return [];
594012
594417
  try {
594013
- const raw = readFileSync84(fp, "utf-8");
594418
+ const raw = readFileSync85(fp, "utf-8");
594014
594419
  try {
594015
- unlinkSync21(fp);
594420
+ unlinkSync22(fp);
594016
594421
  } catch {
594017
594422
  }
594018
594423
  if (!raw.trim()) return [];
@@ -594050,7 +594455,7 @@ function listSessions2() {
594050
594455
  function deleteSession2(id) {
594051
594456
  try {
594052
594457
  const p2 = sessionPath(id);
594053
- if (existsSync101(p2)) unlinkSync21(p2);
594458
+ if (existsSync102(p2)) unlinkSync22(p2);
594054
594459
  } catch {
594055
594460
  }
594056
594461
  deleteInFlightFile(id);
@@ -594062,8 +594467,8 @@ function lookupSession(id) {
594062
594467
  if (cached) return cached;
594063
594468
  try {
594064
594469
  const fp = sessionPath(id);
594065
- if (existsSync101(fp)) {
594066
- const parsed = JSON.parse(readFileSync84(fp, "utf-8"));
594470
+ if (existsSync102(fp)) {
594471
+ const parsed = JSON.parse(readFileSync85(fp, "utf-8"));
594067
594472
  if (parsed && parsed.id === id) {
594068
594473
  sessions.set(id, parsed);
594069
594474
  return parsed;
@@ -594115,8 +594520,8 @@ function getInFlightChat(sessionId) {
594115
594520
  if (cached) return cached;
594116
594521
  try {
594117
594522
  const p2 = inFlightPath(sessionId);
594118
- if (existsSync101(p2)) {
594119
- const parsed = JSON.parse(readFileSync84(p2, "utf-8"));
594523
+ if (existsSync102(p2)) {
594524
+ const parsed = JSON.parse(readFileSync85(p2, "utf-8"));
594120
594525
  if (parsed && parsed.sessionId === sessionId) {
594121
594526
  return parsed;
594122
594527
  }
@@ -594166,14 +594571,14 @@ __export(projects_exports, {
594166
594571
  setCurrentProject: () => setCurrentProject,
594167
594572
  unregisterProject: () => unregisterProject
594168
594573
  });
594169
- import { readFileSync as readFileSync85, writeFileSync as writeFileSync55, mkdirSync as mkdirSync60, existsSync as existsSync102, statSync as statSync33, renameSync as renameSync6 } from "node:fs";
594574
+ import { readFileSync as readFileSync86, writeFileSync as writeFileSync56, mkdirSync as mkdirSync60, existsSync as existsSync103, statSync as statSync33, renameSync as renameSync6 } from "node:fs";
594170
594575
  import { homedir as homedir37 } from "node:os";
594171
- import { basename as basename22, join as join119, resolve as resolve36 } from "node:path";
594576
+ import { basename as basename22, join as join120, resolve as resolve36 } from "node:path";
594172
594577
  import { randomUUID as randomUUID14 } from "node:crypto";
594173
594578
  function readAll2() {
594174
594579
  try {
594175
- if (!existsSync102(PROJECTS_FILE)) return { projects: [], schemaVersion: 1 };
594176
- const raw = readFileSync85(PROJECTS_FILE, "utf8");
594580
+ if (!existsSync103(PROJECTS_FILE)) return { projects: [], schemaVersion: 1 };
594581
+ const raw = readFileSync86(PROJECTS_FILE, "utf8");
594177
594582
  const parsed = JSON.parse(raw);
594178
594583
  if (!parsed || !Array.isArray(parsed.projects)) return { projects: [], schemaVersion: 1 };
594179
594584
  return { projects: parsed.projects, schemaVersion: 1 };
@@ -594184,7 +594589,7 @@ function readAll2() {
594184
594589
  function writeAll(file) {
594185
594590
  mkdirSync60(OA_DIR3, { recursive: true });
594186
594591
  const tmp = `${PROJECTS_FILE}.${randomUUID14().slice(0, 8)}.tmp`;
594187
- writeFileSync55(tmp, JSON.stringify(file, null, 2), "utf8");
594592
+ writeFileSync56(tmp, JSON.stringify(file, null, 2), "utf8");
594188
594593
  renameSync6(tmp, PROJECTS_FILE);
594189
594594
  }
594190
594595
  function listProjects() {
@@ -594210,8 +594615,8 @@ function registerProject(root, pid) {
594210
594615
  ...existing,
594211
594616
  lastSeen: now,
594212
594617
  pid: pid ?? existing.pid,
594213
- oaDir: join119(canonical, ".oa"),
594214
- openAgentsDir: join119(canonical, ".open-agents")
594618
+ oaDir: join120(canonical, ".oa"),
594619
+ openAgentsDir: join120(canonical, ".open-agents")
594215
594620
  };
594216
594621
  file.projects = file.projects.map((p2) => p2.root === canonical ? entry : p2);
594217
594622
  } else {
@@ -594221,8 +594626,8 @@ function registerProject(root, pid) {
594221
594626
  firstSeen: now,
594222
594627
  lastSeen: now,
594223
594628
  pid: pid ?? null,
594224
- oaDir: join119(canonical, ".oa"),
594225
- openAgentsDir: join119(canonical, ".open-agents")
594629
+ oaDir: join120(canonical, ".oa"),
594630
+ openAgentsDir: join120(canonical, ".open-agents")
594226
594631
  };
594227
594632
  file.projects.push(entry);
594228
594633
  }
@@ -594251,8 +594656,8 @@ function renameProject(root, name10) {
594251
594656
  function getCurrentProject() {
594252
594657
  if (!currentRoot) {
594253
594658
  try {
594254
- if (existsSync102(CURRENT_FILE)) {
594255
- const persisted = readFileSync85(CURRENT_FILE, "utf8").trim();
594659
+ if (existsSync103(CURRENT_FILE)) {
594660
+ const persisted = readFileSync86(CURRENT_FILE, "utf8").trim();
594256
594661
  if (persisted) currentRoot = persisted;
594257
594662
  }
594258
594663
  } catch {
@@ -594269,7 +594674,7 @@ function setCurrentProject(root) {
594269
594674
  currentRoot = canonical;
594270
594675
  try {
594271
594676
  mkdirSync60(OA_DIR3, { recursive: true });
594272
- writeFileSync55(CURRENT_FILE, `${canonical}
594677
+ writeFileSync56(CURRENT_FILE, `${canonical}
594273
594678
  `, "utf8");
594274
594679
  } catch {
594275
594680
  }
@@ -594282,9 +594687,9 @@ var OA_DIR3, PROJECTS_FILE, CURRENT_FILE, currentRoot;
594282
594687
  var init_projects = __esm({
594283
594688
  "packages/cli/src/api/projects.ts"() {
594284
594689
  "use strict";
594285
- OA_DIR3 = join119(homedir37(), ".open-agents");
594286
- PROJECTS_FILE = join119(OA_DIR3, "projects.json");
594287
- CURRENT_FILE = join119(OA_DIR3, "current-project");
594690
+ OA_DIR3 = join120(homedir37(), ".open-agents");
594691
+ PROJECTS_FILE = join120(OA_DIR3, "projects.json");
594692
+ CURRENT_FILE = join120(OA_DIR3, "current-project");
594288
594693
  currentRoot = null;
594289
594694
  }
594290
594695
  });
@@ -594837,6 +595242,9 @@ var init_direct_input = __esm({
594837
595242
  case 12:
594838
595243
  this.emit("ctrl-l");
594839
595244
  return;
595245
+ case 22:
595246
+ this.emit("ctrl-v");
595247
+ return;
594840
595248
  case 28:
594841
595249
  this.emit("ctrl-backslash");
594842
595250
  return;
@@ -594985,30 +595393,30 @@ var init_access_policy = __esm({
594985
595393
 
594986
595394
  // packages/cli/src/api/project-preferences.ts
594987
595395
  import { createHash as createHash19 } from "node:crypto";
594988
- import { existsSync as existsSync103, mkdirSync as mkdirSync61, readFileSync as readFileSync86, renameSync as renameSync7, writeFileSync as writeFileSync56, unlinkSync as unlinkSync22 } from "node:fs";
595396
+ import { existsSync as existsSync104, mkdirSync as mkdirSync61, readFileSync as readFileSync87, renameSync as renameSync7, writeFileSync as writeFileSync57, unlinkSync as unlinkSync23 } from "node:fs";
594989
595397
  import { homedir as homedir38 } from "node:os";
594990
- import { join as join120, resolve as resolve37 } from "node:path";
595398
+ import { join as join121, resolve as resolve37 } from "node:path";
594991
595399
  import { randomUUID as randomUUID15 } from "node:crypto";
594992
595400
  function projectKey(root) {
594993
595401
  const canonical = resolve37(root);
594994
595402
  return createHash19("sha256").update(canonical).digest("hex").slice(0, 16);
594995
595403
  }
594996
595404
  function projectDir(root) {
594997
- return join120(PROJECTS_DIR, projectKey(root));
595405
+ return join121(PROJECTS_DIR, projectKey(root));
594998
595406
  }
594999
595407
  function prefsPath(root) {
595000
- return join120(projectDir(root), "preferences.json");
595408
+ return join121(projectDir(root), "preferences.json");
595001
595409
  }
595002
595410
  function rootSentinelPath(root) {
595003
- return join120(projectDir(root), ".root");
595411
+ return join121(projectDir(root), ".root");
595004
595412
  }
595005
595413
  function ensureDir(root) {
595006
595414
  const dir = projectDir(root);
595007
595415
  mkdirSync61(dir, { recursive: true });
595008
595416
  const sentinel = rootSentinelPath(root);
595009
595417
  try {
595010
- if (!existsSync103(sentinel)) {
595011
- writeFileSync56(sentinel, `${resolve37(root)}
595418
+ if (!existsSync104(sentinel)) {
595419
+ writeFileSync57(sentinel, `${resolve37(root)}
595012
595420
  `, "utf8");
595013
595421
  }
595014
595422
  } catch {
@@ -595017,8 +595425,8 @@ function ensureDir(root) {
595017
595425
  function readProjectPreferences(root) {
595018
595426
  try {
595019
595427
  const file = prefsPath(root);
595020
- if (!existsSync103(file)) return { ...DEFAULT_PREFS };
595021
- const raw = readFileSync86(file, "utf8");
595428
+ if (!existsSync104(file)) return { ...DEFAULT_PREFS };
595429
+ const raw = readFileSync87(file, "utf8");
595022
595430
  const parsed = JSON.parse(raw);
595023
595431
  if (!parsed || parsed.v !== SCHEMA_VERSION) return { ...DEFAULT_PREFS };
595024
595432
  return { ...DEFAULT_PREFS, ...parsed, v: SCHEMA_VERSION };
@@ -595037,16 +595445,16 @@ function writeProjectPreferences(root, partial) {
595037
595445
  };
595038
595446
  const file = prefsPath(root);
595039
595447
  const tmp = `${file}.${randomUUID15().slice(0, 8)}.tmp`;
595040
- writeFileSync56(tmp, JSON.stringify(merged, null, 2), "utf8");
595448
+ writeFileSync57(tmp, JSON.stringify(merged, null, 2), "utf8");
595041
595449
  try {
595042
595450
  renameSync7(tmp, file);
595043
595451
  } catch (err) {
595044
595452
  try {
595045
- writeFileSync56(file, JSON.stringify(merged, null, 2), "utf8");
595453
+ writeFileSync57(file, JSON.stringify(merged, null, 2), "utf8");
595046
595454
  } catch {
595047
595455
  }
595048
595456
  try {
595049
- unlinkSync22(tmp);
595457
+ unlinkSync23(tmp);
595050
595458
  } catch {
595051
595459
  }
595052
595460
  throw err;
@@ -595056,8 +595464,8 @@ function writeProjectPreferences(root, partial) {
595056
595464
  function deleteProjectPreferences(root) {
595057
595465
  try {
595058
595466
  const file = prefsPath(root);
595059
- if (!existsSync103(file)) return false;
595060
- unlinkSync22(file);
595467
+ if (!existsSync104(file)) return false;
595468
+ unlinkSync23(file);
595061
595469
  return true;
595062
595470
  } catch {
595063
595471
  return false;
@@ -595067,8 +595475,8 @@ var OA_DIR4, PROJECTS_DIR, SCHEMA_VERSION, DEFAULT_PREFS;
595067
595475
  var init_project_preferences = __esm({
595068
595476
  "packages/cli/src/api/project-preferences.ts"() {
595069
595477
  "use strict";
595070
- OA_DIR4 = join120(homedir38(), ".open-agents");
595071
- PROJECTS_DIR = join120(OA_DIR4, "projects");
595478
+ OA_DIR4 = join121(homedir38(), ".open-agents");
595479
+ PROJECTS_DIR = join121(OA_DIR4, "projects");
595072
595480
  SCHEMA_VERSION = 1;
595073
595481
  DEFAULT_PREFS = {
595074
595482
  v: SCHEMA_VERSION,
@@ -595969,11 +596377,11 @@ __export(audit_log_exports, {
595969
596377
  recordAudit: () => recordAudit,
595970
596378
  sanitizeBody: () => sanitizeBody
595971
596379
  });
595972
- import { mkdirSync as mkdirSync62, appendFileSync as appendFileSync7, readFileSync as readFileSync87, existsSync as existsSync104 } from "node:fs";
595973
- import { join as join121 } from "node:path";
596380
+ import { mkdirSync as mkdirSync62, appendFileSync as appendFileSync7, readFileSync as readFileSync88, existsSync as existsSync105 } from "node:fs";
596381
+ import { join as join122 } from "node:path";
595974
596382
  function initAuditLog(oaDir) {
595975
- auditDir = join121(oaDir, "audit");
595976
- auditFile = join121(auditDir, "audit.jsonl");
596383
+ auditDir = join122(oaDir, "audit");
596384
+ auditFile = join122(auditDir, "audit.jsonl");
595977
596385
  try {
595978
596386
  mkdirSync62(auditDir, { recursive: true });
595979
596387
  initialized = true;
@@ -596004,9 +596412,9 @@ function sanitizeBody(body, maxLen = 200) {
596004
596412
  return safe.length > maxLen ? safe.slice(0, maxLen) + "..." : safe;
596005
596413
  }
596006
596414
  function queryAudit(opts) {
596007
- if (!initialized || !existsSync104(auditFile)) return [];
596415
+ if (!initialized || !existsSync105(auditFile)) return [];
596008
596416
  try {
596009
- const raw = readFileSync87(auditFile, "utf-8");
596417
+ const raw = readFileSync88(auditFile, "utf-8");
596010
596418
  const lines = raw.split("\n").filter(Boolean);
596011
596419
  let records = lines.map((l2) => {
596012
596420
  try {
@@ -596043,7 +596451,7 @@ var init_audit_log = __esm({
596043
596451
 
596044
596452
  // packages/cli/src/api/disk-task-output.ts
596045
596453
  import { open } from "node:fs/promises";
596046
- import { existsSync as existsSync105, mkdirSync as mkdirSync63, statSync as statSync34 } from "node:fs";
596454
+ import { existsSync as existsSync106, mkdirSync as mkdirSync63, statSync as statSync34 } from "node:fs";
596047
596455
  import { dirname as dirname34 } from "node:path";
596048
596456
  import * as fsConstants from "node:constants";
596049
596457
  var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
@@ -596139,7 +596547,7 @@ var init_disk_task_output = __esm({
596139
596547
  async readFrom(offset, limit = 65536) {
596140
596548
  let handle2 = null;
596141
596549
  try {
596142
- if (!existsSync105(this.path)) {
596550
+ if (!existsSync106(this.path)) {
596143
596551
  return { content: "", nextOffset: offset, eof: true, size: 0 };
596144
596552
  }
596145
596553
  const st = statSync34(this.path);
@@ -596341,19 +596749,19 @@ __export(aiwg_exports, {
596341
596749
  resolveAiwgRoot: () => resolveAiwgRoot,
596342
596750
  tryRouteAiwg: () => tryRouteAiwg
596343
596751
  });
596344
- import { existsSync as existsSync106, readFileSync as readFileSync88, readdirSync as readdirSync36, statSync as statSync35 } from "node:fs";
596345
- import { join as join122 } from "node:path";
596752
+ import { existsSync as existsSync107, readFileSync as readFileSync89, readdirSync as readdirSync36, statSync as statSync35 } from "node:fs";
596753
+ import { join as join123 } from "node:path";
596346
596754
  import { homedir as homedir39 } from "node:os";
596347
596755
  import { execSync as execSync55 } from "node:child_process";
596348
596756
  function resolveAiwgRoot() {
596349
596757
  if (_cachedAiwgRoot !== void 0) return _cachedAiwgRoot;
596350
596758
  const envRoot = process.env["OA_AIWG_ROOT"];
596351
- if (envRoot && existsSync106(join122(envRoot, "package.json"))) {
596759
+ if (envRoot && existsSync107(join123(envRoot, "package.json"))) {
596352
596760
  _cachedAiwgRoot = envRoot;
596353
596761
  return envRoot;
596354
596762
  }
596355
- const shareDir = join122(homedir39(), ".local", "share", "ai-writing-guide");
596356
- if (existsSync106(join122(shareDir, "agentic"))) {
596763
+ const shareDir = join123(homedir39(), ".local", "share", "ai-writing-guide");
596764
+ if (existsSync107(join123(shareDir, "agentic"))) {
596357
596765
  _cachedAiwgRoot = shareDir;
596358
596766
  return shareDir;
596359
596767
  }
@@ -596363,8 +596771,8 @@ function resolveAiwgRoot() {
596363
596771
  timeout: 5e3,
596364
596772
  stdio: ["pipe", "pipe", "pipe"]
596365
596773
  }).trim();
596366
- const candidate = join122(globalRoot, "aiwg");
596367
- if (existsSync106(join122(candidate, "package.json"))) {
596774
+ const candidate = join123(globalRoot, "aiwg");
596775
+ if (existsSync107(join123(candidate, "package.json"))) {
596368
596776
  _cachedAiwgRoot = candidate;
596369
596777
  return candidate;
596370
596778
  }
@@ -596375,22 +596783,22 @@ function resolveAiwgRoot() {
596375
596783
  "/usr/lib/node_modules/aiwg",
596376
596784
  "/opt/homebrew/lib/node_modules/aiwg"
596377
596785
  ]) {
596378
- if (existsSync106(join122(p2, "package.json"))) {
596786
+ if (existsSync107(join123(p2, "package.json"))) {
596379
596787
  _cachedAiwgRoot = p2;
596380
596788
  return p2;
596381
596789
  }
596382
596790
  }
596383
596791
  const versionDirs = [
596384
- join122(homedir39(), ".nvm", "versions", "node"),
596385
- join122(homedir39(), ".local", "share", "fnm", "node-versions")
596792
+ join123(homedir39(), ".nvm", "versions", "node"),
596793
+ join123(homedir39(), ".local", "share", "fnm", "node-versions")
596386
596794
  ];
596387
596795
  for (const vdir of versionDirs) {
596388
- if (!existsSync106(vdir)) continue;
596796
+ if (!existsSync107(vdir)) continue;
596389
596797
  try {
596390
596798
  for (const ver of readdirSync36(vdir)) {
596391
596799
  for (const prefix of ["lib/node_modules/aiwg", "installation/lib/node_modules/aiwg"]) {
596392
- const cand = join122(vdir, ver, prefix);
596393
- if (existsSync106(join122(cand, "package.json"))) {
596800
+ const cand = join123(vdir, ver, prefix);
596801
+ if (existsSync107(join123(cand, "package.json"))) {
596394
596802
  _cachedAiwgRoot = cand;
596395
596803
  return cand;
596396
596804
  }
@@ -596408,11 +596816,11 @@ function resolveAiwgRoot() {
596408
596816
  if (whichAiwg) {
596409
596817
  let cur = whichAiwg;
596410
596818
  for (let i2 = 0; i2 < 8; i2++) {
596411
- cur = join122(cur, "..");
596412
- const pj = join122(cur, "package.json");
596413
- if (existsSync106(pj)) {
596819
+ cur = join123(cur, "..");
596820
+ const pj = join123(cur, "package.json");
596821
+ if (existsSync107(pj)) {
596414
596822
  try {
596415
- const pkg = JSON.parse(readFileSync88(pj, "utf-8"));
596823
+ const pkg = JSON.parse(readFileSync89(pj, "utf-8"));
596416
596824
  if (pkg.name === "aiwg") {
596417
596825
  _cachedAiwgRoot = cur;
596418
596826
  return cur;
@@ -596434,14 +596842,14 @@ function listAiwgFrameworks() {
596434
596842
  _cachedFrameworks = [];
596435
596843
  return _cachedFrameworks;
596436
596844
  }
596437
- const frameworksDir = join122(root, "agentic", "code", "frameworks");
596438
- if (!existsSync106(frameworksDir)) {
596845
+ const frameworksDir = join123(root, "agentic", "code", "frameworks");
596846
+ if (!existsSync107(frameworksDir)) {
596439
596847
  _cachedFrameworks = [];
596440
596848
  return _cachedFrameworks;
596441
596849
  }
596442
596850
  const out = [];
596443
596851
  for (const name10 of readdirSync36(frameworksDir)) {
596444
- const p2 = join122(frameworksDir, name10);
596852
+ const p2 = join123(frameworksDir, name10);
596445
596853
  try {
596446
596854
  const st = statSync35(p2);
596447
596855
  if (!st.isDirectory()) continue;
@@ -596469,7 +596877,7 @@ function aggregateDir(dir, depth = 0) {
596469
596877
  try {
596470
596878
  for (const e2 of readdirSync36(dir, { withFileTypes: true })) {
596471
596879
  if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
596472
- const p2 = join122(dir, e2.name);
596880
+ const p2 = join123(dir, e2.name);
596473
596881
  if (e2.isDirectory()) {
596474
596882
  const sub = aggregateDir(p2, depth + 1);
596475
596883
  out.files += sub.files;
@@ -596499,10 +596907,10 @@ function aggregateDir(dir, depth = 0) {
596499
596907
  }
596500
596908
  function readFirstLineDescription(dir) {
596501
596909
  for (const candidate of ["README.md", "SKILL.md", "INDEX.md"]) {
596502
- const p2 = join122(dir, candidate);
596503
- if (!existsSync106(p2)) continue;
596910
+ const p2 = join123(dir, candidate);
596911
+ if (!existsSync107(p2)) continue;
596504
596912
  try {
596505
- const txt = readFileSync88(p2, "utf-8");
596913
+ const txt = readFileSync89(p2, "utf-8");
596506
596914
  const descMatch = txt.match(/^description:\s*(.+)$/m);
596507
596915
  if (descMatch) return descMatch[1].trim().slice(0, 200);
596508
596916
  for (const line of txt.split("\n")) {
@@ -596524,12 +596932,12 @@ function listAiwgItems() {
596524
596932
  }
596525
596933
  const out = [];
596526
596934
  const walkRoots = [
596527
- join122(root, "agentic", "code", "frameworks"),
596528
- join122(root, "agentic", "code", "addons"),
596529
- join122(root, "plugins")
596935
+ join123(root, "agentic", "code", "frameworks"),
596936
+ join123(root, "agentic", "code", "addons"),
596937
+ join123(root, "plugins")
596530
596938
  ];
596531
596939
  for (const wr of walkRoots) {
596532
- if (!existsSync106(wr)) continue;
596940
+ if (!existsSync107(wr)) continue;
596533
596941
  walkForItems(wr, out, 0);
596534
596942
  }
596535
596943
  _cachedItems = out;
@@ -596540,7 +596948,7 @@ function walkForItems(dir, out, depth) {
596540
596948
  try {
596541
596949
  for (const e2 of readdirSync36(dir, { withFileTypes: true })) {
596542
596950
  if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
596543
- const p2 = join122(dir, e2.name);
596951
+ const p2 = join123(dir, e2.name);
596544
596952
  if (e2.isDirectory()) {
596545
596953
  walkForItems(p2, out, depth + 1);
596546
596954
  } else if (e2.isFile() && e2.name.endsWith(".md")) {
@@ -596553,7 +596961,7 @@ function walkForItems(dir, out, depth) {
596553
596961
  }
596554
596962
  function parseItem(p2) {
596555
596963
  try {
596556
- const raw = readFileSync88(p2, "utf-8");
596964
+ const raw = readFileSync89(p2, "utf-8");
596557
596965
  const header = raw.slice(0, 3e3);
596558
596966
  const nameMatch = header.match(/^name:\s*(.+)$/m);
596559
596967
  const descMatch = header.match(/^description:\s*(.+)$/m);
@@ -596591,8 +596999,8 @@ function deriveSource(p2) {
596591
596999
  }
596592
597000
  function loadAiwgItemContent(path11, maxBytes = 2e4) {
596593
597001
  try {
596594
- if (!existsSync106(path11)) return null;
596595
- const raw = readFileSync88(path11, "utf-8");
597002
+ if (!existsSync107(path11)) return null;
597003
+ const raw = readFileSync89(path11, "utf-8");
596596
597004
  return raw.length > maxBytes ? raw.slice(0, maxBytes) + "\n\n...(truncated for context budget)" : raw;
596597
597005
  } catch {
596598
597006
  return null;
@@ -596605,14 +597013,14 @@ function listAiwgAddons() {
596605
597013
  _cachedAddons = [];
596606
597014
  return _cachedAddons;
596607
597015
  }
596608
- const addonsDir = join122(root, "agentic", "code", "addons");
596609
- if (!existsSync106(addonsDir)) {
597016
+ const addonsDir = join123(root, "agentic", "code", "addons");
597017
+ if (!existsSync107(addonsDir)) {
596610
597018
  _cachedAddons = [];
596611
597019
  return _cachedAddons;
596612
597020
  }
596613
597021
  const out = [];
596614
597022
  for (const name10 of readdirSync36(addonsDir)) {
596615
- const p2 = join122(addonsDir, name10);
597023
+ const p2 = join123(addonsDir, name10);
596616
597024
  try {
596617
597025
  const st = statSync35(p2);
596618
597026
  if (!st.isDirectory()) continue;
@@ -597101,18 +597509,18 @@ __export(runtime_keys_exports, {
597101
597509
  mintKey: () => mintKey,
597102
597510
  revokeByPrefix: () => revokeByPrefix
597103
597511
  });
597104
- import { existsSync as existsSync107, readFileSync as readFileSync89, writeFileSync as writeFileSync57, mkdirSync as mkdirSync64, chmodSync } from "node:fs";
597105
- import { join as join123 } from "node:path";
597512
+ import { existsSync as existsSync108, readFileSync as readFileSync90, writeFileSync as writeFileSync58, mkdirSync as mkdirSync64, chmodSync } from "node:fs";
597513
+ import { join as join124 } from "node:path";
597106
597514
  import { homedir as homedir40 } from "node:os";
597107
597515
  import { randomBytes as randomBytes21 } from "node:crypto";
597108
597516
  function ensureDir2() {
597109
- const dir = join123(homedir40(), ".open-agents");
597110
- if (!existsSync107(dir)) mkdirSync64(dir, { recursive: true });
597517
+ const dir = join124(homedir40(), ".open-agents");
597518
+ if (!existsSync108(dir)) mkdirSync64(dir, { recursive: true });
597111
597519
  }
597112
597520
  function loadAll() {
597113
- if (!existsSync107(KEYS_FILE)) return [];
597521
+ if (!existsSync108(KEYS_FILE)) return [];
597114
597522
  try {
597115
- const raw = readFileSync89(KEYS_FILE, "utf-8");
597523
+ const raw = readFileSync90(KEYS_FILE, "utf-8");
597116
597524
  const parsed = JSON.parse(raw);
597117
597525
  if (!Array.isArray(parsed)) return [];
597118
597526
  return parsed;
@@ -597122,7 +597530,7 @@ function loadAll() {
597122
597530
  }
597123
597531
  function persistAll(records) {
597124
597532
  ensureDir2();
597125
- writeFileSync57(KEYS_FILE, JSON.stringify(records, null, 2), "utf-8");
597533
+ writeFileSync58(KEYS_FILE, JSON.stringify(records, null, 2), "utf-8");
597126
597534
  try {
597127
597535
  chmodSync(KEYS_FILE, 384);
597128
597536
  } catch {
@@ -597187,7 +597595,7 @@ var KEYS_FILE;
597187
597595
  var init_runtime_keys = __esm({
597188
597596
  "packages/cli/src/api/runtime-keys.ts"() {
597189
597597
  "use strict";
597190
- KEYS_FILE = join123(homedir40(), ".open-agents", "keys.json");
597598
+ KEYS_FILE = join124(homedir40(), ".open-agents", "keys.json");
597191
597599
  }
597192
597600
  });
597193
597601
 
@@ -597198,20 +597606,20 @@ __export(tor_fallback_exports, {
597198
597606
  torIsReachable: () => torIsReachable,
597199
597607
  tunnelViaTor: () => tunnelViaTor
597200
597608
  });
597201
- import { existsSync as existsSync108, readFileSync as readFileSync90 } from "node:fs";
597609
+ import { existsSync as existsSync109, readFileSync as readFileSync91 } from "node:fs";
597202
597610
  import { homedir as homedir41 } from "node:os";
597203
- import { join as join124 } from "node:path";
597611
+ import { join as join125 } from "node:path";
597204
597612
  import { createConnection as createConnection3 } from "node:net";
597205
597613
  function getLocalOnion() {
597206
597614
  const candidates = [
597207
- join124(homedir41(), "hidden_service_hostname"),
597208
- join124(homedir41(), ".oa", "tor", "hostname"),
597615
+ join125(homedir41(), "hidden_service_hostname"),
597616
+ join125(homedir41(), ".oa", "tor", "hostname"),
597209
597617
  "/var/lib/tor/hidden_service/hostname"
597210
597618
  ];
597211
597619
  for (const p2 of candidates) {
597212
597620
  try {
597213
- if (existsSync108(p2)) {
597214
- const v = readFileSync90(p2, "utf-8").trim();
597621
+ if (existsSync109(p2)) {
597622
+ const v = readFileSync91(p2, "utf-8").trim();
597215
597623
  if (v && v.endsWith(".onion")) return v;
597216
597624
  }
597217
597625
  } catch {
@@ -597356,8 +597764,8 @@ __export(graphical_sudo_exports, {
597356
597764
  runGraphicalSudo: () => runGraphicalSudo
597357
597765
  });
597358
597766
  import { spawn as spawn25 } from "node:child_process";
597359
- import { existsSync as existsSync109, mkdirSync as mkdirSync65, writeFileSync as writeFileSync58, chmodSync as chmodSync2 } from "node:fs";
597360
- import { join as join125 } from "node:path";
597767
+ import { existsSync as existsSync110, mkdirSync as mkdirSync65, writeFileSync as writeFileSync59, chmodSync as chmodSync2 } from "node:fs";
597768
+ import { join as join126 } from "node:path";
597361
597769
  import { tmpdir as tmpdir21 } from "node:os";
597362
597770
  function detectSudoHelper() {
597363
597771
  if (process.platform === "win32") return null;
@@ -597373,15 +597781,15 @@ function which(cmd) {
597373
597781
  const path11 = process.env["PATH"] || "/usr/bin:/bin:/usr/local/bin";
597374
597782
  for (const dir of path11.split(":")) {
597375
597783
  if (!dir) continue;
597376
- const full = join125(dir, cmd);
597377
- if (existsSync109(full)) return full;
597784
+ const full = join126(dir, cmd);
597785
+ if (existsSync110(full)) return full;
597378
597786
  }
597379
597787
  return null;
597380
597788
  }
597381
597789
  function ensureAskpassShim(helper, description) {
597382
- const shimDir = join125(tmpdir21(), "oa-askpass");
597790
+ const shimDir = join126(tmpdir21(), "oa-askpass");
597383
597791
  mkdirSync65(shimDir, { recursive: true });
597384
- const shim = join125(shimDir, `${helper}.sh`);
597792
+ const shim = join126(shimDir, `${helper}.sh`);
597385
597793
  let body;
597386
597794
  if (helper === "zenity") {
597387
597795
  body = `#!/bin/sh
@@ -597392,7 +597800,7 @@ exec zenity --password --title="OA needs sudo" --text="${description.replace(/"/
597392
597800
  exec kdialog --password "${description.replace(/"/g, '\\"')}" 2>/dev/null
597393
597801
  `;
597394
597802
  }
597395
- writeFileSync58(shim, body, "utf-8");
597803
+ writeFileSync59(shim, body, "utf-8");
597396
597804
  chmodSync2(shim, 493);
597397
597805
  return shim;
597398
597806
  }
@@ -597686,8 +598094,8 @@ var init_command_passthrough = __esm({
597686
598094
  });
597687
598095
 
597688
598096
  // packages/cli/src/api/routes-v1.ts
597689
- import { existsSync as existsSync110, readFileSync as readFileSync91, readdirSync as readdirSync37, statSync as statSync36 } from "node:fs";
597690
- import { join as join126, resolve as pathResolve2 } from "node:path";
598097
+ import { existsSync as existsSync111, readFileSync as readFileSync92, readdirSync as readdirSync37, statSync as statSync36 } from "node:fs";
598098
+ import { join as join127, resolve as pathResolve2 } from "node:path";
597691
598099
  import { homedir as homedir42 } from "node:os";
597692
598100
  async function tryRouteV1(ctx3) {
597693
598101
  const { pathname, method } = ctx3;
@@ -597923,11 +598331,11 @@ async function handleGetSkill(ctx3, name10) {
597923
598331
  async function fallbackDiscoverSkills() {
597924
598332
  return (_root) => {
597925
598333
  const roots = [
597926
- join126(homedir42(), ".local", "share", "ai-writing-guide")
598334
+ join127(homedir42(), ".local", "share", "ai-writing-guide")
597927
598335
  ];
597928
598336
  const out = [];
597929
598337
  for (const root of roots) {
597930
- if (!existsSync110(root)) continue;
598338
+ if (!existsSync111(root)) continue;
597931
598339
  walkForSkills(root, out, 0);
597932
598340
  }
597933
598341
  return out;
@@ -597938,12 +598346,12 @@ function walkForSkills(dir, out, depth) {
597938
598346
  try {
597939
598347
  for (const e2 of readdirSync37(dir, { withFileTypes: true })) {
597940
598348
  if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
597941
- const p2 = join126(dir, e2.name);
598349
+ const p2 = join127(dir, e2.name);
597942
598350
  if (e2.isDirectory()) {
597943
598351
  walkForSkills(p2, out, depth + 1);
597944
598352
  } else if (e2.isFile() && e2.name === "SKILL.md") {
597945
598353
  try {
597946
- const content = readFileSync91(p2, "utf-8").slice(0, 2e3);
598354
+ const content = readFileSync92(p2, "utf-8").slice(0, 2e3);
597947
598355
  const nameMatch = content.match(/^name:\s*(.+)$/m);
597948
598356
  const descMatch = content.match(/^description:\s*(.+)$/m);
597949
598357
  out.push({
@@ -598127,7 +598535,7 @@ async function getMemoryStores() {
598127
598535
  if (memoryInitTried) return null;
598128
598536
  memoryInitTried = true;
598129
598537
  try {
598130
- const dbPath = join126(homedir42(), ".open-agents", "memory.db");
598538
+ const dbPath = join127(homedir42(), ".open-agents", "memory.db");
598131
598539
  const sharedDb = initDb(dbPath);
598132
598540
  memoryStoresCache = {
598133
598541
  episode: new EpisodeStore(dbPath),
@@ -598385,7 +598793,7 @@ async function handleFilesRead(ctx3) {
598385
598793
  }));
598386
598794
  return true;
598387
598795
  }
598388
- if (!existsSync110(resolved)) {
598796
+ if (!existsSync111(resolved)) {
598389
598797
  sendProblem(res, problemDetails({
598390
598798
  type: P.notFound,
598391
598799
  status: 404,
@@ -598417,7 +598825,7 @@ async function handleFilesRead(ctx3) {
598417
598825
  }));
598418
598826
  return true;
598419
598827
  }
598420
- const content = readFileSync91(resolved, "utf-8");
598828
+ const content = readFileSync92(resolved, "utf-8");
598421
598829
  const offset = typeof body.offset === "number" && body.offset >= 0 ? body.offset : 0;
598422
598830
  const limit = typeof body.limit === "number" && body.limit > 0 ? body.limit : content.length;
598423
598831
  const slice2 = content.slice(offset, offset + limit);
@@ -598650,14 +599058,14 @@ async function handleNexusStatus(ctx3) {
598650
599058
  const { res, requestId } = ctx3;
598651
599059
  try {
598652
599060
  const statePaths = [
598653
- join126(process.cwd(), ".oa", "nexus-peer-state.json"),
598654
- join126(homedir42(), ".open-agents", "nexus-peer-cache.json")
599061
+ join127(process.cwd(), ".oa", "nexus-peer-state.json"),
599062
+ join127(homedir42(), ".open-agents", "nexus-peer-cache.json")
598655
599063
  ];
598656
599064
  const states = [];
598657
599065
  for (const p2 of statePaths) {
598658
- if (!existsSync110(p2)) continue;
599066
+ if (!existsSync111(p2)) continue;
598659
599067
  try {
598660
- const raw = readFileSync91(p2, "utf-8");
599068
+ const raw = readFileSync92(p2, "utf-8");
598661
599069
  states.push({ source: p2, data: JSON.parse(raw) });
598662
599070
  } catch (e2) {
598663
599071
  states.push({ source: p2, error: String(e2) });
@@ -598684,8 +599092,8 @@ async function handleNexusStatus(ctx3) {
598684
599092
  }
598685
599093
  function loadAgentName() {
598686
599094
  try {
598687
- const p2 = join126(homedir42(), ".open-agents", "agent-name");
598688
- if (existsSync110(p2)) return readFileSync91(p2, "utf-8").trim();
599095
+ const p2 = join127(homedir42(), ".open-agents", "agent-name");
599096
+ if (existsSync111(p2)) return readFileSync92(p2, "utf-8").trim();
598689
599097
  } catch {
598690
599098
  }
598691
599099
  return null;
@@ -598694,14 +599102,14 @@ async function handleSponsors(ctx3) {
598694
599102
  const { req: req2, res, url, requestId } = ctx3;
598695
599103
  try {
598696
599104
  const candidates = [
598697
- join126(homedir42(), ".open-agents", "sponsor-cache.json"),
598698
- join126(homedir42(), ".open-agents", "sponsors.json")
599105
+ join127(homedir42(), ".open-agents", "sponsor-cache.json"),
599106
+ join127(homedir42(), ".open-agents", "sponsors.json")
598699
599107
  ];
598700
599108
  let sponsors = [];
598701
599109
  for (const p2 of candidates) {
598702
- if (!existsSync110(p2)) continue;
599110
+ if (!existsSync111(p2)) continue;
598703
599111
  try {
598704
- const raw = JSON.parse(readFileSync91(p2, "utf-8"));
599112
+ const raw = JSON.parse(readFileSync92(p2, "utf-8"));
598705
599113
  if (Array.isArray(raw)) {
598706
599114
  sponsors = raw;
598707
599115
  break;
@@ -598770,8 +599178,8 @@ async function handleEvaluate(ctx3) {
598770
599178
  }));
598771
599179
  return true;
598772
599180
  }
598773
- const jobPath = join126(process.cwd(), ".oa", "jobs", `${runId}.json`);
598774
- if (!existsSync110(jobPath)) {
599181
+ const jobPath = join127(process.cwd(), ".oa", "jobs", `${runId}.json`);
599182
+ if (!existsSync111(jobPath)) {
598775
599183
  sendProblem(res, problemDetails({
598776
599184
  type: P.notFound,
598777
599185
  status: 404,
@@ -598781,7 +599189,7 @@ async function handleEvaluate(ctx3) {
598781
599189
  }));
598782
599190
  return true;
598783
599191
  }
598784
- const job = JSON.parse(readFileSync91(jobPath, "utf-8"));
599192
+ const job = JSON.parse(readFileSync92(jobPath, "utf-8"));
598785
599193
  sendJson(res, 200, {
598786
599194
  run_id: runId,
598787
599195
  task: job.task,
@@ -598919,9 +599327,9 @@ async function handleMintKey(ctx3) {
598919
599327
  return true;
598920
599328
  }
598921
599329
  function _readStatusFile(p2) {
598922
- if (!existsSync110(p2)) return null;
599330
+ if (!existsSync111(p2)) return null;
598923
599331
  try {
598924
- const data = JSON.parse(readFileSync91(p2, "utf-8"));
599332
+ const data = JSON.parse(readFileSync92(p2, "utf-8"));
598925
599333
  if (data?.connected && typeof data.peerId === "string" && data.peerId.length > 10) {
598926
599334
  return {
598927
599335
  peerId: data.peerId,
@@ -598936,18 +599344,18 @@ function _readStatusFile(p2) {
598936
599344
  function resolveLocalPeerId() {
598937
599345
  const override = process.env["OA_NEXUS_DIR"];
598938
599346
  if (override) {
598939
- const r2 = _readStatusFile(join126(override, "status.json"));
599347
+ const r2 = _readStatusFile(join127(override, "status.json"));
598940
599348
  if (r2) return r2;
598941
599349
  }
598942
599350
  try {
598943
- const regPath = join126(homedir42(), ".open-agents", "nexus-registry.json");
598944
- if (existsSync110(regPath)) {
598945
- const reg = JSON.parse(readFileSync91(regPath, "utf-8"));
599351
+ const regPath = join127(homedir42(), ".open-agents", "nexus-registry.json");
599352
+ if (existsSync111(regPath)) {
599353
+ const reg = JSON.parse(readFileSync92(regPath, "utf-8"));
598946
599354
  const entries = Array.isArray(reg?.dirs) ? reg.dirs : [];
598947
599355
  for (const entry of entries) {
598948
599356
  const dir = typeof entry === "string" ? entry : entry?.dir;
598949
599357
  if (typeof dir === "string") {
598950
- const r2 = _readStatusFile(join126(dir, "status.json"));
599358
+ const r2 = _readStatusFile(join127(dir, "status.json"));
598951
599359
  if (r2) return r2;
598952
599360
  }
598953
599361
  }
@@ -598955,9 +599363,9 @@ function resolveLocalPeerId() {
598955
599363
  } catch {
598956
599364
  }
598957
599365
  const candidates = [
598958
- join126(process.cwd(), ".oa", "nexus", "status.json"),
598959
- join126(homedir42(), ".oa", "nexus", "status.json"),
598960
- join126(homedir42(), ".open-agents", "nexus", "status.json")
599366
+ join127(process.cwd(), ".oa", "nexus", "status.json"),
599367
+ join127(homedir42(), ".oa", "nexus", "status.json"),
599368
+ join127(homedir42(), ".open-agents", "nexus", "status.json")
598961
599369
  ];
598962
599370
  for (const p2 of candidates) {
598963
599371
  const r2 = _readStatusFile(p2);
@@ -598990,21 +599398,21 @@ function locateTorScript(filename) {
598990
599398
  const candidates = [
598991
599399
  // npm-installed layout: build-publish.mjs copies scripts to
598992
599400
  // publish/dist/scripts/tor/ which lands at <install>/dist/scripts/tor/.
598993
- join126(__dirname, "scripts", "tor", filename),
598994
- join126(__dirname, "..", "scripts", "tor", filename),
598995
- join126(__dirname, "..", "..", "scripts", "tor", filename),
599401
+ join127(__dirname, "scripts", "tor", filename),
599402
+ join127(__dirname, "..", "scripts", "tor", filename),
599403
+ join127(__dirname, "..", "..", "scripts", "tor", filename),
598996
599404
  // Workspace dev: cli package's source tree.
598997
- join126(process.cwd(), "packages", "cli", "scripts", "tor", filename),
598998
- join126(process.cwd(), "scripts", "tor", filename)
599405
+ join127(process.cwd(), "packages", "cli", "scripts", "tor", filename),
599406
+ join127(process.cwd(), "scripts", "tor", filename)
598999
599407
  ];
599000
599408
  for (const p2 of candidates) {
599001
- if (existsSync110(p2)) return p2;
599409
+ if (existsSync111(p2)) return p2;
599002
599410
  }
599003
599411
  try {
599004
599412
  const { execSync: execSync60 } = __require("node:child_process");
599005
599413
  const root = execSync60("npm root -g", { encoding: "utf-8", timeout: 5e3 }).trim();
599006
- const p2 = join126(root, "open-agents-ai", "dist", "scripts", "tor", filename);
599007
- if (existsSync110(p2)) return p2;
599414
+ const p2 = join127(root, "open-agents-ai", "dist", "scripts", "tor", filename);
599415
+ if (existsSync111(p2)) return p2;
599008
599416
  } catch {
599009
599417
  }
599010
599418
  return null;
@@ -599274,13 +599682,13 @@ async function handleRemoteProxy(ctx3) {
599274
599682
  return true;
599275
599683
  }
599276
599684
  const nexusCandidates = [
599277
- join126(process.cwd(), ".oa", "nexus"),
599278
- join126(homedir42(), ".oa", "nexus"),
599279
- join126(homedir42(), ".open-agents", "nexus")
599685
+ join127(process.cwd(), ".oa", "nexus"),
599686
+ join127(homedir42(), ".oa", "nexus"),
599687
+ join127(homedir42(), ".open-agents", "nexus")
599280
599688
  ];
599281
599689
  let nexusDirPath = null;
599282
599690
  for (const p2 of nexusCandidates) {
599283
- if (existsSync110(join126(p2, "status.json"))) {
599691
+ if (existsSync111(join127(p2, "status.json"))) {
599284
599692
  nexusDirPath = p2;
599285
599693
  break;
599286
599694
  }
@@ -599376,7 +599784,7 @@ async function handleRemoteProxy(ctx3) {
599376
599784
  }));
599377
599785
  return true;
599378
599786
  }
599379
- const streamFile = join126(nexusDirPath, `tunnel-${requestId}-${Date.now()}.jsonl`);
599787
+ const streamFile = join127(nexusDirPath, `tunnel-${requestId}-${Date.now()}.jsonl`);
599380
599788
  try {
599381
599789
  const { writeFileSync: _wfs } = await import("node:fs");
599382
599790
  _wfs(streamFile, "");
@@ -599937,14 +600345,14 @@ async function handleListEngines(ctx3) {
599937
600345
  const home = homedir42();
599938
600346
  sendJson(res, 200, {
599939
600347
  engines: [
599940
- { name: "dream", state_file: join126(process.cwd(), ".oa", "dreams"), controllable_via: "SSE + slash commands" },
599941
- { name: "bless", state_file: join126(process.cwd(), ".oa", "bless-state.json"), controllable_via: "slash commands" },
599942
- { name: "call", state_file: join126(process.cwd(), ".oa", "call-state.json"), controllable_via: "slash commands" },
599943
- { name: "listen", state_file: join126(process.cwd(), ".oa", "listen-state.json"), controllable_via: "slash commands" },
599944
- { name: "telegram", state_file: join126(home, ".open-agents", "telegram-state.json"), controllable_via: "slash commands" },
599945
- { name: "expose", state_file: join126(process.cwd(), ".oa", "expose-state.json"), controllable_via: "/expose commands" },
599946
- { name: "nexus", state_file: join126(home, ".open-agents", "nexus-peer-cache.json"), controllable_via: "/nexus commands" },
599947
- { name: "ipfs", state_file: join126(process.cwd(), ".oa", "ipfs"), controllable_via: "slash commands" }
600348
+ { name: "dream", state_file: join127(process.cwd(), ".oa", "dreams"), controllable_via: "SSE + slash commands" },
600349
+ { name: "bless", state_file: join127(process.cwd(), ".oa", "bless-state.json"), controllable_via: "slash commands" },
600350
+ { name: "call", state_file: join127(process.cwd(), ".oa", "call-state.json"), controllable_via: "slash commands" },
600351
+ { name: "listen", state_file: join127(process.cwd(), ".oa", "listen-state.json"), controllable_via: "slash commands" },
600352
+ { name: "telegram", state_file: join127(home, ".open-agents", "telegram-state.json"), controllable_via: "slash commands" },
600353
+ { name: "expose", state_file: join127(process.cwd(), ".oa", "expose-state.json"), controllable_via: "/expose commands" },
600354
+ { name: "nexus", state_file: join127(home, ".open-agents", "nexus-peer-cache.json"), controllable_via: "/nexus commands" },
600355
+ { name: "ipfs", state_file: join127(process.cwd(), ".oa", "ipfs"), controllable_via: "slash commands" }
599948
600356
  ],
599949
600357
  note: "Engine instrumentation lives in the running TUI process. Full status + control requires the daemon↔TUI bridge (PT-07). See parity audit WO-PARITY-04."
599950
600358
  });
@@ -600027,12 +600435,12 @@ async function tryAimsRoute(ctx3) {
600027
600435
  return false;
600028
600436
  }
600029
600437
  function aimsDir() {
600030
- return join126(homedir42(), ".open-agents", "aims");
600438
+ return join127(homedir42(), ".open-agents", "aims");
600031
600439
  }
600032
600440
  function readAimsFile(name10, fallback) {
600033
600441
  try {
600034
- const p2 = join126(aimsDir(), name10);
600035
- if (existsSync110(p2)) return JSON.parse(readFileSync91(p2, "utf-8"));
600442
+ const p2 = join127(aimsDir(), name10);
600443
+ if (existsSync111(p2)) return JSON.parse(readFileSync92(p2, "utf-8"));
600036
600444
  } catch {
600037
600445
  }
600038
600446
  return fallback;
@@ -600041,7 +600449,7 @@ function writeAimsFile(name10, data) {
600041
600449
  const dir = aimsDir();
600042
600450
  const { mkdirSync: mkdirSync74, writeFileSync: wf, renameSync: rn } = __require("node:fs");
600043
600451
  mkdirSync74(dir, { recursive: true });
600044
- const finalPath = join126(dir, name10);
600452
+ const finalPath = join127(dir, name10);
600045
600453
  const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
600046
600454
  try {
600047
600455
  wf(tmpPath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
@@ -600371,12 +600779,12 @@ async function handleAimsSuppliers(ctx3) {
600371
600779
  }
600372
600780
  ];
600373
600781
  const sponsorPaths = [
600374
- join126(homedir42(), ".open-agents", "sponsor-cache.json")
600782
+ join127(homedir42(), ".open-agents", "sponsor-cache.json")
600375
600783
  ];
600376
600784
  for (const p2 of sponsorPaths) {
600377
- if (!existsSync110(p2)) continue;
600785
+ if (!existsSync111(p2)) continue;
600378
600786
  try {
600379
- const raw = JSON.parse(readFileSync91(p2, "utf-8"));
600787
+ const raw = JSON.parse(readFileSync92(p2, "utf-8"));
600380
600788
  const list = Array.isArray(raw) ? raw : raw?.sponsors ?? [];
600381
600789
  for (const s2 of list) {
600382
600790
  suppliers.push({
@@ -609531,15 +609939,15 @@ var init_auth_oidc = __esm({
609531
609939
  });
609532
609940
 
609533
609941
  // packages/cli/src/api/usage-tracker.ts
609534
- import { mkdirSync as mkdirSync66, readFileSync as readFileSync92, writeFileSync as writeFileSync59, existsSync as existsSync111 } from "node:fs";
609535
- import { join as join127 } from "node:path";
609942
+ import { mkdirSync as mkdirSync66, readFileSync as readFileSync93, writeFileSync as writeFileSync60, existsSync as existsSync112 } from "node:fs";
609943
+ import { join as join128 } from "node:path";
609536
609944
  function initUsageTracker(oaDir) {
609537
- const dir = join127(oaDir, "usage");
609945
+ const dir = join128(oaDir, "usage");
609538
609946
  mkdirSync66(dir, { recursive: true });
609539
- usageFile = join127(dir, "token-usage.json");
609947
+ usageFile = join128(dir, "token-usage.json");
609540
609948
  try {
609541
- if (existsSync111(usageFile)) {
609542
- store = JSON.parse(readFileSync92(usageFile, "utf-8"));
609949
+ if (existsSync112(usageFile)) {
609950
+ store = JSON.parse(readFileSync93(usageFile, "utf-8"));
609543
609951
  }
609544
609952
  } catch {
609545
609953
  store = { providers: {}, lastSaved: "" };
@@ -609575,7 +609983,7 @@ function flush2() {
609575
609983
  if (!initialized2 || !dirty) return;
609576
609984
  try {
609577
609985
  store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
609578
- writeFileSync59(usageFile, JSON.stringify(store, null, 2), "utf-8");
609986
+ writeFileSync60(usageFile, JSON.stringify(store, null, 2), "utf-8");
609579
609987
  dirty = false;
609580
609988
  } catch {
609581
609989
  }
@@ -609603,24 +610011,24 @@ var init_usage_tracker = __esm({
609603
610011
  });
609604
610012
 
609605
610013
  // packages/cli/src/api/profiles.ts
609606
- import { existsSync as existsSync112, readFileSync as readFileSync93, writeFileSync as writeFileSync60, mkdirSync as mkdirSync67, readdirSync as readdirSync38, unlinkSync as unlinkSync23 } from "node:fs";
609607
- import { join as join128 } from "node:path";
610014
+ import { existsSync as existsSync113, readFileSync as readFileSync94, writeFileSync as writeFileSync61, mkdirSync as mkdirSync67, readdirSync as readdirSync38, unlinkSync as unlinkSync24 } from "node:fs";
610015
+ import { join as join129 } from "node:path";
609608
610016
  import { homedir as homedir43 } from "node:os";
609609
610017
  import { createCipheriv as createCipheriv4, createDecipheriv as createDecipheriv4, randomBytes as randomBytes22, scryptSync as scryptSync3 } from "node:crypto";
609610
610018
  function globalProfileDir() {
609611
- return join128(homedir43(), ".open-agents", "profiles");
610019
+ return join129(homedir43(), ".open-agents", "profiles");
609612
610020
  }
609613
610021
  function projectProfileDir(projectDir2) {
609614
- return join128(projectDir2 || process.cwd(), ".oa", "profiles");
610022
+ return join129(projectDir2 || process.cwd(), ".oa", "profiles");
609615
610023
  }
609616
610024
  function listProfiles(projectDir2) {
609617
610025
  const result = [];
609618
610026
  const seen = /* @__PURE__ */ new Set();
609619
610027
  const projDir = projectProfileDir(projectDir2);
609620
- if (existsSync112(projDir)) {
610028
+ if (existsSync113(projDir)) {
609621
610029
  for (const f2 of readdirSync38(projDir).filter((f3) => f3.endsWith(".json"))) {
609622
610030
  try {
609623
- const raw = JSON.parse(readFileSync93(join128(projDir, f2), "utf8"));
610031
+ const raw = JSON.parse(readFileSync94(join129(projDir, f2), "utf8"));
609624
610032
  const name10 = f2.replace(".json", "");
609625
610033
  seen.add(name10);
609626
610034
  result.push({
@@ -609634,12 +610042,12 @@ function listProfiles(projectDir2) {
609634
610042
  }
609635
610043
  }
609636
610044
  const globDir = globalProfileDir();
609637
- if (existsSync112(globDir)) {
610045
+ if (existsSync113(globDir)) {
609638
610046
  for (const f2 of readdirSync38(globDir).filter((f3) => f3.endsWith(".json"))) {
609639
610047
  const name10 = f2.replace(".json", "");
609640
610048
  if (seen.has(name10)) continue;
609641
610049
  try {
609642
- const raw = JSON.parse(readFileSync93(join128(globDir, f2), "utf8"));
610050
+ const raw = JSON.parse(readFileSync94(join129(globDir, f2), "utf8"));
609643
610051
  result.push({
609644
610052
  name: name10,
609645
610053
  description: raw.description || "",
@@ -609654,11 +610062,11 @@ function listProfiles(projectDir2) {
609654
610062
  }
609655
610063
  function loadProfile(name10, password, projectDir2) {
609656
610064
  const sanitized = name10.replace(/[^a-zA-Z0-9_-]/g, "");
609657
- const projPath = join128(projectProfileDir(projectDir2), `${sanitized}.json`);
609658
- const globPath = join128(globalProfileDir(), `${sanitized}.json`);
609659
- const filePath = existsSync112(projPath) ? projPath : existsSync112(globPath) ? globPath : null;
610065
+ const projPath = join129(projectProfileDir(projectDir2), `${sanitized}.json`);
610066
+ const globPath = join129(globalProfileDir(), `${sanitized}.json`);
610067
+ const filePath = existsSync113(projPath) ? projPath : existsSync113(globPath) ? globPath : null;
609660
610068
  if (!filePath) return null;
609661
- const raw = JSON.parse(readFileSync93(filePath, "utf8"));
610069
+ const raw = JSON.parse(readFileSync94(filePath, "utf8"));
609662
610070
  if (raw.encrypted === true) {
609663
610071
  if (!password) return null;
609664
610072
  return decryptProfile(raw, password);
@@ -609669,22 +610077,22 @@ function saveProfile(profile, password, scope = "global", projectDir2) {
609669
610077
  const dir = scope === "project" ? projectProfileDir(projectDir2) : globalProfileDir();
609670
610078
  mkdirSync67(dir, { recursive: true });
609671
610079
  const sanitized = profile.name.replace(/[^a-zA-Z0-9_-]/g, "");
609672
- const filePath = join128(dir, `${sanitized}.json`);
610080
+ const filePath = join129(dir, `${sanitized}.json`);
609673
610081
  profile.modified = (/* @__PURE__ */ new Date()).toISOString();
609674
610082
  if (password) {
609675
610083
  const encrypted = encryptProfile(profile, password);
609676
- writeFileSync60(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
610084
+ writeFileSync61(filePath, JSON.stringify(encrypted, null, 2), { mode: 384 });
609677
610085
  } else {
609678
610086
  profile.encrypted = false;
609679
- writeFileSync60(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
610087
+ writeFileSync61(filePath, JSON.stringify(profile, null, 2), { mode: 420 });
609680
610088
  }
609681
610089
  }
609682
610090
  function deleteProfile(name10, scope = "global", projectDir2) {
609683
610091
  const sanitized = name10.replace(/[^a-zA-Z0-9_-]/g, "");
609684
610092
  const dir = scope === "project" ? projectProfileDir(projectDir2) : globalProfileDir();
609685
- const filePath = join128(dir, `${sanitized}.json`);
609686
- if (existsSync112(filePath)) {
609687
- unlinkSync23(filePath);
610093
+ const filePath = join129(dir, `${sanitized}.json`);
610094
+ if (existsSync113(filePath)) {
610095
+ unlinkSync24(filePath);
609688
610096
  return true;
609689
610097
  }
609690
610098
  return false;
@@ -609860,23 +610268,23 @@ var init_profiles = __esm({
609860
610268
 
609861
610269
  // packages/cli/src/docker.ts
609862
610270
  import { execSync as execSync56, spawn as spawn26 } from "node:child_process";
609863
- import { existsSync as existsSync113, mkdirSync as mkdirSync68, writeFileSync as writeFileSync61 } from "node:fs";
609864
- import { join as join129, resolve as resolve38, dirname as dirname35 } from "node:path";
610271
+ import { existsSync as existsSync114, mkdirSync as mkdirSync68, writeFileSync as writeFileSync62 } from "node:fs";
610272
+ import { join as join130, resolve as resolve38, dirname as dirname35 } from "node:path";
609865
610273
  import { homedir as homedir44 } from "node:os";
609866
610274
  import { fileURLToPath as fileURLToPath16 } from "node:url";
609867
610275
  function getDockerDir() {
609868
610276
  try {
609869
610277
  if (typeof __dirname !== "undefined") {
609870
- return join129(__dirname, "..", "..", "..", "docker");
610278
+ return join130(__dirname, "..", "..", "..", "docker");
609871
610279
  }
609872
610280
  } catch {
609873
610281
  }
609874
610282
  try {
609875
610283
  const thisDir = dirname35(fileURLToPath16(import.meta.url));
609876
- return join129(thisDir, "..", "..", "..", "docker");
610284
+ return join130(thisDir, "..", "..", "..", "docker");
609877
610285
  } catch {
609878
610286
  }
609879
- return join129(process.cwd(), "docker");
610287
+ return join130(process.cwd(), "docker");
609880
610288
  }
609881
610289
  function isDockerAvailable() {
609882
610290
  try {
@@ -610007,10 +610415,10 @@ async function ensureOaImage(force = false) {
610007
610415
  }
610008
610416
  let buildContext;
610009
610417
  const dockerDir = getDockerDir();
610010
- if (existsSync113(join129(dockerDir, "Dockerfile"))) {
610418
+ if (existsSync114(join130(dockerDir, "Dockerfile"))) {
610011
610419
  buildContext = dockerDir;
610012
610420
  } else {
610013
- buildContext = join129(homedir44(), ".oa", "docker-build");
610421
+ buildContext = join130(homedir44(), ".oa", "docker-build");
610014
610422
  mkdirSync68(buildContext, { recursive: true });
610015
610423
  writeDockerfiles(buildContext);
610016
610424
  }
@@ -610085,8 +610493,8 @@ chown -R node:node /workspace /home/node/.oa /home/node/.open-agents 2>/dev/null
610085
610493
  if [ "$1" = "oa" ]; then shift; exec su - node -c "cd /workspace && oa $*"; fi
610086
610494
  exec "$@"
610087
610495
  `;
610088
- writeFileSync61(join129(dir, "Dockerfile"), dockerfile);
610089
- writeFileSync61(join129(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
610496
+ writeFileSync62(join130(dir, "Dockerfile"), dockerfile);
610497
+ writeFileSync62(join130(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
610090
610498
  }
610091
610499
  function hasNvidiaGpu() {
610092
610500
  try {
@@ -610339,23 +610747,23 @@ import * as http5 from "node:http";
610339
610747
  import * as https3 from "node:https";
610340
610748
  import { createRequire as createRequire5 } from "node:module";
610341
610749
  import { fileURLToPath as fileURLToPath17 } from "node:url";
610342
- import { dirname as dirname36, join as join130, resolve as resolve39 } from "node:path";
610750
+ import { dirname as dirname36, join as join131, resolve as resolve39 } from "node:path";
610343
610751
  import { homedir as homedir45 } from "node:os";
610344
610752
  import { spawn as spawn27, execSync as execSync57 } from "node:child_process";
610345
- import { mkdirSync as mkdirSync69, writeFileSync as writeFileSync62, readFileSync as readFileSync94, readdirSync as readdirSync39, existsSync as existsSync114, watch as fsWatch3, renameSync as renameSync8, unlinkSync as unlinkSync24 } from "node:fs";
610753
+ import { mkdirSync as mkdirSync69, writeFileSync as writeFileSync63, readFileSync as readFileSync95, readdirSync as readdirSync39, existsSync as existsSync115, watch as fsWatch3, renameSync as renameSync8, unlinkSync as unlinkSync25 } from "node:fs";
610346
610754
  import { randomBytes as randomBytes23, randomUUID as randomUUID16 } from "node:crypto";
610347
610755
  import { createHash as createHash22 } from "node:crypto";
610348
610756
  function getVersion3() {
610349
610757
  try {
610350
610758
  const thisDir = dirname36(fileURLToPath17(import.meta.url));
610351
610759
  const candidates = [
610352
- join130(thisDir, "..", "package.json"),
610353
- join130(thisDir, "..", "..", "package.json"),
610354
- join130(thisDir, "..", "..", "..", "package.json")
610760
+ join131(thisDir, "..", "package.json"),
610761
+ join131(thisDir, "..", "..", "package.json"),
610762
+ join131(thisDir, "..", "..", "..", "package.json")
610355
610763
  ];
610356
610764
  for (const pkgPath of candidates) {
610357
610765
  try {
610358
- if (!existsSync114(pkgPath)) continue;
610766
+ if (!existsSync115(pkgPath)) continue;
610359
610767
  const pkg = require3(pkgPath);
610360
610768
  if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
610361
610769
  return pkg.version ?? "0.0.0";
@@ -610611,9 +611019,9 @@ function isOriginAllowed(origin) {
610611
611019
  if (!origin) return true;
610612
611020
  let accessMode = (process.env["OA_ACCESS"] || "").toLowerCase().trim();
610613
611021
  try {
610614
- const accessFile = join130(homedir45(), ".open-agents", "access");
610615
- if (existsSync114(accessFile)) {
610616
- const persisted = readFileSync94(accessFile, "utf8").trim().toLowerCase();
611022
+ const accessFile = join131(homedir45(), ".open-agents", "access");
611023
+ if (existsSync115(accessFile)) {
611024
+ const persisted = readFileSync95(accessFile, "utf8").trim().toLowerCase();
610617
611025
  if (persisted === "any" || persisted === "lan" || persisted === "loopback") {
610618
611026
  accessMode = persisted;
610619
611027
  }
@@ -610673,7 +611081,7 @@ async function retrieveMemoryContext(userMessage, sessionId, maxEpisodes = 5) {
610673
611081
  if (!memMod || !memMod.EpisodeStore) {
610674
611082
  return { contextBlock: "", retrieved: [] };
610675
611083
  }
610676
- const dbPath = join130(homedir45(), ".open-agents", "memory.db");
611084
+ const dbPath = join131(homedir45(), ".open-agents", "memory.db");
610677
611085
  const store2 = new memMod.EpisodeStore(dbPath);
610678
611086
  const recent = store2.search({ limit: 30, sessionId: void 0 }) ?? [];
610679
611087
  const qLower = userMessage.toLowerCase();
@@ -610716,7 +611124,7 @@ async function writeMemoryEpisodes(sessionId, userMessage, assistantContent, too
610716
611124
  try {
610717
611125
  const memMod = await Promise.resolve().then(() => (init_dist7(), dist_exports2)).catch(() => null);
610718
611126
  if (!memMod || !memMod.EpisodeStore) return 0;
610719
- const dbPath = join130(homedir45(), ".open-agents", "memory.db");
611127
+ const dbPath = join131(homedir45(), ".open-agents", "memory.db");
610720
611128
  const store2 = new memMod.EpisodeStore(dbPath);
610721
611129
  let written = 0;
610722
611130
  try {
@@ -611046,27 +611454,27 @@ function ollamaStream(ollamaUrl, path11, method, body, onData, onEnd, onError, t
611046
611454
  }
611047
611455
  function jobsDir() {
611048
611456
  const root = resolve39(process.cwd());
611049
- const dir = join130(root, ".oa", "jobs");
611457
+ const dir = join131(root, ".oa", "jobs");
611050
611458
  mkdirSync69(dir, { recursive: true });
611051
611459
  return dir;
611052
611460
  }
611053
611461
  function loadJob(id) {
611054
- const file = join130(jobsDir(), `${id}.json`);
611055
- if (!existsSync114(file)) return null;
611462
+ const file = join131(jobsDir(), `${id}.json`);
611463
+ if (!existsSync115(file)) return null;
611056
611464
  try {
611057
- return JSON.parse(readFileSync94(file, "utf-8"));
611465
+ return JSON.parse(readFileSync95(file, "utf-8"));
611058
611466
  } catch {
611059
611467
  return null;
611060
611468
  }
611061
611469
  }
611062
611470
  function listJobs() {
611063
611471
  const dir = jobsDir();
611064
- if (!existsSync114(dir)) return [];
611472
+ if (!existsSync115(dir)) return [];
611065
611473
  const files = readdirSync39(dir).filter((f2) => f2.endsWith(".json")).sort();
611066
611474
  const jobs = [];
611067
611475
  for (const file of files) {
611068
611476
  try {
611069
- jobs.push(JSON.parse(readFileSync94(join130(dir, file), "utf-8")));
611477
+ jobs.push(JSON.parse(readFileSync95(join131(dir, file), "utf-8")));
611070
611478
  } catch {
611071
611479
  }
611072
611480
  }
@@ -611076,14 +611484,14 @@ function pruneOldJobs() {
611076
611484
  const retentionH = parseFloat(process.env["OA_RUN_RETENTION_H"] || "24");
611077
611485
  const cutoffMs = Date.now() - (Number.isFinite(retentionH) && retentionH > 0 ? retentionH : 24) * 36e5;
611078
611486
  const dir = jobsDir();
611079
- if (!existsSync114(dir)) return { pruned: 0, kept: 0 };
611487
+ if (!existsSync115(dir)) return { pruned: 0, kept: 0 };
611080
611488
  let pruned = 0;
611081
611489
  let kept = 0;
611082
611490
  for (const file of readdirSync39(dir)) {
611083
611491
  if (!file.endsWith(".json")) continue;
611084
- const path11 = join130(dir, file);
611492
+ const path11 = join131(dir, file);
611085
611493
  try {
611086
- const job = JSON.parse(readFileSync94(path11, "utf-8"));
611494
+ const job = JSON.parse(readFileSync95(path11, "utf-8"));
611087
611495
  if (job.status === "running") {
611088
611496
  kept++;
611089
611497
  continue;
@@ -611092,13 +611500,13 @@ function pruneOldJobs() {
611092
611500
  const ts = ageRef ? Date.parse(ageRef) : NaN;
611093
611501
  if (Number.isFinite(ts) && ts < cutoffMs) {
611094
611502
  try {
611095
- unlinkSync24(path11);
611503
+ unlinkSync25(path11);
611096
611504
  } catch {
611097
611505
  }
611098
611506
  const outFile = path11.replace(/\.json$/, ".output");
611099
- if (existsSync114(outFile)) {
611507
+ if (existsSync115(outFile)) {
611100
611508
  try {
611101
- unlinkSync24(outFile);
611509
+ unlinkSync25(outFile);
611102
611510
  } catch {
611103
611511
  }
611104
611512
  }
@@ -611108,7 +611516,7 @@ function pruneOldJobs() {
611108
611516
  }
611109
611517
  } catch {
611110
611518
  try {
611111
- unlinkSync24(path11);
611519
+ unlinkSync25(path11);
611112
611520
  pruned++;
611113
611521
  } catch {
611114
611522
  }
@@ -611389,18 +611797,18 @@ function autoSeedTodosFromPrompt(prompt) {
611389
611797
  return [];
611390
611798
  }
611391
611799
  function atomicJobWrite(dir, id, job) {
611392
- const finalPath = join130(dir, `${id}.json`);
611800
+ const finalPath = join131(dir, `${id}.json`);
611393
611801
  const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
611394
611802
  try {
611395
- writeFileSync62(tmpPath, JSON.stringify(job, null, 2), "utf-8");
611803
+ writeFileSync63(tmpPath, JSON.stringify(job, null, 2), "utf-8");
611396
611804
  renameSync8(tmpPath, finalPath);
611397
611805
  } catch {
611398
611806
  try {
611399
- writeFileSync62(finalPath, JSON.stringify(job, null, 2), "utf-8");
611807
+ writeFileSync63(finalPath, JSON.stringify(job, null, 2), "utf-8");
611400
611808
  } catch {
611401
611809
  }
611402
611810
  try {
611403
- unlinkSync24(tmpPath);
611811
+ unlinkSync25(tmpPath);
611404
611812
  } catch {
611405
611813
  }
611406
611814
  }
@@ -612831,27 +613239,27 @@ ${task}` : task;
612831
613239
  });
612832
613240
  }
612833
613241
  function updateStateFile() {
612834
- return join130(homedir45(), ".open-agents", "update-state.json");
613242
+ return join131(homedir45(), ".open-agents", "update-state.json");
612835
613243
  }
612836
613244
  function updateLogPath() {
612837
- return join130(homedir45(), ".open-agents", "update.log");
613245
+ return join131(homedir45(), ".open-agents", "update.log");
612838
613246
  }
612839
613247
  function readUpdateState() {
612840
613248
  try {
612841
613249
  const p2 = updateStateFile();
612842
- if (!existsSync114(p2)) return null;
612843
- return JSON.parse(readFileSync94(p2, "utf-8"));
613250
+ if (!existsSync115(p2)) return null;
613251
+ return JSON.parse(readFileSync95(p2, "utf-8"));
612844
613252
  } catch {
612845
613253
  return null;
612846
613254
  }
612847
613255
  }
612848
613256
  function writeUpdateState(state) {
612849
613257
  try {
612850
- const dir = join130(homedir45(), ".open-agents");
613258
+ const dir = join131(homedir45(), ".open-agents");
612851
613259
  mkdirSync69(dir, { recursive: true });
612852
613260
  const finalPath = updateStateFile();
612853
613261
  const tmpPath = `${finalPath}.tmp.${process.pid}`;
612854
- writeFileSync62(tmpPath, JSON.stringify(state, null, 2), "utf-8");
613262
+ writeFileSync63(tmpPath, JSON.stringify(state, null, 2), "utf-8");
612855
613263
  renameSync8(tmpPath, finalPath);
612856
613264
  } catch {
612857
613265
  }
@@ -612895,15 +613303,15 @@ async function handleV1Update(req2, res, requestId) {
612895
613303
  const { execSync: es } = require3("node:child_process");
612896
613304
  const isWin2 = process.platform === "win32";
612897
613305
  let npmBin = "";
612898
- for (const candidate of isWin2 ? [join130(nodeDir, "npm.cmd"), join130(nodeDir, "npm")] : [join130(nodeDir, "npm"), "/usr/local/bin/npm", "/usr/bin/npm"]) {
612899
- if (existsSync114(candidate)) {
613306
+ for (const candidate of isWin2 ? [join131(nodeDir, "npm.cmd"), join131(nodeDir, "npm")] : [join131(nodeDir, "npm"), "/usr/local/bin/npm", "/usr/bin/npm"]) {
613307
+ if (existsSync115(candidate)) {
612900
613308
  npmBin = candidate;
612901
613309
  break;
612902
613310
  }
612903
613311
  }
612904
613312
  if (!npmBin) npmBin = isWin2 ? "npm.cmd" : "npm";
612905
613313
  const pkgSpec = `open-agents-ai@${targetVersion}`;
612906
- const dir = join130(homedir45(), ".open-agents");
613314
+ const dir = join131(homedir45(), ".open-agents");
612907
613315
  fs10.mkdirSync(dir, { recursive: true });
612908
613316
  const logFd = fs10.openSync(logPath3, "w");
612909
613317
  const npmPrefix = dirname36(nodeDir);
@@ -612913,13 +613321,13 @@ async function handleV1Update(req2, res, requestId) {
612913
613321
  globalBinDir = es(`${npmBin} bin -g`, { encoding: "utf8", timeout: 5e3, stdio: "pipe" }).trim();
612914
613322
  } else {
612915
613323
  const npmCliCandidates = [
612916
- join130(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
612917
- join130(npmBin, "..", "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
613324
+ join131(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
613325
+ join131(npmBin, "..", "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
612918
613326
  ];
612919
613327
  let npmCli = "";
612920
613328
  for (const c9 of npmCliCandidates) {
612921
613329
  try {
612922
- if (existsSync114(c9)) {
613330
+ if (existsSync115(c9)) {
612923
613331
  npmCli = c9;
612924
613332
  break;
612925
613333
  }
@@ -612951,13 +613359,13 @@ async function handleV1Update(req2, res, requestId) {
612951
613359
  });
612952
613360
  } else {
612953
613361
  const npmCliCandidates = [
612954
- join130(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
612955
- join130(npmBin, "..", "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
613362
+ join131(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
613363
+ join131(npmBin, "..", "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
612956
613364
  ];
612957
613365
  let npmCli = "";
612958
613366
  for (const c9 of npmCliCandidates) {
612959
613367
  try {
612960
- if (existsSync114(c9)) {
613368
+ if (existsSync115(c9)) {
612961
613369
  npmCli = c9;
612962
613370
  break;
612963
613371
  }
@@ -613054,8 +613462,8 @@ function handleV1UpdateStatus(res) {
613054
613462
  let logTail = "";
613055
613463
  let exitCode = null;
613056
613464
  try {
613057
- if (existsSync114(logPath3)) {
613058
- const raw = readFileSync94(logPath3, "utf-8");
613465
+ if (existsSync115(logPath3)) {
613466
+ const raw = readFileSync95(logPath3, "utf-8");
613059
613467
  const m2 = raw.match(/__EXIT_CODE=(\d+)/);
613060
613468
  if (m2) exitCode = parseInt(m2[1], 10);
613061
613469
  logTail = raw.slice(-2e3);
@@ -613151,7 +613559,7 @@ async function handleV1Run(req2, res) {
613151
613559
  if (workingDir) {
613152
613560
  cwd4 = resolve39(workingDir);
613153
613561
  } else if (isolate) {
613154
- const wsDir = join130(dir, "..", "workspaces", id);
613562
+ const wsDir = join131(dir, "..", "workspaces", id);
613155
613563
  mkdirSync69(wsDir, { recursive: true });
613156
613564
  cwd4 = wsDir;
613157
613565
  } else {
@@ -613338,7 +613746,7 @@ async function handleV1Run(req2, res) {
613338
613746
  let output = "";
613339
613747
  let tailBytes = 0;
613340
613748
  const TAIL_BUDGET = 1048576;
613341
- const outputWriter = new DiskTaskOutput(join130(dir, `${id}.output`));
613749
+ const outputWriter = new DiskTaskOutput(join131(dir, `${id}.output`));
613342
613750
  job.outputFile = outputWriter.path;
613343
613751
  atomicJobWrite(dir, id, job);
613344
613752
  child.stdout?.on("data", (chunk) => {
@@ -614310,10 +614718,10 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
614310
614718
  return;
614311
614719
  }
614312
614720
  const { tmpdir: tmpdir23 } = await import("node:os");
614313
- const { writeFileSync: writeFileSync67, unlinkSync: unlinkSync25 } = await import("node:fs");
614721
+ const { writeFileSync: writeFileSync68, unlinkSync: unlinkSync26 } = await import("node:fs");
614314
614722
  const { join: pjoin } = await import("node:path");
614315
614723
  const tmpPath = pjoin(tmpdir23(), `oa-clone-upload-${Date.now()}-${safeName}`);
614316
- writeFileSync67(tmpPath, buf);
614724
+ writeFileSync68(tmpPath, buf);
614317
614725
  try {
614318
614726
  const ve = getVoiceEngine();
614319
614727
  const msg = await ve.setCloneVoice(tmpPath);
@@ -614325,7 +614733,7 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
614325
614733
  });
614326
614734
  } finally {
614327
614735
  try {
614328
- unlinkSync25(tmpPath);
614736
+ unlinkSync26(tmpPath);
614329
614737
  } catch {
614330
614738
  }
614331
614739
  }
@@ -614905,7 +615313,7 @@ data: ${JSON.stringify(data)}
614905
615313
  }
614906
615314
  for (const f2 of seenFiles) {
614907
615315
  try {
614908
- writeFileSync62(f2, JSON.stringify({ tasks: [] }, null, 2));
615316
+ writeFileSync63(f2, JSON.stringify({ tasks: [] }, null, 2));
614909
615317
  deleted++;
614910
615318
  } catch {
614911
615319
  }
@@ -616009,7 +616417,7 @@ ${steering}`;
616009
616417
  function getScheduleRoots() {
616010
616418
  const rootsEnv = process.env["OA_SCHEDULE_ROOTS"] || "";
616011
616419
  const roots = rootsEnv.split(rootsEnv.includes(";") ? ";" : ":").filter(Boolean);
616012
- const defaults3 = [process.cwd(), join130(homedir45(), "Documents")];
616420
+ const defaults3 = [process.cwd(), join131(homedir45(), "Documents")];
616013
616421
  const set = /* @__PURE__ */ new Set([...defaults3, ...roots]);
616014
616422
  return [...set];
616015
616423
  }
@@ -616021,10 +616429,10 @@ function listScheduledTasks() {
616021
616429
  for (const root of roots) {
616022
616430
  try {
616023
616431
  walk(root, 0, (dir) => {
616024
- if (dir.endsWith(`${join130(".oa", "scheduled")}`) || dir.includes(`${join130(".oa", "scheduled")}`)) {
616025
- const file = join130(dir, "tasks.json");
616432
+ if (dir.endsWith(`${join131(".oa", "scheduled")}`) || dir.includes(`${join131(".oa", "scheduled")}`)) {
616433
+ const file = join131(dir, "tasks.json");
616026
616434
  try {
616027
- const raw = readFileSync94(file, "utf-8");
616435
+ const raw = readFileSync95(file, "utf-8");
616028
616436
  const json = JSON.parse(raw);
616029
616437
  const tasks = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
616030
616438
  tasks.forEach((t2, i2) => {
@@ -616089,7 +616497,7 @@ function walk(dir, depth, onDir, maxDepth) {
616089
616497
  if (e2.name === "node_modules" || e2.name.startsWith(".")) {
616090
616498
  if (e2.name !== ".oa") continue;
616091
616499
  }
616092
- const child = join130(dir, e2.name);
616500
+ const child = join131(dir, e2.name);
616093
616501
  walk(child, depth + 1, onDir, maxDepth);
616094
616502
  }
616095
616503
  }
@@ -616098,18 +616506,18 @@ function setScheduledEnabled(id, enabled2) {
616098
616506
  const target = tasks.find((t2) => t2.id === id);
616099
616507
  if (!target) return false;
616100
616508
  try {
616101
- const raw = readFileSync94(target.file, "utf-8");
616509
+ const raw = readFileSync95(target.file, "utf-8");
616102
616510
  const json = JSON.parse(raw);
616103
616511
  const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
616104
616512
  if (!arr[target.index]) return false;
616105
616513
  arr[target.index].enabled = enabled2;
616106
616514
  if (Array.isArray(json?.tasks)) {
616107
616515
  json.tasks = arr;
616108
- writeFileSync62(target.file, JSON.stringify(json, null, 2));
616516
+ writeFileSync63(target.file, JSON.stringify(json, null, 2));
616109
616517
  } else if (Array.isArray(json)) {
616110
- writeFileSync62(target.file, JSON.stringify(arr, null, 2));
616518
+ writeFileSync63(target.file, JSON.stringify(arr, null, 2));
616111
616519
  } else {
616112
- writeFileSync62(target.file, JSON.stringify({ tasks: arr }, null, 2));
616520
+ writeFileSync63(target.file, JSON.stringify({ tasks: arr }, null, 2));
616113
616521
  }
616114
616522
  if (!enabled2) {
616115
616523
  try {
@@ -616131,7 +616539,7 @@ function deleteScheduledById(id) {
616131
616539
  const target = tasks.find((t2) => t2.id === id);
616132
616540
  if (!target) return false;
616133
616541
  try {
616134
- const raw = readFileSync94(target.file, "utf-8");
616542
+ const raw = readFileSync95(target.file, "utf-8");
616135
616543
  const json = JSON.parse(raw);
616136
616544
  const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
616137
616545
  if (!arr[target.index]) return false;
@@ -616139,11 +616547,11 @@ function deleteScheduledById(id) {
616139
616547
  arr.splice(target.index, 1);
616140
616548
  if (Array.isArray(json?.tasks)) {
616141
616549
  json.tasks = arr;
616142
- writeFileSync62(target.file, JSON.stringify(json, null, 2));
616550
+ writeFileSync63(target.file, JSON.stringify(json, null, 2));
616143
616551
  } else if (Array.isArray(json)) {
616144
- writeFileSync62(target.file, JSON.stringify(arr, null, 2));
616552
+ writeFileSync63(target.file, JSON.stringify(arr, null, 2));
616145
616553
  } else {
616146
- writeFileSync62(target.file, JSON.stringify({ tasks: arr }, null, 2));
616554
+ writeFileSync63(target.file, JSON.stringify({ tasks: arr }, null, 2));
616147
616555
  }
616148
616556
  const candidates = [];
616149
616557
  if (id) candidates.push(id);
@@ -616396,11 +616804,11 @@ function reconcileScheduledTasks(apply) {
616396
616804
  const errors = [];
616397
616805
  for (const f2 of found) {
616398
616806
  const wdir = f2.workingDir || process.cwd();
616399
- const file = join130(wdir, ".oa", "scheduled", "tasks.json");
616807
+ const file = join131(wdir, ".oa", "scheduled", "tasks.json");
616400
616808
  try {
616401
616809
  let json = { tasks: [] };
616402
616810
  try {
616403
- const raw = readFileSync94(file, "utf-8");
616811
+ const raw = readFileSync95(file, "utf-8");
616404
616812
  json = JSON.parse(raw);
616405
616813
  } catch {
616406
616814
  }
@@ -616411,9 +616819,9 @@ function reconcileScheduledTasks(apply) {
616411
616819
  const entry = { task: f2.task || `legacy ${f2.id}`, schedule: f2.cron, enabled: true };
616412
616820
  arr.push(entry);
616413
616821
  const toWrite = Array.isArray(json?.tasks) ? { ...json, tasks: arr } : Array.isArray(json) ? arr : { tasks: arr };
616414
- mkdirSync69(join130(wdir, ".oa", "scheduled"), { recursive: true });
616415
- mkdirSync69(join130(wdir, ".oa", "scheduled", "logs"), { recursive: true });
616416
- writeFileSync62(file, JSON.stringify(toWrite, null, 2));
616822
+ mkdirSync69(join131(wdir, ".oa", "scheduled"), { recursive: true });
616823
+ mkdirSync69(join131(wdir, ".oa", "scheduled", "logs"), { recursive: true });
616824
+ writeFileSync63(file, JSON.stringify(toWrite, null, 2));
616417
616825
  adopted.push({ file, index: arr.length - 1 });
616418
616826
  }
616419
616827
  } else {
@@ -616457,32 +616865,32 @@ function writeCrontabLines(lines) {
616457
616865
  }
616458
616866
  function canonicalCronLine(rec) {
616459
616867
  const oaBin = findOaBinary4();
616460
- const logDir = join130(rec.workingDir, ".oa", "scheduled", "logs");
616461
- const logFile = join130(logDir, `${rec.id}.log`);
616462
- const storeFile = join130(rec.workingDir, ".oa", "scheduled", "tasks.json");
616868
+ const logDir = join131(rec.workingDir, ".oa", "scheduled", "logs");
616869
+ const logFile = join131(logDir, `${rec.id}.log`);
616870
+ const storeFile = join131(rec.workingDir, ".oa", "scheduled", "tasks.json");
616463
616871
  const taskEsc = rec.task.replace(/'/g, "'\\''");
616464
- const lockDir = join130(rec.workingDir, ".oa", "run");
616465
- const lockPath = join130(lockDir, `${rec.id}.lock`);
616872
+ const lockDir = join131(rec.workingDir, ".oa", "run");
616873
+ const lockPath = join131(lockDir, `${rec.id}.lock`);
616466
616874
  const wrapper = [
616467
616875
  `cd ${JSON.stringify(rec.workingDir)}`,
616468
616876
  `mkdir -p ${JSON.stringify(logDir)}`,
616469
616877
  `mkdir -p ${JSON.stringify(lockDir)}`,
616470
616878
  `if mkdir ${JSON.stringify(lockPath)} 2>/dev/null; then`,
616471
- ` echo $$ > ${JSON.stringify(join130(lockPath, "pid"))}`,
616879
+ ` echo $$ > ${JSON.stringify(join131(lockPath, "pid"))}`,
616472
616880
  ` trap 'rm -rf ${lockPath}' EXIT`,
616473
616881
  `else`,
616474
- ` if [ -f ${JSON.stringify(join130(lockPath, "pid"))} ]; then`,
616475
- ` oldpid=$(cat ${JSON.stringify(join130(lockPath, "pid"))} 2>/dev/null || echo)`,
616882
+ ` if [ -f ${JSON.stringify(join131(lockPath, "pid"))} ]; then`,
616883
+ ` oldpid=$(cat ${JSON.stringify(join131(lockPath, "pid"))} 2>/dev/null || echo)`,
616476
616884
  ` if [ -n "$oldpid" ] && kill -0 "$oldpid" 2>/dev/null; then`,
616477
616885
  ` echo "[oa-scheduler] ${rec.id} already running as PID $oldpid; skipping" >> ${JSON.stringify(logFile)}`,
616478
616886
  ` exit 0`,
616479
616887
  ` else`,
616480
616888
  ` rm -rf ${JSON.stringify(lockPath)} 2>/dev/null || true`,
616481
- ` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(join130(lockPath, "pid"))} && trap 'rm -rf ${lockPath}' EXIT`,
616889
+ ` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(join131(lockPath, "pid"))} && trap 'rm -rf ${lockPath}' EXIT`,
616482
616890
  ` fi`,
616483
616891
  ` else`,
616484
616892
  ` rm -rf ${JSON.stringify(lockPath)} 2>/dev/null || true`,
616485
- ` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(join130(lockPath, "pid"))} && trap 'rm -rf ${lockPath}' EXIT`,
616893
+ ` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(join131(lockPath, "pid"))} && trap 'rm -rf ${lockPath}' EXIT`,
616486
616894
  ` fi`,
616487
616895
  `fi`,
616488
616896
  `${oaBin} '${taskEsc}' >> ${JSON.stringify(logFile)} 2>&1; _oa_exit=$?`,
@@ -616514,9 +616922,9 @@ function fixupOrMigrateScheduled(mode, dryRun) {
616514
616922
  try {
616515
616923
  if (!f2.workingDir || !f2.task) continue;
616516
616924
  const unitBase = `oa-${f2.id}`;
616517
- const unitDir = join130(homedir45(), ".config", "systemd", "user");
616518
- const svc = join130(unitDir, `${unitBase}.service`);
616519
- const tim = join130(unitDir, `${unitBase}.timer`);
616925
+ const unitDir = join131(homedir45(), ".config", "systemd", "user");
616926
+ const svc = join131(unitDir, `${unitBase}.service`);
616927
+ const tim = join131(unitDir, `${unitBase}.timer`);
616520
616928
  const oaBin = findOaBinary4();
616521
616929
  const rec = { id: f2.id, cron: f2.cron, workingDir: f2.workingDir, task: f2.task };
616522
616930
  const cmd = canonicalCronLine(rec).split(" ").slice(5).join(" ");
@@ -616547,8 +616955,8 @@ WantedBy=timers.target
616547
616955
  `;
616548
616956
  if (!dryRun) {
616549
616957
  mkdirSync69(unitDir, { recursive: true });
616550
- writeFileSync62(svc, svcText);
616551
- writeFileSync62(tim, timText);
616958
+ writeFileSync63(svc, svcText);
616959
+ writeFileSync63(tim, timText);
616552
616960
  try {
616553
616961
  const { execSync: es } = require3("node:child_process");
616554
616962
  es("systemctl --user daemon-reload", { stdio: "pipe" });
@@ -616643,8 +617051,8 @@ function startApiServer(options2 = {}) {
616643
617051
  const config = loadConfig();
616644
617052
  const ollamaUrl = options2.ollamaUrl ?? config.backendUrl;
616645
617053
  const cwd4 = process.cwd();
616646
- initAuditLog(join130(cwd4, ".oa"));
616647
- initUsageTracker(join130(cwd4, ".oa"));
617054
+ initAuditLog(join131(cwd4, ".oa"));
617055
+ initUsageTracker(join131(cwd4, ".oa"));
616648
617056
  try {
616649
617057
  const taskMgr = getSharedTaskManager();
616650
617058
  taskMgr.setEventPublisher((type, data, opts) => {
@@ -616701,7 +617109,7 @@ function startApiServer(options2 = {}) {
616701
617109
  if (!f2.endsWith(".json") || f2.includes(".tmp.")) continue;
616702
617110
  const sid = f2.replace(/\.json$/, "");
616703
617111
  try {
616704
- const items = JSON.parse(readFileSync94(join130(dir, f2), "utf-8"));
617112
+ const items = JSON.parse(readFileSync95(join131(dir, f2), "utf-8"));
616705
617113
  if (Array.isArray(items)) {
616706
617114
  cache8.set(sid, new Map(items.map((t2) => [t2.id, t2])));
616707
617115
  }
@@ -616713,10 +617121,10 @@ function startApiServer(options2 = {}) {
616713
617121
  const watcher = fsWatch3(dir, (_evt, fname) => {
616714
617122
  if (!fname || !fname.endsWith(".json") || fname.includes(".tmp.")) return;
616715
617123
  const sid = fname.replace(/\.json$/, "");
616716
- const fp = join130(dir, fname);
617124
+ const fp = join131(dir, fname);
616717
617125
  let next = [];
616718
617126
  try {
616719
- if (!existsSync114(fp)) {
617127
+ if (!existsSync115(fp)) {
616720
617128
  const old = cache8.get(sid);
616721
617129
  if (old) {
616722
617130
  for (const t2 of old.values()) {
@@ -616729,7 +617137,7 @@ function startApiServer(options2 = {}) {
616729
617137
  }
616730
617138
  return;
616731
617139
  }
616732
- next = JSON.parse(readFileSync94(fp, "utf-8"));
617140
+ next = JSON.parse(readFileSync95(fp, "utf-8"));
616733
617141
  if (!Array.isArray(next)) return;
616734
617142
  } catch {
616735
617143
  return;
@@ -616768,18 +617176,18 @@ function startApiServer(options2 = {}) {
616768
617176
  const retentionDays = parseInt(process.env["OA_JOB_RETENTION_DAYS"] ?? "30", 10);
616769
617177
  if (!apiTestMode && retentionDays > 0) {
616770
617178
  try {
616771
- const jobsDir3 = join130(cwd4, ".oa", "jobs");
616772
- if (existsSync114(jobsDir3)) {
617179
+ const jobsDir3 = join131(cwd4, ".oa", "jobs");
617180
+ if (existsSync115(jobsDir3)) {
616773
617181
  const cutoff = Date.now() - retentionDays * 864e5;
616774
617182
  for (const f2 of readdirSync39(jobsDir3)) {
616775
617183
  if (!f2.endsWith(".json")) continue;
616776
617184
  try {
616777
- const jobPath = join130(jobsDir3, f2);
616778
- const job = JSON.parse(readFileSync94(jobPath, "utf-8"));
617185
+ const jobPath = join131(jobsDir3, f2);
617186
+ const job = JSON.parse(readFileSync95(jobPath, "utf-8"));
616779
617187
  const jobTime = new Date(job.startedAt ?? job.completedAt ?? 0).getTime();
616780
617188
  if (jobTime > 0 && jobTime < cutoff && job.status !== "running") {
616781
- const { unlinkSync: unlinkSync25 } = require3("node:fs");
616782
- unlinkSync25(jobPath);
617189
+ const { unlinkSync: unlinkSync26 } = require3("node:fs");
617190
+ unlinkSync26(jobPath);
616783
617191
  }
616784
617192
  } catch {
616785
617193
  }
@@ -616795,8 +617203,8 @@ function startApiServer(options2 = {}) {
616795
617203
  if (useTls) {
616796
617204
  try {
616797
617205
  tlsOpts = {
616798
- cert: readFileSync94(resolve39(tlsCert)),
616799
- key: readFileSync94(resolve39(tlsKey))
617206
+ cert: readFileSync95(resolve39(tlsCert)),
617207
+ key: readFileSync95(resolve39(tlsKey))
616800
617208
  };
616801
617209
  } catch (e2) {
616802
617210
  log22(`
@@ -616807,9 +617215,9 @@ function startApiServer(options2 = {}) {
616807
617215
  }
616808
617216
  let runtimeAccessMode = resolveAccessMode(process.env["OA_ACCESS"], host);
616809
617217
  try {
616810
- const accessFile = join130(homedir45(), ".open-agents", "access");
616811
- if (existsSync114(accessFile)) {
616812
- const persisted = readFileSync94(accessFile, "utf8").trim();
617218
+ const accessFile = join131(homedir45(), ".open-agents", "access");
617219
+ if (existsSync115(accessFile)) {
617220
+ const persisted = readFileSync95(accessFile, "utf8").trim();
616813
617221
  const resolved = resolveAccessMode(persisted, host);
616814
617222
  if (resolved) runtimeAccessMode = resolved;
616815
617223
  }
@@ -616869,9 +617277,9 @@ function startApiServer(options2 = {}) {
616869
617277
  const previous = runtimeAccessMode;
616870
617278
  runtimeAccessMode = requested;
616871
617279
  try {
616872
- const dir = join130(homedir45(), ".open-agents");
617280
+ const dir = join131(homedir45(), ".open-agents");
616873
617281
  mkdirSync69(dir, { recursive: true });
616874
- writeFileSync62(join130(dir, "access"), `${runtimeAccessMode}
617282
+ writeFileSync63(join131(dir, "access"), `${runtimeAccessMode}
616875
617283
  `, "utf8");
616876
617284
  } catch {
616877
617285
  }
@@ -617080,9 +617488,9 @@ function startApiServer(options2 = {}) {
617080
617488
  try {
617081
617489
  const { startEmbeddingWorkers: startEmbeddingWorkers2 } = await Promise.resolve().then(() => (init_embedding_workers(), embedding_workers_exports));
617082
617490
  const { ensureEmbedDeps: ensureEmbedDeps2, runEmbedImage: runEmbedImage2, runEmbedAudio: runEmbedAudio2 } = await Promise.resolve().then(() => (init_py_embed(), py_embed_exports));
617083
- const dbBase = join130(cwd4, ".oa");
617084
- const epStore = new mem.EpisodeStore(join130(dbBase, "memory.db"));
617085
- const kg = new mem.TemporalGraph(join130(dbBase, "kg.db"));
617491
+ const dbBase = join131(cwd4, ".oa");
617492
+ const epStore = new mem.EpisodeStore(join131(dbBase, "memory.db"));
617493
+ const kg = new mem.TemporalGraph(join131(dbBase, "kg.db"));
617086
617494
  try {
617087
617495
  ensureEmbedDeps2();
617088
617496
  } catch {
@@ -617164,7 +617572,7 @@ function startApiServer(options2 = {}) {
617164
617572
  return;
617165
617573
  }
617166
617574
  try {
617167
- const { writeFileSync: writeFileSync67, mkdirSync: mkdirSync74, existsSync: _exists, readFileSync: _rfs } = require3("node:fs");
617575
+ const { writeFileSync: writeFileSync68, mkdirSync: mkdirSync74, existsSync: _exists, readFileSync: _rfs } = require3("node:fs");
617168
617576
  const { join: _join } = require3("node:path");
617169
617577
  const { homedir: _homedir } = require3("node:os");
617170
617578
  const apiHint = JSON.stringify({
@@ -617195,7 +617603,7 @@ function startApiServer(options2 = {}) {
617195
617603
  for (const dir of dirSet) {
617196
617604
  try {
617197
617605
  if (!_exists(dir)) mkdirSync74(dir, { recursive: true });
617198
- writeFileSync67(_join(dir, "api-port.json"), apiHint);
617606
+ writeFileSync68(_join(dir, "api-port.json"), apiHint);
617199
617607
  written++;
617200
617608
  } catch {
617201
617609
  }
@@ -617513,10 +617921,10 @@ async function handleMemoryIngest(req2, res, ollamaUrl) {
617513
617921
  const labels = Array.isArray(b.labels) ? b.labels : [];
617514
617922
  const mediaPath = typeof b.media_path === "string" ? b.media_path : void 0;
617515
617923
  const cwd4 = process.cwd();
617516
- const dbBase = join130(cwd4, ".oa");
617924
+ const dbBase = join131(cwd4, ".oa");
617517
617925
  const { EpisodeStore: EpisodeStore3, TemporalGraph: TemporalGraph3 } = await Promise.resolve().then(() => (init_dist7(), dist_exports2));
617518
- const epStore = new EpisodeStore3(join130(dbBase, "memory.db"));
617519
- const kg = new TemporalGraph3(join130(dbBase, "kg.db"));
617926
+ const epStore = new EpisodeStore3(join131(dbBase, "memory.db"));
617927
+ const kg = new TemporalGraph3(join131(dbBase, "kg.db"));
617520
617928
  const meta = {};
617521
617929
  if (mediaPath) meta.media_path = mediaPath;
617522
617930
  const epId = epStore.insert({ modality, content: content || (mediaPath || ""), metadata: meta, toolName: "memory_ingest" });
@@ -617583,7 +617991,7 @@ async function handleEntitiesList(req2, res) {
617583
617991
  const type = url.searchParams.get("type") || "person";
617584
617992
  const limit = Math.max(1, Math.min(1e3, parseInt(url.searchParams.get("limit") || "100", 10)));
617585
617993
  const { TemporalGraph: TemporalGraph3 } = await Promise.resolve().then(() => (init_dist7(), dist_exports2));
617586
- const kg = new TemporalGraph3(join130(process.cwd(), ".oa", "kg.db"));
617994
+ const kg = new TemporalGraph3(join131(process.cwd(), ".oa", "kg.db"));
617587
617995
  const nodes = kg.nodesByType(type, limit).map((n2) => ({ id: n2.id, text: n2.text, mentionCount: n2.mentionCount, firstSeen: n2.firstSeen, lastSeen: n2.lastSeen }));
617588
617996
  jsonResponse(res, 200, { object: "list", data: nodes });
617589
617997
  } catch (err) {
@@ -617705,16 +618113,16 @@ var clipboard_media_exports = {};
617705
618113
  __export(clipboard_media_exports, {
617706
618114
  pasteClipboardImageToFile: () => pasteClipboardImageToFile
617707
618115
  });
617708
- import { execFileSync as execFileSync2, execSync as execSync58 } from "node:child_process";
617709
- import { mkdirSync as mkdirSync70, readFileSync as readFileSync95, rmSync as rmSync5, writeFileSync as writeFileSync63 } from "node:fs";
617710
- import { join as join131 } from "node:path";
618116
+ import { execFileSync as execFileSync3, execSync as execSync58 } from "node:child_process";
618117
+ import { mkdirSync as mkdirSync70, readFileSync as readFileSync96, rmSync as rmSync5, writeFileSync as writeFileSync64 } from "node:fs";
618118
+ import { join as join132 } from "node:path";
617711
618119
  function pasteClipboardImageToFile(repoRoot) {
617712
618120
  const image = readClipboardImage();
617713
618121
  if (!image) return null;
617714
- const dir = join131(repoRoot, ".oa", "clipboard");
618122
+ const dir = join132(repoRoot, ".oa", "clipboard");
617715
618123
  mkdirSync70(dir, { recursive: true });
617716
- const path11 = join131(dir, `clipboard-${Date.now()}${image.ext}`);
617717
- writeFileSync63(path11, image.buffer);
618124
+ const path11 = join132(dir, `clipboard-${Date.now()}${image.ext}`);
618125
+ writeFileSync64(path11, image.buffer);
617718
618126
  return { path: path11, buffer: image.buffer, mime: image.mime };
617719
618127
  }
617720
618128
  function readClipboardImage() {
@@ -617722,8 +618130,8 @@ function readClipboardImage() {
617722
618130
  try {
617723
618131
  execSync58("command -v pngpaste", { stdio: "ignore", timeout: 1e3 });
617724
618132
  const tmp = `/tmp/oa-clipboard-${Date.now()}.png`;
617725
- execFileSync2("pngpaste", [tmp], { timeout: 3e3 });
617726
- const buffer2 = readFileSync95(tmp);
618133
+ execFileSync3("pngpaste", [tmp], { timeout: 3e3 });
618134
+ const buffer2 = readFileSync96(tmp);
617727
618135
  try {
617728
618136
  rmSync5(tmp);
617729
618137
  } catch {
@@ -617742,7 +618150,7 @@ function readClipboardImage() {
617742
618150
  ];
617743
618151
  for (const attempt of attempts) {
617744
618152
  try {
617745
- const buffer2 = execFileSync2(attempt.cmd, attempt.args, { timeout: 3e3, maxBuffer: 25 * 1024 * 1024 });
618153
+ const buffer2 = execFileSync3(attempt.cmd, attempt.args, { timeout: 3e3, maxBuffer: 25 * 1024 * 1024 });
617746
618154
  if (buffer2.length > 0) return { buffer: buffer2, mime: attempt.mime, ext: attempt.ext };
617747
618155
  } catch {
617748
618156
  continue;
@@ -617759,7 +618167,7 @@ function readClipboardImage() {
617759
618167
  "$img.Save($ms,[Drawing.Imaging.ImageFormat]::Png);",
617760
618168
  "[Console]::OpenStandardOutput().Write($ms.ToArray(),0,$ms.Length)"
617761
618169
  ].join("");
617762
- const buffer2 = execFileSync2("powershell.exe", ["-NoProfile", "-Command", ps], {
618170
+ const buffer2 = execFileSync3("powershell.exe", ["-NoProfile", "-Command", ps], {
617763
618171
  timeout: 5e3,
617764
618172
  maxBuffer: 25 * 1024 * 1024
617765
618173
  });
@@ -617778,18 +618186,18 @@ var init_clipboard_media = __esm({
617778
618186
 
617779
618187
  // packages/cli/src/tui/interactive.ts
617780
618188
  import { cwd } from "node:process";
617781
- import { resolve as resolve40, join as join132, dirname as dirname37, extname as extname13, relative as relative11 } from "node:path";
618189
+ import { resolve as resolve40, join as join133, dirname as dirname37, extname as extname13, relative as relative11 } from "node:path";
617782
618190
  import { createRequire as createRequire6 } from "node:module";
617783
618191
  import { fileURLToPath as fileURLToPath18 } from "node:url";
617784
618192
  import {
617785
- readFileSync as readFileSync96,
617786
- writeFileSync as writeFileSync64,
618193
+ readFileSync as readFileSync97,
618194
+ writeFileSync as writeFileSync65,
617787
618195
  appendFileSync as appendFileSync8,
617788
618196
  rmSync as rmSync6,
617789
618197
  readdirSync as readdirSync40,
617790
618198
  mkdirSync as mkdirSync71
617791
618199
  } from "node:fs";
617792
- import { existsSync as existsSync115 } from "node:fs";
618200
+ import { existsSync as existsSync116 } from "node:fs";
617793
618201
  import { execSync as execSync59 } from "node:child_process";
617794
618202
  import { homedir as homedir46 } from "node:os";
617795
618203
  function formatTimeAgo2(date) {
@@ -617807,12 +618215,12 @@ function getVersion4() {
617807
618215
  const require4 = createRequire6(import.meta.url);
617808
618216
  const thisDir = dirname37(fileURLToPath18(import.meta.url));
617809
618217
  const candidates = [
617810
- join132(thisDir, "..", "package.json"),
617811
- join132(thisDir, "..", "..", "package.json"),
617812
- join132(thisDir, "..", "..", "..", "package.json")
618218
+ join133(thisDir, "..", "package.json"),
618219
+ join133(thisDir, "..", "..", "package.json"),
618220
+ join133(thisDir, "..", "..", "..", "package.json")
617813
618221
  ];
617814
618222
  for (const pkgPath of candidates) {
617815
- if (existsSync115(pkgPath)) {
618223
+ if (existsSync116(pkgPath)) {
617816
618224
  const pkg = require4(pkgPath);
617817
618225
  if (pkg.name === "open-agents-ai" || pkg.name === "@open-agents/cli" || pkg.name === "@open-agents/monorepo") {
617818
618226
  return pkg.version ?? "0.0.0";
@@ -618702,14 +619110,14 @@ Meta-critique: quality ${meta.quality}/5, thorough: ${meta.thorough}`;
618702
619110
  function gatherMemorySnippets(root) {
618703
619111
  const snippets = [];
618704
619112
  const dirs = [
618705
- join132(root, ".oa", "memory"),
618706
- join132(root, ".open-agents", "memory")
619113
+ join133(root, ".oa", "memory"),
619114
+ join133(root, ".open-agents", "memory")
618707
619115
  ];
618708
619116
  for (const dir of dirs) {
618709
- if (!existsSync115(dir)) continue;
619117
+ if (!existsSync116(dir)) continue;
618710
619118
  try {
618711
619119
  for (const f2 of readdirSync40(dir).filter((f3) => f3.endsWith(".json"))) {
618712
- const data = JSON.parse(readFileSync96(join132(dir, f2), "utf-8"));
619120
+ const data = JSON.parse(readFileSync97(join133(dir, f2), "utf-8"));
618713
619121
  for (const val of Object.values(data)) {
618714
619122
  const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
618715
619123
  if (v.length > 10) snippets.push(v);
@@ -618882,9 +619290,9 @@ ${metabolismMemories}
618882
619290
  } catch {
618883
619291
  }
618884
619292
  try {
618885
- const archeFile = join132(repoRoot, ".oa", "arche", "variants.json");
618886
- if (existsSync115(archeFile)) {
618887
- const variants = JSON.parse(readFileSync96(archeFile, "utf8"));
619293
+ const archeFile = join133(repoRoot, ".oa", "arche", "variants.json");
619294
+ if (existsSync116(archeFile)) {
619295
+ const variants = JSON.parse(readFileSync97(archeFile, "utf8"));
618888
619296
  if (variants.length > 0) {
618889
619297
  let filtered = variants;
618890
619298
  if (taskType) {
@@ -619091,9 +619499,9 @@ RULES:
619091
619499
  const compactionThreshold = Number.isFinite(envOverride) && envOverride > 0 ? envOverride : modelTier === "small" ? 12e3 : modelTier === "medium" ? 24e3 : 4e4;
619092
619500
  let identityInjection = "";
619093
619501
  try {
619094
- const ikStateFile = join132(repoRoot, ".oa", "identity", "self-state.json");
619095
- if (existsSync115(ikStateFile)) {
619096
- const selfState = JSON.parse(readFileSync96(ikStateFile, "utf8"));
619502
+ const ikStateFile = join133(repoRoot, ".oa", "identity", "self-state.json");
619503
+ if (existsSync116(ikStateFile)) {
619504
+ const selfState = JSON.parse(readFileSync97(ikStateFile, "utf8"));
619097
619505
  const lines = [
619098
619506
  `[Identity State v${selfState.version}]`,
619099
619507
  `Self: ${selfState.narrative_summary}`,
@@ -619359,17 +619767,17 @@ Review its full output in the [${id}] tab or via sub_agent(action='output', id='
619359
619767
  }
619360
619768
  }
619361
619769
  try {
619362
- const { readdirSync: readdirSync42, readFileSync: readFileSync98, existsSync: existsSync118 } = await import("node:fs");
619770
+ const { readdirSync: readdirSync42, readFileSync: readFileSync99, existsSync: existsSync119 } = await import("node:fs");
619363
619771
  const { join: pathJoin } = await import("node:path");
619364
619772
  const chunksDir = pathJoin(cwd(), ".oa", "todo-chunks");
619365
- if (existsSync118(chunksDir)) {
619773
+ if (existsSync119(chunksDir)) {
619366
619774
  const files = readdirSync42(chunksDir).filter(
619367
619775
  (f2) => f2.endsWith(".json")
619368
619776
  );
619369
619777
  for (const f2 of files) {
619370
619778
  try {
619371
619779
  const data = JSON.parse(
619372
- readFileSync98(pathJoin(chunksDir, f2), "utf-8")
619780
+ readFileSync99(pathJoin(chunksDir, f2), "utf-8")
619373
619781
  );
619374
619782
  if (data._deleted) continue;
619375
619783
  if ((data.functionalSummary || "").toLowerCase().includes(q) || (data.detailSummary || "").toLowerCase().includes(q) || (data.keyFiles || []).some(
@@ -619435,11 +619843,11 @@ ${lines.join("\n")}`
619435
619843
  const expand2 = args.expand === true;
619436
619844
  if (expand2 && id.startsWith("todo-ctx-")) {
619437
619845
  try {
619438
- const { readFileSync: readFileSync98, existsSync: existsSync118 } = await import("node:fs");
619846
+ const { readFileSync: readFileSync99, existsSync: existsSync119 } = await import("node:fs");
619439
619847
  const { join: pathJoin } = await import("node:path");
619440
619848
  const chunksDir = pathJoin(cwd(), ".oa", "todo-chunks");
619441
619849
  const todoIdSuffix = id.replace("todo-ctx-", "");
619442
- const files = existsSync118(chunksDir) ? (await import("node:fs")).readdirSync(chunksDir).filter((f2) => f2.endsWith(".json")) : [];
619850
+ const files = existsSync119(chunksDir) ? (await import("node:fs")).readdirSync(chunksDir).filter((f2) => f2.endsWith(".json")) : [];
619443
619851
  let chunkData = null;
619444
619852
  for (const f2 of files) {
619445
619853
  try {
@@ -620210,11 +620618,11 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
620210
620618
  });
620211
620619
  }
620212
620620
  try {
620213
- const ikDir = join132(repoRoot, ".oa", "identity");
620214
- const ikFile = join132(ikDir, "self-state.json");
620621
+ const ikDir = join133(repoRoot, ".oa", "identity");
620622
+ const ikFile = join133(ikDir, "self-state.json");
620215
620623
  let ikState;
620216
- if (existsSync115(ikFile)) {
620217
- ikState = JSON.parse(readFileSync96(ikFile, "utf8"));
620624
+ if (existsSync116(ikFile)) {
620625
+ ikState = JSON.parse(readFileSync97(ikFile, "utf8"));
620218
620626
  } else {
620219
620627
  mkdirSync71(ikDir, { recursive: true });
620220
620628
  const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
@@ -620326,7 +620734,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
620326
620734
  }
620327
620735
  ikState.session_count = (ikState.session_count || 0) + 1;
620328
620736
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
620329
- writeFileSync64(ikFile, JSON.stringify(ikState, null, 2));
620737
+ writeFileSync65(ikFile, JSON.stringify(ikState, null, 2));
620330
620738
  } catch (ikErr) {
620331
620739
  try {
620332
620740
  console.error("[IK-OBSERVE]", ikErr);
@@ -620358,9 +620766,9 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
620358
620766
  tokens
620359
620767
  );
620360
620768
  try {
620361
- const ikFile = join132(repoRoot, ".oa", "identity", "self-state.json");
620362
- if (existsSync115(ikFile)) {
620363
- const ikState = JSON.parse(readFileSync96(ikFile, "utf8"));
620769
+ const ikFile = join133(repoRoot, ".oa", "identity", "self-state.json");
620770
+ if (existsSync116(ikFile)) {
620771
+ const ikState = JSON.parse(readFileSync97(ikFile, "utf8"));
620364
620772
  if (!ikState.stats) ikState.stats = { queries_served: 0 };
620365
620773
  ikState.stats.queries_served = (ikState.stats.queries_served || 0) + 1;
620366
620774
  ikState.homeostasis.uncertainty = Math.min(
@@ -620382,7 +620790,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
620382
620790
  ikState.version_history = ikState.version_history.slice(-200);
620383
620791
  ikState.session_count = (ikState.session_count || 0) + 1;
620384
620792
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
620385
- writeFileSync64(ikFile, JSON.stringify(ikState, null, 2));
620793
+ writeFileSync65(ikFile, JSON.stringify(ikState, null, 2));
620386
620794
  }
620387
620795
  } catch {
620388
620796
  }
@@ -620649,10 +621057,10 @@ async function startInteractive(config, repoPath) {
620649
621057
  process.stdin.pause();
620650
621058
  }
620651
621059
  try {
620652
- const oaDir = join132(repoRoot, ".oa");
620653
- const nexusPidFile = join132(oaDir, "nexus", "daemon.pid");
620654
- if (existsSync115(nexusPidFile)) {
620655
- const pid = parseInt(readFileSync96(nexusPidFile, "utf8").trim(), 10);
621060
+ const oaDir = join133(repoRoot, ".oa");
621061
+ const nexusPidFile = join133(oaDir, "nexus", "daemon.pid");
621062
+ if (existsSync116(nexusPidFile)) {
621063
+ const pid = parseInt(readFileSync97(nexusPidFile, "utf8").trim(), 10);
620656
621064
  if (pid > 0) {
620657
621065
  try {
620658
621066
  process.kill(pid, 0);
@@ -621382,7 +621790,7 @@ ${result.summary}`
621382
621790
  let p2pGateway = null;
621383
621791
  let peerMesh = null;
621384
621792
  let inferenceRouter = null;
621385
- const secretVault = new SecretVault(join132(repoRoot, ".oa", "vault.enc"));
621793
+ const secretVault = new SecretVault(join133(repoRoot, ".oa", "vault.enc"));
621386
621794
  let adminSessionKey = null;
621387
621795
  const callSubAgents = /* @__PURE__ */ new Map();
621388
621796
  const streamRenderer = new StreamRenderer();
@@ -621578,22 +621986,22 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
621578
621986
  const out = [];
621579
621987
  const pushJsonFiles = (dir, prefix) => {
621580
621988
  try {
621581
- if (!existsSync115(dir)) return;
621989
+ if (!existsSync116(dir)) return;
621582
621990
  for (const file of readdirSync40(dir)) {
621583
621991
  if (!file.endsWith(".json")) continue;
621584
621992
  const id = file.replace(/\.json$/, "");
621585
- out.push({ id: `${prefix}:${id}`, label: id, path: join132(dir, file) });
621993
+ out.push({ id: `${prefix}:${id}`, label: id, path: join133(dir, file) });
621586
621994
  }
621587
621995
  } catch {
621588
621996
  }
621589
621997
  };
621590
- pushJsonFiles(join132(repoRoot, ".oa", "checkpoints"), "turn");
621998
+ pushJsonFiles(join133(repoRoot, ".oa", "checkpoints"), "turn");
621591
621999
  try {
621592
- const sessionDir = join132(repoRoot, ".oa", "session");
621593
- if (existsSync115(sessionDir)) {
622000
+ const sessionDir = join133(repoRoot, ".oa", "session");
622001
+ if (existsSync116(sessionDir)) {
621594
622002
  for (const entry of readdirSync40(sessionDir)) {
621595
- const cp2 = join132(sessionDir, entry, "checkpoint.json");
621596
- if (existsSync115(cp2)) out.push({ id: `session:${entry}`, label: entry, path: cp2 });
622003
+ const cp2 = join133(sessionDir, entry, "checkpoint.json");
622004
+ if (existsSync116(cp2)) out.push({ id: `session:${entry}`, label: entry, path: cp2 });
621597
622005
  }
621598
622006
  }
621599
622007
  } catch {
@@ -621652,8 +622060,8 @@ This is an independent background session started from /background.`
621652
622060
  return id;
621653
622061
  };
621654
622062
  try {
621655
- const titleFile = join132(repoRoot, ".oa", "session-title");
621656
- if (existsSync115(titleFile)) sessionTitle = readFileSync96(titleFile, "utf8").trim() || null;
622063
+ const titleFile = join133(repoRoot, ".oa", "session-title");
622064
+ if (existsSync116(titleFile)) sessionTitle = readFileSync97(titleFile, "utf8").trim() || null;
621657
622065
  } catch {
621658
622066
  }
621659
622067
  let carouselRetired = isResumed;
@@ -621710,13 +622118,13 @@ This is an independent background session started from /background.`
621710
622118
  );
621711
622119
  return [hits, line];
621712
622120
  }
621713
- const HISTORY_DIR = join132(homedir46(), ".open-agents");
621714
- const HISTORY_FILE = join132(HISTORY_DIR, "repl-history");
622121
+ const HISTORY_DIR = join133(homedir46(), ".open-agents");
622122
+ const HISTORY_FILE = join133(HISTORY_DIR, "repl-history");
621715
622123
  const MAX_HISTORY_LINES = 500;
621716
622124
  let savedHistory = [];
621717
622125
  try {
621718
- if (existsSync115(HISTORY_FILE)) {
621719
- const raw = readFileSync96(HISTORY_FILE, "utf8").trim();
622126
+ if (existsSync116(HISTORY_FILE)) {
622127
+ const raw = readFileSync97(HISTORY_FILE, "utf8").trim();
621720
622128
  if (raw) savedHistory = raw.split("\n").reverse();
621721
622129
  }
621722
622130
  } catch {
@@ -621876,9 +622284,9 @@ This is an independent background session started from /background.`
621876
622284
  mkdirSync71(HISTORY_DIR, { recursive: true });
621877
622285
  appendFileSync8(HISTORY_FILE, line + "\n", "utf8");
621878
622286
  if (Math.random() < 0.02) {
621879
- const all2 = readFileSync96(HISTORY_FILE, "utf8").trim().split("\n");
622287
+ const all2 = readFileSync97(HISTORY_FILE, "utf8").trim().split("\n");
621880
622288
  if (all2.length > MAX_HISTORY_LINES) {
621881
- writeFileSync64(
622289
+ writeFileSync65(
621882
622290
  HISTORY_FILE,
621883
622291
  all2.slice(-MAX_HISTORY_LINES).join("\n") + "\n",
621884
622292
  "utf8"
@@ -622081,10 +622489,10 @@ This is an independent background session started from /background.`
622081
622489
  const { unlinkSync: _rmStale } = await import("node:fs");
622082
622490
  const { homedir: _hdir } = await import("node:os");
622083
622491
  for (const dp of [
622084
- join132(repoRoot, ".oa", "nexus", "nexus-daemon.mjs"),
622085
- join132(_hdir(), ".open-agents", ".oa", "nexus", "nexus-daemon.mjs")
622492
+ join133(repoRoot, ".oa", "nexus", "nexus-daemon.mjs"),
622493
+ join133(_hdir(), ".open-agents", ".oa", "nexus", "nexus-daemon.mjs")
622086
622494
  ]) {
622087
- if (existsSync115(dp))
622495
+ if (existsSync116(dp))
622088
622496
  try {
622089
622497
  _rmStale(dp);
622090
622498
  } catch {
@@ -622096,10 +622504,10 @@ This is an independent background session started from /background.`
622096
622504
  const autoNexus = new NexusTool(repoRoot);
622097
622505
  const _registerNexusDaemon = () => {
622098
622506
  try {
622099
- const nexusPidFile = join132(repoRoot, ".oa", "nexus", "daemon.pid");
622100
- if (existsSync115(nexusPidFile)) {
622507
+ const nexusPidFile = join133(repoRoot, ".oa", "nexus", "daemon.pid");
622508
+ if (existsSync116(nexusPidFile)) {
622101
622509
  const nPid = parseInt(
622102
- readFileSync96(nexusPidFile, "utf8").trim(),
622510
+ readFileSync97(nexusPidFile, "utf8").trim(),
622103
622511
  10
622104
622512
  );
622105
622513
  if (nPid > 0 && !registry2.daemons.has("Nexus")) {
@@ -622167,7 +622575,7 @@ This is an independent background session started from /background.`
622167
622575
  } catch {
622168
622576
  }
622169
622577
  try {
622170
- const oaDir = join132(repoRoot, ".oa");
622578
+ const oaDir = join133(repoRoot, ".oa");
622171
622579
  const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
622172
622580
  onInfo: (msg) => writeContent(() => renderInfo(msg)),
622173
622581
  onError: (msg) => writeContent(() => renderWarning(msg))
@@ -622205,7 +622613,7 @@ This is an independent background session started from /background.`
622205
622613
  } catch {
622206
622614
  }
622207
622615
  try {
622208
- const oaDir = join132(repoRoot, ".oa");
622616
+ const oaDir = join133(repoRoot, ".oa");
622209
622617
  const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(
622210
622618
  oaDir,
622211
622619
  new NexusTool(repoRoot),
@@ -622269,11 +622677,11 @@ This is an independent background session started from /background.`
622269
622677
  hostname: _hn,
622270
622678
  userInfo: _ui
622271
622679
  } = await import("node:os");
622272
- const globalNamePath = join132(_hd(), ".open-agents", "agent-name");
622680
+ const globalNamePath = join133(_hd(), ".open-agents", "agent-name");
622273
622681
  let agName = "";
622274
622682
  try {
622275
- if (existsSync115(globalNamePath))
622276
- agName = readFileSync96(globalNamePath, "utf8").trim();
622683
+ if (existsSync116(globalNamePath))
622684
+ agName = readFileSync97(globalNamePath, "utf8").trim();
622277
622685
  } catch {
622278
622686
  }
622279
622687
  if (!agName) {
@@ -622304,7 +622712,7 @@ This is an independent background session started from /background.`
622304
622712
  }
622305
622713
  if (!ollamaAlive) {
622306
622714
  try {
622307
- const savedSponsorsPath = join132(
622715
+ const savedSponsorsPath = join133(
622308
622716
  repoRoot,
622309
622717
  ".oa",
622310
622718
  "sponsor",
@@ -622312,9 +622720,9 @@ This is an independent background session started from /background.`
622312
622720
  );
622313
622721
  let savedSponsors = [];
622314
622722
  try {
622315
- if (existsSync115(savedSponsorsPath)) {
622723
+ if (existsSync116(savedSponsorsPath)) {
622316
622724
  savedSponsors = JSON.parse(
622317
- readFileSync96(savedSponsorsPath, "utf8")
622725
+ readFileSync97(savedSponsorsPath, "utf8")
622318
622726
  );
622319
622727
  const oneHourAgo = Date.now() - 36e5;
622320
622728
  savedSponsors = savedSponsors.filter(
@@ -622739,8 +623147,8 @@ This is an independent background session started from /background.`
622739
623147
  setSessionTitle(title) {
622740
623148
  sessionTitle = title.trim() || null;
622741
623149
  try {
622742
- mkdirSync71(join132(repoRoot, ".oa"), { recursive: true });
622743
- writeFileSync64(join132(repoRoot, ".oa", "session-title"), `${sessionTitle ?? ""}
623150
+ mkdirSync71(join133(repoRoot, ".oa"), { recursive: true });
623151
+ writeFileSync65(join133(repoRoot, ".oa", "session-title"), `${sessionTitle ?? ""}
622744
623152
  `, "utf8");
622745
623153
  } catch {
622746
623154
  }
@@ -622762,16 +623170,26 @@ This is an independent background session started from /background.`
622762
623170
  const pasted = pasteClipboardImageToFile2(repoRoot);
622763
623171
  if (!pasted) return { ok: false, message: "Clipboard does not contain a supported image or no clipboard reader is available." };
622764
623172
  const relPath = relative11(repoRoot, pasted.path).startsWith("..") ? pasted.path : relative11(repoRoot, pasted.path);
623173
+ let visionContext = "";
623174
+ try {
623175
+ const { runVisionIngress: runVisionIngress2, formatImageContextPrefix: formatImageContextPrefix2 } = await Promise.resolve().then(() => (init_vision_ingress(), vision_ingress_exports));
623176
+ const currentModel = config.model ?? "";
623177
+ const ingressResult = await runVisionIngress2(pasted, currentModel);
623178
+ visionContext = formatImageContextPrefix2(ingressResult);
623179
+ } catch {
623180
+ }
622765
623181
  if (activeTask) {
622766
623182
  activeTask.runner.injectImage(
622767
623183
  pasted.buffer.toString("base64"),
622768
623184
  pasted.mime,
622769
- `User pasted clipboard image: ${relPath}`
623185
+ visionContext || `User pasted clipboard image: ${relPath}`
622770
623186
  );
622771
623187
  return { ok: true, message: `Attached clipboard image to active task: ${relPath}`, path: pasted.path };
622772
623188
  }
622773
623189
  queuePrompt(
622774
- `The user pasted a clipboard image saved at ${relPath}. Read it with image_read or vision and respond to what is shown.`,
623190
+ visionContext ? `${visionContext}
623191
+
623192
+ The user pasted a clipboard image saved at ${relPath}. Use the OCR and vision analysis above to understand and respond to the image content.` : `The user pasted a clipboard image saved at ${relPath}. Read it with image_read or vision and respond to what is shown.`,
622775
623193
  "clipboard"
622776
623194
  );
622777
623195
  return { ok: true, message: `Clipboard image queued for next prompt: ${relPath}`, path: pasted.path };
@@ -623809,10 +624227,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
623809
624227
  if (name10 === "voice_list_files") {
623810
624228
  const baseDir = String(args?.dir ?? ".");
623811
624229
  const { readdirSync: readdirSync42, statSync: statSync38 } = __require("node:fs");
623812
- const { join: join137, resolve: resolve44 } = __require("node:path");
623813
- const base3 = baseDir.startsWith("/") ? baseDir : resolve44(join137(repoRoot, baseDir));
624230
+ const { join: join138, resolve: resolve44 } = __require("node:path");
624231
+ const base3 = baseDir.startsWith("/") ? baseDir : resolve44(join138(repoRoot, baseDir));
623814
624232
  const items = readdirSync42(base3).slice(0, 200).map((f2) => {
623815
- const s2 = statSync38(join137(base3, f2));
624233
+ const s2 = statSync38(join138(base3, f2));
623816
624234
  return { name: f2, dir: s2.isDirectory(), size: s2.size };
623817
624235
  });
623818
624236
  return JSON.stringify({ dir: base3, items }, null, 2);
@@ -623911,7 +624329,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
623911
624329
  kind,
623912
624330
  targetUrl,
623913
624331
  authKey,
623914
- stateDir: join132(repoRoot, ".oa"),
624332
+ stateDir: join133(repoRoot, ".oa"),
623915
624333
  passthrough: passthrough ?? false,
623916
624334
  loadbalance: loadbalance ?? false,
623917
624335
  endpointAuth: passthrough ? currentConfig.apiKey : void 0,
@@ -623966,7 +624384,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
623966
624384
  targetUrl,
623967
624385
  authKey,
623968
624386
  fullAccess,
623969
- stateDir: join132(repoRoot, ".oa")
624387
+ stateDir: join133(repoRoot, ".oa")
623970
624388
  });
623971
624389
  newTunnel.on("stats", (stats) => {
623972
624390
  statusBar.setExposeStatus({
@@ -624056,9 +624474,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
624056
624474
  });
624057
624475
  if (!result.success) throw new Error(result.error || "Connect failed");
624058
624476
  try {
624059
- const nexusPidFile = join132(repoRoot, ".oa", "nexus", "daemon.pid");
624060
- if (existsSync115(nexusPidFile)) {
624061
- const pid = parseInt(readFileSync96(nexusPidFile, "utf8").trim(), 10);
624477
+ const nexusPidFile = join133(repoRoot, ".oa", "nexus", "daemon.pid");
624478
+ if (existsSync116(nexusPidFile)) {
624479
+ const pid = parseInt(readFileSync97(nexusPidFile, "utf8").trim(), 10);
624062
624480
  if (pid > 0) {
624063
624481
  registry2.register({
624064
624482
  name: "Nexus",
@@ -624266,10 +624684,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
624266
624684
  );
624267
624685
  }
624268
624686
  try {
624269
- const nexusDir = join132(repoRoot, OA_DIR, "nexus");
624270
- const pidFile = join132(nexusDir, "daemon.pid");
624271
- if (existsSync115(pidFile)) {
624272
- const pid = parseInt(readFileSync96(pidFile, "utf8").trim(), 10);
624687
+ const nexusDir = join133(repoRoot, OA_DIR, "nexus");
624688
+ const pidFile = join133(nexusDir, "daemon.pid");
624689
+ if (existsSync116(pidFile)) {
624690
+ const pid = parseInt(readFileSync97(pidFile, "utf8").trim(), 10);
624273
624691
  if (pid > 0) {
624274
624692
  try {
624275
624693
  if (process.platform === "win32") {
@@ -624296,13 +624714,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
624296
624714
  } catch {
624297
624715
  }
624298
624716
  try {
624299
- const voiceDir2 = join132(homedir46(), ".open-agents", "voice");
624717
+ const voiceDir2 = join133(homedir46(), ".open-agents", "voice");
624300
624718
  const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
624301
624719
  for (const pf of voicePidFiles) {
624302
- const pidPath = join132(voiceDir2, pf);
624303
- if (existsSync115(pidPath)) {
624720
+ const pidPath = join133(voiceDir2, pf);
624721
+ if (existsSync116(pidPath)) {
624304
624722
  try {
624305
- const pid = parseInt(readFileSync96(pidPath, "utf8").trim(), 10);
624723
+ const pid = parseInt(readFileSync97(pidPath, "utf8").trim(), 10);
624306
624724
  if (pid > 0) {
624307
624725
  if (process.platform === "win32") {
624308
624726
  try {
@@ -624332,8 +624750,8 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
624332
624750
  );
624333
624751
  } catch {
624334
624752
  }
624335
- const oaPath = join132(repoRoot, OA_DIR);
624336
- if (existsSync115(oaPath)) {
624753
+ const oaPath = join133(repoRoot, OA_DIR);
624754
+ if (existsSync116(oaPath)) {
624337
624755
  let deleted = false;
624338
624756
  for (let attempt = 0; attempt < 3; attempt++) {
624339
624757
  try {
@@ -624431,23 +624849,23 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
624431
624849
  try {
624432
624850
  const { isPersonaPlexRunning: isPersonaPlexRunning2 } = await Promise.resolve().then(() => (init_personaplex(), personaplex_exports));
624433
624851
  if (isPersonaPlexRunning2()) {
624434
- const ppPidFile = join132(
624852
+ const ppPidFile = join133(
624435
624853
  homedir46(),
624436
624854
  ".open-agents",
624437
624855
  "voice",
624438
624856
  "personaplex",
624439
624857
  "daemon.pid"
624440
624858
  );
624441
- const ppPortFile = join132(
624859
+ const ppPortFile = join133(
624442
624860
  homedir46(),
624443
624861
  ".open-agents",
624444
624862
  "voice",
624445
624863
  "personaplex",
624446
624864
  "daemon.port"
624447
624865
  );
624448
- if (existsSync115(ppPidFile)) {
624449
- const ppPid = parseInt(readFileSync96(ppPidFile, "utf8").trim(), 10);
624450
- const ppPort = existsSync115(ppPortFile) ? parseInt(readFileSync96(ppPortFile, "utf8").trim(), 10) : void 0;
624866
+ if (existsSync116(ppPidFile)) {
624867
+ const ppPid = parseInt(readFileSync97(ppPidFile, "utf8").trim(), 10);
624868
+ const ppPort = existsSync116(ppPortFile) ? parseInt(readFileSync97(ppPortFile, "utf8").trim(), 10) : void 0;
624451
624869
  if (ppPid > 0 && !registry2.daemons.has("PersonaPlex")) {
624452
624870
  registry2.register({
624453
624871
  name: "PersonaPlex",
@@ -624459,9 +624877,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
624459
624877
  }
624460
624878
  }
624461
624879
  }
624462
- const nexusPidFile = join132(repoRoot, ".oa", "nexus", "daemon.pid");
624463
- if (existsSync115(nexusPidFile)) {
624464
- const nPid = parseInt(readFileSync96(nexusPidFile, "utf8").trim(), 10);
624880
+ const nexusPidFile = join133(repoRoot, ".oa", "nexus", "daemon.pid");
624881
+ if (existsSync116(nexusPidFile)) {
624882
+ const nPid = parseInt(readFileSync97(nexusPidFile, "utf8").trim(), 10);
624465
624883
  if (nPid > 0 && !registry2.daemons.has("Nexus")) {
624466
624884
  try {
624467
624885
  process.kill(nPid, 0);
@@ -624900,9 +625318,9 @@ Execute this skill now. Follow the behavioral guidance above.`;
624900
625318
  }
624901
625319
  }
624902
625320
  const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
624903
- const isImage = isImagePath(cleanPath) && existsSync115(resolve40(repoRoot, cleanPath));
624904
- const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync115(resolve40(repoRoot, cleanPath));
624905
- const isMarkdown = !isImage && !isMedia && /\.(md|markdown)$/i.test(cleanPath) && existsSync115(resolve40(repoRoot, cleanPath));
625321
+ const isImage = isImagePath(cleanPath) && existsSync116(resolve40(repoRoot, cleanPath));
625322
+ const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync116(resolve40(repoRoot, cleanPath));
625323
+ const isMarkdown = !isImage && !isMedia && /\.(md|markdown)$/i.test(cleanPath) && existsSync116(resolve40(repoRoot, cleanPath));
624906
625324
  if (activeTask) {
624907
625325
  if (activeTask.runner.isPaused) {
624908
625326
  activeTask.runner.resume();
@@ -624911,7 +625329,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
624911
625329
  if (isImage) {
624912
625330
  try {
624913
625331
  const imgPath = resolve40(repoRoot, cleanPath);
624914
- const imgBuffer = readFileSync96(imgPath);
625332
+ const imgBuffer = readFileSync97(imgPath);
624915
625333
  const base642 = imgBuffer.toString("base64");
624916
625334
  const ext = extname13(cleanPath).toLowerCase();
624917
625335
  const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
@@ -625087,7 +625505,7 @@ ${result.text}`;
625087
625505
  if (isMarkdown && fullInput === input) {
625088
625506
  try {
625089
625507
  const mdPath = resolve40(repoRoot, cleanPath);
625090
- const mdContent = readFileSync96(mdPath, "utf8");
625508
+ const mdContent = readFileSync97(mdPath, "utf8");
625091
625509
  const { parseMcpMarkdown: parseMcpMarkdown2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports));
625092
625510
  const result = parseMcpMarkdown2(mdContent);
625093
625511
  if (result.servers.length > 0) {
@@ -625447,6 +625865,18 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
625447
625865
  }
625448
625866
  showPrompt();
625449
625867
  }
625868
+ rl.on("ctrl-v", async () => {
625869
+ try {
625870
+ const result = await commandCtx.attachClipboardImage?.();
625871
+ if (result?.ok) {
625872
+ process.stderr.write(c3.green("📎 " + result.message + "\n"));
625873
+ } else {
625874
+ process.stderr.write(c3.yellow("⚠ " + (result?.message ?? "paste failed") + "\n"));
625875
+ }
625876
+ } catch (err) {
625877
+ process.stderr.write(c3.red("Clipboard paste failed\n"));
625878
+ }
625879
+ });
625450
625880
  rl.on("close", () => {
625451
625881
  if (peerMesh) {
625452
625882
  peerMesh.stop().catch(() => {
@@ -625625,11 +626055,11 @@ async function runWithTUI(task, config, repoPath, callbacks) {
625625
626055
  const handle2 = startTask(task, config, repoRoot);
625626
626056
  await handle2.promise;
625627
626057
  try {
625628
- const ikDir = join132(repoRoot, ".oa", "identity");
625629
- const ikFile = join132(ikDir, "self-state.json");
626058
+ const ikDir = join133(repoRoot, ".oa", "identity");
626059
+ const ikFile = join133(ikDir, "self-state.json");
625630
626060
  let ikState;
625631
- if (existsSync115(ikFile)) {
625632
- ikState = JSON.parse(readFileSync96(ikFile, "utf8"));
626061
+ if (existsSync116(ikFile)) {
626062
+ ikState = JSON.parse(readFileSync97(ikFile, "utf8"));
625633
626063
  } else {
625634
626064
  mkdirSync71(ikDir, { recursive: true });
625635
626065
  ikState = {
@@ -625684,7 +626114,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
625684
626114
  );
625685
626115
  ikState.session_count = (ikState.session_count || 0) + 1;
625686
626116
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
625687
- writeFileSync64(ikFile, JSON.stringify(ikState, null, 2));
626117
+ writeFileSync65(ikFile, JSON.stringify(ikState, null, 2));
625688
626118
  } catch (ikErr) {
625689
626119
  }
625690
626120
  try {
@@ -625697,12 +626127,12 @@ async function runWithTUI(task, config, repoPath, callbacks) {
625697
626127
  );
625698
626128
  } catch {
625699
626129
  try {
625700
- const archeDir = join132(repoRoot, ".oa", "arche");
625701
- const archeFile = join132(archeDir, "variants.json");
626130
+ const archeDir = join133(repoRoot, ".oa", "arche");
626131
+ const archeFile = join133(archeDir, "variants.json");
625702
626132
  let variants = [];
625703
626133
  try {
625704
- if (existsSync115(archeFile))
625705
- variants = JSON.parse(readFileSync96(archeFile, "utf8"));
626134
+ if (existsSync116(archeFile))
626135
+ variants = JSON.parse(readFileSync97(archeFile, "utf8"));
625706
626136
  } catch {
625707
626137
  }
625708
626138
  variants.push({
@@ -625717,20 +626147,20 @@ async function runWithTUI(task, config, repoPath, callbacks) {
625717
626147
  });
625718
626148
  if (variants.length > 50) variants = variants.slice(-50);
625719
626149
  mkdirSync71(archeDir, { recursive: true });
625720
- writeFileSync64(archeFile, JSON.stringify(variants, null, 2));
626150
+ writeFileSync65(archeFile, JSON.stringify(variants, null, 2));
625721
626151
  } catch {
625722
626152
  }
625723
626153
  }
625724
626154
  try {
625725
- const metaFile = join132(
626155
+ const metaFile = join133(
625726
626156
  repoRoot,
625727
626157
  ".oa",
625728
626158
  "memory",
625729
626159
  "metabolism",
625730
626160
  "store.json"
625731
626161
  );
625732
- if (existsSync115(metaFile)) {
625733
- const store2 = JSON.parse(readFileSync96(metaFile, "utf8"));
626162
+ if (existsSync116(metaFile)) {
626163
+ const store2 = JSON.parse(readFileSync97(metaFile, "utf8"));
625734
626164
  const surfaced = store2.filter(
625735
626165
  (m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15
625736
626166
  ).sort(
@@ -625748,7 +626178,7 @@ async function runWithTUI(task, config, repoPath, callbacks) {
625748
626178
  updated = true;
625749
626179
  }
625750
626180
  if (updated) {
625751
- writeFileSync64(metaFile, JSON.stringify(store2, null, 2));
626181
+ writeFileSync65(metaFile, JSON.stringify(store2, null, 2));
625752
626182
  }
625753
626183
  }
625754
626184
  } catch {
@@ -625806,9 +626236,9 @@ Rules:
625806
626236
  try {
625807
626237
  const { initDb: initDb2 } = __require("@open-agents/memory");
625808
626238
  const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@open-agents/memory");
625809
- const dbDir = join132(repoRoot, ".oa", "memory");
626239
+ const dbDir = join133(repoRoot, ".oa", "memory");
625810
626240
  mkdirSync71(dbDir, { recursive: true });
625811
- const db = initDb2(join132(dbDir, "structured.db"));
626241
+ const db = initDb2(join133(dbDir, "structured.db"));
625812
626242
  const memStore = new ProceduralMemoryStore2(db);
625813
626243
  memStore.createWithEmbedding(
625814
626244
  {
@@ -625828,12 +626258,12 @@ Rules:
625828
626258
  db.close();
625829
626259
  } catch {
625830
626260
  }
625831
- const metaDir = join132(repoRoot, ".oa", "memory", "metabolism");
625832
- const storeFile = join132(metaDir, "store.json");
626261
+ const metaDir = join133(repoRoot, ".oa", "memory", "metabolism");
626262
+ const storeFile = join133(metaDir, "store.json");
625833
626263
  let store2 = [];
625834
626264
  try {
625835
- if (existsSync115(storeFile))
625836
- store2 = JSON.parse(readFileSync96(storeFile, "utf8"));
626265
+ if (existsSync116(storeFile))
626266
+ store2 = JSON.parse(readFileSync97(storeFile, "utf8"));
625837
626267
  } catch {
625838
626268
  }
625839
626269
  store2.push({
@@ -625857,31 +626287,31 @@ Rules:
625857
626287
  });
625858
626288
  if (store2.length > 100) store2 = store2.slice(-100);
625859
626289
  mkdirSync71(metaDir, { recursive: true });
625860
- writeFileSync64(storeFile, JSON.stringify(store2, null, 2));
626290
+ writeFileSync65(storeFile, JSON.stringify(store2, null, 2));
625861
626291
  }
625862
626292
  }
625863
626293
  } catch {
625864
626294
  }
625865
626295
  try {
625866
- const cohereSettingsFile = join132(repoRoot, ".oa", "settings.json");
626296
+ const cohereSettingsFile = join133(repoRoot, ".oa", "settings.json");
625867
626297
  let cohereActive = false;
625868
626298
  try {
625869
- if (existsSync115(cohereSettingsFile)) {
625870
- const settings = JSON.parse(readFileSync96(cohereSettingsFile, "utf8"));
626299
+ if (existsSync116(cohereSettingsFile)) {
626300
+ const settings = JSON.parse(readFileSync97(cohereSettingsFile, "utf8"));
625871
626301
  cohereActive = settings.cohere === true;
625872
626302
  }
625873
626303
  } catch {
625874
626304
  }
625875
626305
  if (cohereActive) {
625876
- const metaFile = join132(
626306
+ const metaFile = join133(
625877
626307
  repoRoot,
625878
626308
  ".oa",
625879
626309
  "memory",
625880
626310
  "metabolism",
625881
626311
  "store.json"
625882
626312
  );
625883
- if (existsSync115(metaFile)) {
625884
- const store2 = JSON.parse(readFileSync96(metaFile, "utf8"));
626313
+ if (existsSync116(metaFile)) {
626314
+ const store2 = JSON.parse(readFileSync97(metaFile, "utf8"));
625885
626315
  const latest = store2.filter(
625886
626316
  (m2) => m2.sourceTrace === "trajectory-extraction" || m2.sourceTrace === "llm-trajectory-extraction"
625887
626317
  ).slice(-1)[0];
@@ -625908,9 +626338,9 @@ Rules:
625908
626338
  }
625909
626339
  } catch (err) {
625910
626340
  try {
625911
- const ikFile = join132(repoRoot, ".oa", "identity", "self-state.json");
625912
- if (existsSync115(ikFile)) {
625913
- const ikState = JSON.parse(readFileSync96(ikFile, "utf8"));
626341
+ const ikFile = join133(repoRoot, ".oa", "identity", "self-state.json");
626342
+ if (existsSync116(ikFile)) {
626343
+ const ikState = JSON.parse(readFileSync97(ikFile, "utf8"));
625914
626344
  ikState.homeostasis.uncertainty = Math.min(
625915
626345
  1,
625916
626346
  ikState.homeostasis.uncertainty + 0.1
@@ -625921,17 +626351,17 @@ Rules:
625921
626351
  );
625922
626352
  ikState.session_count = (ikState.session_count || 0) + 1;
625923
626353
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
625924
- writeFileSync64(ikFile, JSON.stringify(ikState, null, 2));
626354
+ writeFileSync65(ikFile, JSON.stringify(ikState, null, 2));
625925
626355
  }
625926
- const metaFile = join132(
626356
+ const metaFile = join133(
625927
626357
  repoRoot,
625928
626358
  ".oa",
625929
626359
  "memory",
625930
626360
  "metabolism",
625931
626361
  "store.json"
625932
626362
  );
625933
- if (existsSync115(metaFile)) {
625934
- const store2 = JSON.parse(readFileSync96(metaFile, "utf8"));
626363
+ if (existsSync116(metaFile)) {
626364
+ const store2 = JSON.parse(readFileSync97(metaFile, "utf8"));
625935
626365
  const surfaced = store2.filter(
625936
626366
  (m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15
625937
626367
  ).sort(
@@ -625949,15 +626379,15 @@ Rules:
625949
626379
  (item.scores.confidence || 0.5) - 0.02
625950
626380
  );
625951
626381
  }
625952
- writeFileSync64(metaFile, JSON.stringify(store2, null, 2));
626382
+ writeFileSync65(metaFile, JSON.stringify(store2, null, 2));
625953
626383
  }
625954
626384
  try {
625955
- const archeDir = join132(repoRoot, ".oa", "arche");
625956
- const archeFile = join132(archeDir, "variants.json");
626385
+ const archeDir = join133(repoRoot, ".oa", "arche");
626386
+ const archeFile = join133(archeDir, "variants.json");
625957
626387
  let variants = [];
625958
626388
  try {
625959
- if (existsSync115(archeFile))
625960
- variants = JSON.parse(readFileSync96(archeFile, "utf8"));
626389
+ if (existsSync116(archeFile))
626390
+ variants = JSON.parse(readFileSync97(archeFile, "utf8"));
625961
626391
  } catch {
625962
626392
  }
625963
626393
  variants.push({
@@ -625972,7 +626402,7 @@ Rules:
625972
626402
  });
625973
626403
  if (variants.length > 50) variants = variants.slice(-50);
625974
626404
  mkdirSync71(archeDir, { recursive: true });
625975
- writeFileSync64(archeFile, JSON.stringify(variants, null, 2));
626405
+ writeFileSync65(archeFile, JSON.stringify(variants, null, 2));
625976
626406
  } catch {
625977
626407
  }
625978
626408
  } catch {
@@ -626063,12 +626493,12 @@ __export(run_exports, {
626063
626493
  });
626064
626494
  import { resolve as resolve41 } from "node:path";
626065
626495
  import { spawn as spawn28 } from "node:child_process";
626066
- import { mkdirSync as mkdirSync72, writeFileSync as writeFileSync65, readFileSync as readFileSync97, readdirSync as readdirSync41, existsSync as existsSync116 } from "node:fs";
626496
+ import { mkdirSync as mkdirSync72, writeFileSync as writeFileSync66, readFileSync as readFileSync98, readdirSync as readdirSync41, existsSync as existsSync117 } from "node:fs";
626067
626497
  import { randomBytes as randomBytes24 } from "node:crypto";
626068
- import { join as join133 } from "node:path";
626498
+ import { join as join134 } from "node:path";
626069
626499
  function jobsDir2(repoPath) {
626070
626500
  const root = resolve41(repoPath ?? process.cwd());
626071
- const dir = join133(root, ".oa", "jobs");
626501
+ const dir = join134(root, ".oa", "jobs");
626072
626502
  mkdirSync72(dir, { recursive: true });
626073
626503
  return dir;
626074
626504
  }
@@ -626191,7 +626621,7 @@ async function runBackground(task, config, opts) {
626191
626621
  }
626192
626622
  });
626193
626623
  job.pid = child.pid ?? 0;
626194
- writeFileSync65(join133(dir, `${id}.json`), JSON.stringify(job, null, 2));
626624
+ writeFileSync66(join134(dir, `${id}.json`), JSON.stringify(job, null, 2));
626195
626625
  let output = "";
626196
626626
  child.stdout?.on("data", (chunk) => {
626197
626627
  output += chunk.toString();
@@ -626207,7 +626637,7 @@ async function runBackground(task, config, opts) {
626207
626637
  job.summary = result.summary;
626208
626638
  job.durationMs = result.durationMs;
626209
626639
  job.error = result.error;
626210
- writeFileSync65(join133(dir, `${id}.json`), JSON.stringify(job, null, 2));
626640
+ writeFileSync66(join134(dir, `${id}.json`), JSON.stringify(job, null, 2));
626211
626641
  } catch {
626212
626642
  }
626213
626643
  });
@@ -626223,13 +626653,13 @@ async function runBackground(task, config, opts) {
626223
626653
  }
626224
626654
  function statusCommand(jobId, repoPath) {
626225
626655
  const dir = jobsDir2(repoPath);
626226
- const file = join133(dir, `${jobId}.json`);
626227
- if (!existsSync116(file)) {
626656
+ const file = join134(dir, `${jobId}.json`);
626657
+ if (!existsSync117(file)) {
626228
626658
  console.error(`Job not found: ${jobId}`);
626229
626659
  console.log(`Available jobs: oa jobs`);
626230
626660
  process.exit(1);
626231
626661
  }
626232
- const job = JSON.parse(readFileSync97(file, "utf-8"));
626662
+ const job = JSON.parse(readFileSync98(file, "utf-8"));
626233
626663
  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`;
626234
626664
  const icon = job.status === "completed" ? "✓" : job.status === "failed" ? "✗" : "●";
626235
626665
  console.log(`${icon} ${job.id} [${job.status}] ${runtime}`);
@@ -626250,7 +626680,7 @@ function jobsCommand(repoPath) {
626250
626680
  console.log("Jobs:");
626251
626681
  for (const file of files) {
626252
626682
  try {
626253
- const job = JSON.parse(readFileSync97(join133(dir, file), "utf-8"));
626683
+ const job = JSON.parse(readFileSync98(join134(dir, file), "utf-8"));
626254
626684
  const icon = job.status === "completed" ? "✓" : job.status === "failed" ? "✗" : "●";
626255
626685
  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`;
626256
626686
  const cleanListTask = cleanForStorage(job.task) || job.task;
@@ -626274,13 +626704,13 @@ __export(index_repo_exports, {
626274
626704
  indexRepoCommand: () => indexRepoCommand
626275
626705
  });
626276
626706
  import { resolve as resolve42 } from "node:path";
626277
- import { existsSync as existsSync117, statSync as statSync37 } from "node:fs";
626707
+ import { existsSync as existsSync118, statSync as statSync37 } from "node:fs";
626278
626708
  import { cwd as cwd2 } from "node:process";
626279
626709
  async function indexRepoCommand(opts, _config3) {
626280
626710
  const repoRoot = resolve42(opts.repoPath ?? cwd2());
626281
626711
  printHeader("Index Repository");
626282
626712
  printInfo(`Indexing: ${repoRoot}`);
626283
- if (!existsSync117(repoRoot)) {
626713
+ if (!existsSync118(repoRoot)) {
626284
626714
  printError(`Path does not exist: ${repoRoot}`);
626285
626715
  process.exit(1);
626286
626716
  }
@@ -626532,7 +626962,7 @@ var config_exports2 = {};
626532
626962
  __export(config_exports2, {
626533
626963
  configCommand: () => configCommand
626534
626964
  });
626535
- import { join as join134, resolve as resolve43 } from "node:path";
626965
+ import { join as join135, resolve as resolve43 } from "node:path";
626536
626966
  import { homedir as homedir47 } from "node:os";
626537
626967
  import { cwd as cwd3 } from "node:process";
626538
626968
  function redactIfSensitive(key, value2) {
@@ -626614,7 +627044,7 @@ function handleShow(opts, config) {
626614
627044
  }
626615
627045
  }
626616
627046
  printSection("Config File");
626617
- printInfo(`~/.open-agents/config.json (${join134(homedir47(), ".open-agents", "config.json")})`);
627047
+ printInfo(`~/.open-agents/config.json (${join135(homedir47(), ".open-agents", "config.json")})`);
626618
627048
  printSection("Priority Chain");
626619
627049
  printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
626620
627050
  printInfo(" 2. Project .oa/settings.json (--local)");
@@ -626653,7 +627083,7 @@ function handleSet(opts, _config3) {
626653
627083
  const coerced = coerceForSettings(key, value2);
626654
627084
  saveProjectSettings(repoRoot, { [key]: coerced });
626655
627085
  printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value2)}`);
626656
- printInfo(`Saved to ${join134(repoRoot, ".oa", "settings.json")}`);
627086
+ printInfo(`Saved to ${join135(repoRoot, ".oa", "settings.json")}`);
626657
627087
  printInfo("This override applies only when running in this workspace.");
626658
627088
  } catch (err) {
626659
627089
  printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
@@ -626837,8 +627267,8 @@ __export(eval_exports, {
626837
627267
  evalCommand: () => evalCommand
626838
627268
  });
626839
627269
  import { tmpdir as tmpdir22 } from "node:os";
626840
- import { mkdirSync as mkdirSync73, writeFileSync as writeFileSync66 } from "node:fs";
626841
- import { join as join135 } from "node:path";
627270
+ import { mkdirSync as mkdirSync73, writeFileSync as writeFileSync67 } from "node:fs";
627271
+ import { join as join136 } from "node:path";
626842
627272
  async function evalCommand(opts, config) {
626843
627273
  const suiteName = opts.suite ?? "basic";
626844
627274
  const suite = SUITES[suiteName];
@@ -626967,10 +627397,10 @@ async function evalCommand(opts, config) {
626967
627397
  process.exit(failed > 0 ? 1 : 0);
626968
627398
  }
626969
627399
  function createTempEvalRepo() {
626970
- const dir = join135(tmpdir22(), `open-agents-eval-${Date.now()}`);
627400
+ const dir = join136(tmpdir22(), `open-agents-eval-${Date.now()}`);
626971
627401
  mkdirSync73(dir, { recursive: true });
626972
- writeFileSync66(
626973
- join135(dir, "package.json"),
627402
+ writeFileSync67(
627403
+ join136(dir, "package.json"),
626974
627404
  JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n",
626975
627405
  "utf8"
626976
627406
  );
@@ -627034,7 +627464,7 @@ init_typed_node_events();
627034
627464
  import { parseArgs as nodeParseArgs2 } from "node:util";
627035
627465
  import { createRequire as createRequire7 } from "node:module";
627036
627466
  import { fileURLToPath as fileURLToPath19 } from "node:url";
627037
- import { dirname as dirname38, join as join136 } from "node:path";
627467
+ import { dirname as dirname38, join as join137 } from "node:path";
627038
627468
 
627039
627469
  // packages/cli/src/cli.ts
627040
627470
  init_typed_node_events();
@@ -627174,7 +627604,7 @@ init_output();
627174
627604
  function getVersion5() {
627175
627605
  try {
627176
627606
  const require4 = createRequire7(import.meta.url);
627177
- const pkgPath = join136(dirname38(fileURLToPath19(import.meta.url)), "..", "package.json");
627607
+ const pkgPath = join137(dirname38(fileURLToPath19(import.meta.url)), "..", "package.json");
627178
627608
  const pkg = require4(pkgPath);
627179
627609
  return pkg.version;
627180
627610
  } catch {
@@ -627489,11 +627919,11 @@ function crashLog(label, err) {
627489
627919
  `;
627490
627920
  try {
627491
627921
  const { appendFileSync: appendFileSync9, mkdirSync: mkdirSync74 } = __require("node:fs");
627492
- const { join: join137 } = __require("node:path");
627922
+ const { join: join138 } = __require("node:path");
627493
627923
  const { homedir: homedir48 } = __require("node:os");
627494
- const logDir = join137(homedir48(), ".open-agents");
627924
+ const logDir = join138(homedir48(), ".open-agents");
627495
627925
  mkdirSync74(logDir, { recursive: true });
627496
- appendFileSync9(join137(logDir, "crash.log"), logLine);
627926
+ appendFileSync9(join138(logDir, "crash.log"), logLine);
627497
627927
  } catch {
627498
627928
  }
627499
627929
  try {