open-agents-ai 0.187.383 → 0.187.385

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +139 -70
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10955,11 +10955,11 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
10955
10955
  nodePaths.push(globalDir2);
10956
10956
  } catch {
10957
10957
  }
10958
- const { openSync: openSync2, closeSync: closeSync2 } = await import("node:fs");
10958
+ const { openSync: openSync3, closeSync: closeSync3 } = await import("node:fs");
10959
10959
  const daemonLogPath = join15(this.nexusDir, "daemon.log");
10960
10960
  const daemonErrPath = join15(this.nexusDir, "daemon.err");
10961
- const outFd = openSync2(daemonLogPath, "w");
10962
- const errFd = openSync2(daemonErrPath, "w");
10961
+ const outFd = openSync3(daemonLogPath, "w");
10962
+ const errFd = openSync3(daemonErrPath, "w");
10963
10963
  const child = spawn2("node", [daemonPath, this.nexusDir, agentName, agentType], {
10964
10964
  detached: true,
10965
10965
  stdio: ["ignore", outFd, errFd],
@@ -10968,11 +10968,11 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
10968
10968
  });
10969
10969
  child.unref();
10970
10970
  try {
10971
- closeSync2(outFd);
10971
+ closeSync3(outFd);
10972
10972
  } catch {
10973
10973
  }
10974
10974
  try {
10975
- closeSync2(errFd);
10975
+ closeSync3(errFd);
10976
10976
  } catch {
10977
10977
  }
10978
10978
  const statusFile = join15(this.nexusDir, "status.json");
@@ -33929,11 +33929,11 @@ var init_storage = __esm({
33929
33929
  */
33930
33930
  async put(cid, block, options2 = {}) {
33931
33931
  options2?.signal?.throwIfAborted();
33932
- const releaseLock = await this.lock.readLock();
33932
+ const releaseLock2 = await this.lock.readLock();
33933
33933
  try {
33934
33934
  return await this.child.put(cid, block, options2);
33935
33935
  } finally {
33936
- releaseLock();
33936
+ releaseLock2();
33937
33937
  }
33938
33938
  }
33939
33939
  /**
@@ -33941,11 +33941,11 @@ var init_storage = __esm({
33941
33941
  */
33942
33942
  async *putMany(blocks, options2 = {}) {
33943
33943
  options2?.signal?.throwIfAborted();
33944
- const releaseLock = await this.lock.readLock();
33944
+ const releaseLock2 = await this.lock.readLock();
33945
33945
  try {
33946
33946
  yield* this.child.putMany(blocks, options2);
33947
33947
  } finally {
33948
- releaseLock();
33948
+ releaseLock2();
33949
33949
  }
33950
33950
  }
33951
33951
  /**
@@ -33953,11 +33953,11 @@ var init_storage = __esm({
33953
33953
  */
33954
33954
  async *get(cid, options2 = {}) {
33955
33955
  options2?.signal?.throwIfAborted();
33956
- const releaseLock = await this.lock.readLock();
33956
+ const releaseLock2 = await this.lock.readLock();
33957
33957
  try {
33958
33958
  yield* this.child.get(cid, options2);
33959
33959
  } finally {
33960
- releaseLock();
33960
+ releaseLock2();
33961
33961
  }
33962
33962
  }
33963
33963
  /**
@@ -33965,11 +33965,11 @@ var init_storage = __esm({
33965
33965
  */
33966
33966
  async *getMany(cids, options2 = {}) {
33967
33967
  options2?.signal?.throwIfAborted();
33968
- const releaseLock = await this.lock.readLock();
33968
+ const releaseLock2 = await this.lock.readLock();
33969
33969
  try {
33970
33970
  yield* this.child.getMany(cids, options2);
33971
33971
  } finally {
33972
- releaseLock();
33972
+ releaseLock2();
33973
33973
  }
33974
33974
  }
33975
33975
  /**
@@ -33977,14 +33977,14 @@ var init_storage = __esm({
33977
33977
  */
33978
33978
  async delete(cid, options2 = {}) {
33979
33979
  options2?.signal?.throwIfAborted();
33980
- const releaseLock = await this.lock.writeLock();
33980
+ const releaseLock2 = await this.lock.writeLock();
33981
33981
  try {
33982
33982
  if (await this.pins.isPinned(cid)) {
33983
33983
  throw new BlockPinnedError("Block was pinned - please unpin and try again");
33984
33984
  }
33985
33985
  await this.child.delete(cid, options2);
33986
33986
  } finally {
33987
- releaseLock();
33987
+ releaseLock2();
33988
33988
  }
33989
33989
  }
33990
33990
  /**
@@ -33992,7 +33992,7 @@ var init_storage = __esm({
33992
33992
  */
33993
33993
  async *deleteMany(cids, options2 = {}) {
33994
33994
  options2?.signal?.throwIfAborted();
33995
- const releaseLock = await this.lock.writeLock();
33995
+ const releaseLock2 = await this.lock.writeLock();
33996
33996
  try {
33997
33997
  const storage = this;
33998
33998
  yield* this.child.deleteMany((async function* () {
@@ -34004,25 +34004,25 @@ var init_storage = __esm({
34004
34004
  }
34005
34005
  })(), options2);
34006
34006
  } finally {
34007
- releaseLock();
34007
+ releaseLock2();
34008
34008
  }
34009
34009
  }
34010
34010
  async has(cid, options2 = {}) {
34011
34011
  options2?.signal?.throwIfAborted();
34012
- const releaseLock = await this.lock.readLock();
34012
+ const releaseLock2 = await this.lock.readLock();
34013
34013
  try {
34014
34014
  return await this.child.has(cid, options2);
34015
34015
  } finally {
34016
- releaseLock();
34016
+ releaseLock2();
34017
34017
  }
34018
34018
  }
34019
34019
  async *getAll(options2 = {}) {
34020
34020
  options2?.signal?.throwIfAborted();
34021
- const releaseLock = await this.lock.readLock();
34021
+ const releaseLock2 = await this.lock.readLock();
34022
34022
  try {
34023
34023
  yield* this.child.getAll(options2);
34024
34024
  } finally {
34025
- releaseLock();
34025
+ releaseLock2();
34026
34026
  }
34027
34027
  }
34028
34028
  createSession(root, options2) {
@@ -36869,7 +36869,7 @@ var init_src38 = __esm({
36869
36869
  this.events.dispatchEvent(new CustomEvent("stop", { detail: this }));
36870
36870
  }
36871
36871
  async gc(options2 = {}) {
36872
- const releaseLock = await this.blockstore.lock.writeLock();
36872
+ const releaseLock2 = await this.blockstore.lock.writeLock();
36873
36873
  try {
36874
36874
  const helia = this;
36875
36875
  const blockstore = this.blockstore.unwrap();
@@ -36889,7 +36889,7 @@ var init_src38 = __esm({
36889
36889
  }
36890
36890
  })()));
36891
36891
  } finally {
36892
- releaseLock();
36892
+ releaseLock2();
36893
36893
  }
36894
36894
  this.log("gc finished");
36895
36895
  }
@@ -529603,7 +529603,7 @@ __export(oa_directory_exports, {
529603
529603
  writeIndexData: () => writeIndexData,
529604
529604
  writeIndexMeta: () => writeIndexMeta
529605
529605
  });
529606
- import { existsSync as existsSync57, mkdirSync as mkdirSync32, readFileSync as readFileSync44, writeFileSync as writeFileSync29, readdirSync as readdirSync14, statSync as statSync17, unlinkSync as unlinkSync14 } from "node:fs";
529606
+ import { existsSync as existsSync57, mkdirSync as mkdirSync32, readFileSync as readFileSync44, writeFileSync as writeFileSync29, readdirSync as readdirSync14, statSync as statSync17, unlinkSync as unlinkSync14, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
529607
529607
  import { join as join75, relative as relative6, basename as basename13 } from "node:path";
529608
529608
  import { homedir as homedir25 } from "node:os";
529609
529609
  function initOaDirectory(repoRoot) {
@@ -529838,6 +529838,54 @@ function loadPendingTask(repoRoot) {
529838
529838
  return null;
529839
529839
  }
529840
529840
  }
529841
+ function acquireLock(lockPath) {
529842
+ const startTime = Date.now();
529843
+ const pid = process.pid;
529844
+ for (let attempt = 0; attempt < LOCK_RETRY_MAX; attempt++) {
529845
+ try {
529846
+ const fd = openSync2(lockPath, "wx");
529847
+ const lockData = JSON.stringify({ pid, acquiredAt: Date.now() });
529848
+ writeFileSync29(fd, lockData);
529849
+ closeSync2(fd);
529850
+ return true;
529851
+ } catch (err) {
529852
+ if (existsSync57(lockPath)) {
529853
+ try {
529854
+ const lockContent = readFileSync44(lockPath, "utf-8");
529855
+ const lock = JSON.parse(lockContent);
529856
+ const lockAge = Date.now() - lock.acquiredAt;
529857
+ if (lockAge > LOCK_TIMEOUT_MS) {
529858
+ try {
529859
+ unlinkSync14(lockPath);
529860
+ } catch {
529861
+ }
529862
+ }
529863
+ } catch {
529864
+ try {
529865
+ unlinkSync14(lockPath);
529866
+ } catch {
529867
+ }
529868
+ }
529869
+ }
529870
+ if (Date.now() - startTime < LOCK_TIMEOUT_MS) {
529871
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, LOCK_RETRY_MS);
529872
+ }
529873
+ }
529874
+ }
529875
+ return false;
529876
+ }
529877
+ function releaseLock(lockPath) {
529878
+ try {
529879
+ if (existsSync57(lockPath)) {
529880
+ const lockContent = readFileSync44(lockPath, "utf-8");
529881
+ const lock = JSON.parse(lockContent);
529882
+ if (lock.pid === process.pid) {
529883
+ unlinkSync14(lockPath);
529884
+ }
529885
+ }
529886
+ } catch {
529887
+ }
529888
+ }
529841
529889
  function normalizeSessionText(raw, maxLen = 500) {
529842
529890
  if (!raw) return "";
529843
529891
  return String(raw).replace(/\s+/g, " ").trim().slice(0, maxLen);
@@ -529928,55 +529976,66 @@ function saveSessionContext(repoRoot, entry) {
529928
529976
  const contextDir = join75(repoRoot, OA_DIR, "context");
529929
529977
  mkdirSync32(contextDir, { recursive: true });
529930
529978
  const filePath = join75(contextDir, CONTEXT_SAVE_FILE);
529931
- let ctx3;
529979
+ const lockPath = join75(contextDir, CONTEXT_SAVE_FILE + ".lock");
529980
+ const locked = acquireLock(lockPath);
529981
+ if (!locked) {
529982
+ console.warn("[saveSessionContext] Could not acquire lock, proceeding without mutex");
529983
+ }
529932
529984
  try {
529933
- if (existsSync57(filePath)) {
529934
- ctx3 = JSON.parse(readFileSync44(filePath, "utf-8"));
529935
- } else {
529985
+ let ctx3;
529986
+ try {
529987
+ if (existsSync57(filePath)) {
529988
+ ctx3 = JSON.parse(readFileSync44(filePath, "utf-8"));
529989
+ } else {
529990
+ ctx3 = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
529991
+ }
529992
+ } catch {
529936
529993
  ctx3 = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
529937
529994
  }
529938
- } catch {
529939
- ctx3 = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
529940
- }
529941
- const normalizedEntry = normalizeSessionContextEntry(entry);
529942
- const exactIndex = lastMatchingIndex(
529943
- ctx3.entries,
529944
- (existing) => isExactSessionDuplicate(normalizeSessionContextEntry(existing), normalizedEntry)
529945
- );
529946
- if (exactIndex >= 0) {
529947
- ctx3.entries[exactIndex] = mergeSessionContextEntry(ctx3.entries[exactIndex], normalizedEntry);
529948
- } else {
529949
- const relatedIndex = lastMatchingIndex(ctx3.entries, (existing) => {
529950
- const normalizedExisting = normalizeSessionContextEntry(existing);
529951
- return sameTask(normalizedExisting, normalizedEntry) && isWithinReplaceWindow(normalizedExisting, normalizedEntry);
529952
- });
529953
- if (relatedIndex >= 0) {
529954
- const previous = normalizeSessionContextEntry(ctx3.entries[relatedIndex]);
529955
- const shouldDropPartialResave = previous.completed && !normalizedEntry.completed;
529956
- const shouldReplaceExisting = !previous.completed || previous.completed === normalizedEntry.completed && normalizedEntry.source === "manual";
529957
- if (!shouldDropPartialResave) {
529958
- if (shouldReplaceExisting) {
529959
- ctx3.entries[relatedIndex] = mergeSessionContextEntry(ctx3.entries[relatedIndex], normalizedEntry);
529960
- } else {
529961
- ctx3.entries.push(normalizedEntry);
529995
+ const normalizedEntry = normalizeSessionContextEntry(entry);
529996
+ const exactIndex = lastMatchingIndex(
529997
+ ctx3.entries,
529998
+ (existing) => isExactSessionDuplicate(normalizeSessionContextEntry(existing), normalizedEntry)
529999
+ );
530000
+ if (exactIndex >= 0) {
530001
+ ctx3.entries[exactIndex] = mergeSessionContextEntry(ctx3.entries[exactIndex], normalizedEntry);
530002
+ } else {
530003
+ const relatedIndex = lastMatchingIndex(ctx3.entries, (existing) => {
530004
+ const normalizedExisting = normalizeSessionContextEntry(existing);
530005
+ return sameTask(normalizedExisting, normalizedEntry) && isWithinReplaceWindow(normalizedExisting, normalizedEntry);
530006
+ });
530007
+ if (relatedIndex >= 0) {
530008
+ const previous = normalizeSessionContextEntry(ctx3.entries[relatedIndex]);
530009
+ const shouldDropPartialResave = previous.completed && !normalizedEntry.completed;
530010
+ const shouldReplaceExisting = !previous.completed || normalizedEntry.source === "manual" || previous.completed && normalizedEntry.completed;
530011
+ if (!shouldDropPartialResave) {
530012
+ if (shouldReplaceExisting) {
530013
+ ctx3.entries[relatedIndex] = mergeSessionContextEntry(ctx3.entries[relatedIndex], normalizedEntry);
530014
+ } else {
530015
+ ctx3.entries.push(normalizedEntry);
530016
+ }
529962
530017
  }
530018
+ } else {
530019
+ ctx3.entries.push(normalizedEntry);
529963
530020
  }
529964
- } else {
529965
- ctx3.entries.push(normalizedEntry);
529966
530021
  }
529967
- }
529968
- if (ctx3.entries.length > ctx3.maxEntries) {
529969
- ctx3.entries = ctx3.entries.slice(-ctx3.maxEntries);
529970
- }
529971
- ctx3.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
529972
- writeFileSync29(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
529973
- try {
529974
- writeFileSync29(
529975
- join75(contextDir, "session-diary.md"),
529976
- renderSessionDiary(ctx3.entries.slice(-10)),
529977
- "utf-8"
529978
- );
529979
- } catch {
530022
+ if (ctx3.entries.length > ctx3.maxEntries) {
530023
+ ctx3.entries = ctx3.entries.slice(-ctx3.maxEntries);
530024
+ }
530025
+ ctx3.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
530026
+ writeFileSync29(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
530027
+ try {
530028
+ writeFileSync29(
530029
+ join75(contextDir, "session-diary.md"),
530030
+ renderSessionDiary(ctx3.entries.slice(-10)),
530031
+ "utf-8"
530032
+ );
530033
+ } catch {
530034
+ }
530035
+ } finally {
530036
+ if (locked) {
530037
+ releaseLock(lockPath);
530038
+ }
529980
530039
  }
529981
530040
  }
529982
530041
  function cleanPromptForDiary(raw) {
@@ -530364,7 +530423,7 @@ function deleteUsageRecord(kind, value2, repoRoot) {
530364
530423
  remove(join75(repoRoot, OA_DIR, USAGE_HISTORY_FILE));
530365
530424
  }
530366
530425
  }
530367
- var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SAME_TASK_REPLACE_WINDOW_MS, SESSIONS_DIR, SESSIONS_INDEX, SKIP_DIRS2, HOME_SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
530426
+ var OA_DIR, SUBDIRS, CONTEXT_FILES, PENDING_TASK_FILE, CONTEXT_SAVE_FILE, MAX_CONTEXT_ENTRIES, SAME_TASK_REPLACE_WINDOW_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, LOCK_RETRY_MAX, SESSIONS_DIR, SESSIONS_INDEX, SKIP_DIRS2, HOME_SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
530368
530427
  var init_oa_directory = __esm({
530369
530428
  "packages/cli/src/tui/oa-directory.ts"() {
530370
530429
  "use strict";
@@ -530384,6 +530443,9 @@ var init_oa_directory = __esm({
530384
530443
  CONTEXT_SAVE_FILE = "session-context.json";
530385
530444
  MAX_CONTEXT_ENTRIES = 20;
530386
530445
  SAME_TASK_REPLACE_WINDOW_MS = 12 * 60 * 60 * 1e3;
530446
+ LOCK_TIMEOUT_MS = 5e3;
530447
+ LOCK_RETRY_MS = 50;
530448
+ LOCK_RETRY_MAX = 100;
530387
530449
  SESSIONS_DIR = "sessions";
530388
530450
  SESSIONS_INDEX = "sessions-index.json";
530389
530451
  SKIP_DIRS2 = /* @__PURE__ */ new Set([
@@ -564442,12 +564504,14 @@ var init_mouse_filter = __esm({
564442
564504
  onScroll = null;
564443
564505
  onActivity = null;
564444
564506
  onPointer = null;
564507
+ onKeyboard = null;
564445
564508
  flushTimer = null;
564446
- constructor(scrollHandler, activityHandler, pointerHandler) {
564509
+ constructor(scrollHandler, activityHandler, pointerHandler, keyboardHandler) {
564447
564510
  super();
564448
564511
  this.onScroll = scrollHandler;
564449
564512
  this.onActivity = activityHandler ?? null;
564450
564513
  this.onPointer = pointerHandler ?? null;
564514
+ this.onKeyboard = keyboardHandler ?? null;
564451
564515
  }
564452
564516
  _transform(chunk, _encoding, callback) {
564453
564517
  this.buffer += chunk.toString();
@@ -564469,7 +564533,9 @@ var init_mouse_filter = __esm({
564469
564533
  else if ((btn === 65 || btn === 97) && this.onScroll) this.onScroll("down", 3, row);
564470
564534
  else if (this.onPointer) {
564471
564535
  const hasShift = (btn & 4) !== 0 && btn < 32;
564472
- if (btn === 2 || hasShift) {
564536
+ if (btn === 2) {
564537
+ } else if (hasShift) {
564538
+ process.stdout.write("\x1B[?1000l\x1B[?1006l");
564473
564539
  } else if ((btn === 0 || btn === 1) && suffix === "M") {
564474
564540
  this.onPointer("press", col, row);
564475
564541
  } else if (btn >= 32 && btn <= 35 && suffix === "M") {
@@ -564505,6 +564571,7 @@ var init_mouse_filter = __esm({
564505
564571
  }
564506
564572
  this.buffer = this.buffer.slice(i2);
564507
564573
  if (output.length > 0) {
564574
+ if (this.onKeyboard) this.onKeyboard();
564508
564575
  this.push(output);
564509
564576
  }
564510
564577
  if (this.buffer.length > 0) {
@@ -581955,6 +582022,8 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
581955
582022
  statusBar.scheduleMouseIdle();
581956
582023
  }, (type, col, row) => {
581957
582024
  statusBar.handlePointerEvent(type, col, row);
582025
+ }, () => {
582026
+ statusBar.enableMouseTracking();
581958
582027
  });
581959
582028
  process.stdin.pipe(mouseFilter);
581960
582029
  process.stdin.on("error", (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.383",
3
+ "version": "0.187.385",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",