open-agents-ai 0.187.182 → 0.187.183

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 +51 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3480,13 +3480,32 @@ ${JSON.stringify(entries, null, 2)}`,
3480
3480
  });
3481
3481
 
3482
3482
  // packages/execution/dist/tools/memory-write.js
3483
- import { readFile as readFile4, writeFile as writeFile3, mkdir as mkdir2 } from "node:fs/promises";
3483
+ import { readFile as readFile4, writeFile as writeFile3, mkdir as mkdir2, rename } from "node:fs/promises";
3484
3484
  import { resolve as resolve8, join as join7 } from "node:path";
3485
3485
  import { randomBytes as randomBytes3 } from "node:crypto";
3486
- var MemoryWriteTool;
3486
+ async function withTopicLock(topicFile, fn) {
3487
+ const prev = _writeLocks.get(topicFile) ?? Promise.resolve();
3488
+ let release2 = () => {
3489
+ };
3490
+ const current = new Promise((resolve39) => {
3491
+ release2 = resolve39;
3492
+ });
3493
+ _writeLocks.set(topicFile, prev.then(() => current));
3494
+ try {
3495
+ await prev;
3496
+ return await fn();
3497
+ } finally {
3498
+ release2();
3499
+ if (_writeLocks.get(topicFile) === prev.then(() => current)) {
3500
+ _writeLocks.delete(topicFile);
3501
+ }
3502
+ }
3503
+ }
3504
+ var _writeLocks, MemoryWriteTool;
3487
3505
  var init_memory_write = __esm({
3488
3506
  "packages/execution/dist/tools/memory-write.js"() {
3489
3507
  "use strict";
3508
+ _writeLocks = /* @__PURE__ */ new Map();
3490
3509
  MemoryWriteTool = class {
3491
3510
  name = "memory_write";
3492
3511
  description = "Store a fact or pattern in the agent's persistent memory. Use this to remember solutions, code patterns, or debugging insights for future tasks.";
@@ -3523,19 +3542,23 @@ var init_memory_write = __esm({
3523
3542
  for (const memoryDir of [oaMemDir, legacyMemDir]) {
3524
3543
  await mkdir2(memoryDir, { recursive: true });
3525
3544
  const topicFile = join7(memoryDir, `${topic}.json`);
3526
- let entries = {};
3527
- try {
3528
- const raw = await readFile4(topicFile, "utf-8");
3529
- entries = JSON.parse(raw);
3530
- } catch {
3531
- }
3532
- const artifactId = `mem-${randomBytes3(6).toString("hex")}`;
3533
- entries[key] = {
3534
- value: value2,
3535
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3536
- artifactId
3537
- };
3538
- await writeFile3(topicFile, JSON.stringify(entries, null, 2), "utf-8");
3545
+ await withTopicLock(topicFile, async () => {
3546
+ let entries = {};
3547
+ try {
3548
+ const raw = await readFile4(topicFile, "utf-8");
3549
+ entries = JSON.parse(raw);
3550
+ } catch {
3551
+ }
3552
+ const artifactId = `mem-${randomBytes3(6).toString("hex")}`;
3553
+ entries[key] = {
3554
+ value: value2,
3555
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3556
+ artifactId
3557
+ };
3558
+ const tempFile = `${topicFile}.tmp-${randomBytes3(4).toString("hex")}`;
3559
+ await writeFile3(tempFile, JSON.stringify(entries, null, 2), "utf-8");
3560
+ await rename(tempFile, topicFile);
3561
+ });
3539
3562
  }
3540
3563
  const provenanceDir = resolve8(this.workingDir, ".oa", "provenance");
3541
3564
  try {
@@ -244487,7 +244510,7 @@ var init_src107 = __esm({
244487
244510
  });
244488
244511
 
244489
244512
  // ../node_modules/steno/lib/index.js
244490
- import { rename, writeFile as writeFile9 } from "node:fs/promises";
244513
+ import { rename as rename2, writeFile as writeFile9 } from "node:fs/promises";
244491
244514
  import { basename as basename5, dirname as dirname6, join as join22 } from "node:path";
244492
244515
  import { fileURLToPath as fileURLToPath2 } from "node:url";
244493
244516
  function getTempFilename(file) {
@@ -244534,7 +244557,7 @@ var init_lib3 = __esm({
244534
244557
  try {
244535
244558
  await writeFile9(this.#tempFilename, data, "utf-8");
244536
244559
  await retryAsyncOperation(async () => {
244537
- await rename(this.#tempFilename, this.#filename);
244560
+ await rename2(this.#tempFilename, this.#filename);
244538
244561
  }, 10, 100);
244539
244562
  this.#prev?.[0]();
244540
244563
  } catch (err) {
@@ -266263,10 +266286,18 @@ var init_episodeStore = __esm({
266263
266286
  const params = sessionId ? [sessionId, limit] : [limit];
266264
266287
  return this.db.prepare(sql).all(...params).map((r2) => this.rowToEpisode(r2));
266265
266288
  }
266266
- /** Count episodes. */
266289
+ /** Count episodes.
266290
+ *
266291
+ * BUG FIX (2026-04-07): previously passed `sessionId` to `.get()` even
266292
+ * when the SQL had no placeholder, causing `RangeError: Too many
266293
+ * parameter values were provided` on every `count()` call without args.
266294
+ * Now we only bind when the placeholder is actually present.
266295
+ */
266267
266296
  count(sessionId) {
266268
- const sql = sessionId ? "SELECT COUNT(*) as n FROM episodes WHERE session_id = ?" : "SELECT COUNT(*) as n FROM episodes";
266269
- return this.db.prepare(sql).get(sessionId).n;
266297
+ if (sessionId) {
266298
+ return this.db.prepare("SELECT COUNT(*) as n FROM episodes WHERE session_id = ?").get(sessionId).n;
266299
+ }
266300
+ return this.db.prepare("SELECT COUNT(*) as n FROM episodes").get().n;
266270
266301
  }
266271
266302
  /** Prune expired session-class episodes (call at session end). */
266272
266303
  pruneExpired() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.182",
3
+ "version": "0.187.183",
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",