open-agents-ai 0.187.182 → 0.187.184

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 +131 -34
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2652,14 +2652,16 @@ var init_glob_find = __esm({
2652
2652
  });
2653
2653
 
2654
2654
  // packages/execution/dist/tools/web-fetch.js
2655
- var DEFAULT_MAX_LENGTH, SHORT_CONTENT_THRESHOLD, WebFetchTool;
2655
+ var DEFAULT_MAX_LENGTH, SHORT_CONTENT_THRESHOLD, CACHE_TTL_MS, WebFetchTool;
2656
2656
  var init_web_fetch = __esm({
2657
2657
  "packages/execution/dist/tools/web-fetch.js"() {
2658
2658
  "use strict";
2659
2659
  DEFAULT_MAX_LENGTH = 5e3;
2660
2660
  SHORT_CONTENT_THRESHOLD = 200;
2661
+ CACHE_TTL_MS = 6e4;
2661
2662
  WebFetchTool = class {
2662
2663
  name = "web_fetch";
2664
+ _fetchCache = /* @__PURE__ */ new Map();
2663
2665
  description = "Fetch a single web page and return its text content (HTML stripped to plain text). FASTEST web tool \u2014 use this for reading any single URL: documentation, articles, README files, API references, Stack Overflow answers. Limitations: no JavaScript rendering (SPAs/React apps return empty), no link following, no cookies/auth, no structured data extraction. If the page is blank or incomplete, switch to web_crawl with strategy='playwright'. For scraping/extracting structured data (prices, listings, tables), use web_crawl instead. For search engine queries, use web_search instead. For interactive browser sessions (login, form filling, clicking), use browser_action instead.";
2664
2666
  parameters = {
2665
2667
  type: "object",
@@ -2679,6 +2681,19 @@ var init_web_fetch = __esm({
2679
2681
  const url = args["url"];
2680
2682
  const maxLength = args["max_length"] ?? DEFAULT_MAX_LENGTH;
2681
2683
  const start2 = performance.now();
2684
+ const cached = this._fetchCache.get(url);
2685
+ if (cached && Date.now() - cached.fetchedAt < CACHE_TTL_MS) {
2686
+ const slicedCache = cached.text.length > maxLength ? `${cached.text.slice(0, maxLength)}
2687
+
2688
+ [Content truncated to ${maxLength} characters]` : cached.text;
2689
+ return {
2690
+ success: true,
2691
+ output: `[CACHED \u2014 already fetched this URL in this session; the content below is the full response. Do NOT re-fetch the same URL. If the content seems short, the page may just be short or require JavaScript \u2014 use browser_action with a headless browser instead.]
2692
+
2693
+ ` + slicedCache,
2694
+ durationMs: performance.now() - start2
2695
+ };
2696
+ }
2682
2697
  try {
2683
2698
  const response = await fetch(url, {
2684
2699
  headers: {
@@ -2697,6 +2712,7 @@ var init_web_fetch = __esm({
2697
2712
  }
2698
2713
  const html = await response.text();
2699
2714
  const text = this.#stripHtml(html);
2715
+ this._fetchCache.set(url, { text, fetchedAt: Date.now() });
2700
2716
  if (text.length < SHORT_CONTENT_THRESHOLD) {
2701
2717
  return {
2702
2718
  success: true,
@@ -2711,7 +2727,7 @@ var init_web_fetch = __esm({
2711
2727
  success: true,
2712
2728
  output: truncated ? `${text.slice(0, maxLength)}
2713
2729
 
2714
- [Content truncated to ${maxLength} characters]` : text,
2730
+ [Content truncated to ${maxLength} characters. The full response is cached for this session \u2014 subsequent calls to the same URL return the cached content.]` : text,
2715
2731
  durationMs: performance.now() - start2
2716
2732
  };
2717
2733
  } catch (error) {
@@ -3480,13 +3496,32 @@ ${JSON.stringify(entries, null, 2)}`,
3480
3496
  });
3481
3497
 
3482
3498
  // packages/execution/dist/tools/memory-write.js
3483
- import { readFile as readFile4, writeFile as writeFile3, mkdir as mkdir2 } from "node:fs/promises";
3499
+ import { readFile as readFile4, writeFile as writeFile3, mkdir as mkdir2, rename } from "node:fs/promises";
3484
3500
  import { resolve as resolve8, join as join7 } from "node:path";
3485
3501
  import { randomBytes as randomBytes3 } from "node:crypto";
3486
- var MemoryWriteTool;
3502
+ async function withTopicLock(topicFile, fn) {
3503
+ const prev = _writeLocks.get(topicFile) ?? Promise.resolve();
3504
+ let release2 = () => {
3505
+ };
3506
+ const current = new Promise((resolve39) => {
3507
+ release2 = resolve39;
3508
+ });
3509
+ _writeLocks.set(topicFile, prev.then(() => current));
3510
+ try {
3511
+ await prev;
3512
+ return await fn();
3513
+ } finally {
3514
+ release2();
3515
+ if (_writeLocks.get(topicFile) === prev.then(() => current)) {
3516
+ _writeLocks.delete(topicFile);
3517
+ }
3518
+ }
3519
+ }
3520
+ var _writeLocks, MemoryWriteTool;
3487
3521
  var init_memory_write = __esm({
3488
3522
  "packages/execution/dist/tools/memory-write.js"() {
3489
3523
  "use strict";
3524
+ _writeLocks = /* @__PURE__ */ new Map();
3490
3525
  MemoryWriteTool = class {
3491
3526
  name = "memory_write";
3492
3527
  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 +3558,23 @@ var init_memory_write = __esm({
3523
3558
  for (const memoryDir of [oaMemDir, legacyMemDir]) {
3524
3559
  await mkdir2(memoryDir, { recursive: true });
3525
3560
  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");
3561
+ await withTopicLock(topicFile, async () => {
3562
+ let entries = {};
3563
+ try {
3564
+ const raw = await readFile4(topicFile, "utf-8");
3565
+ entries = JSON.parse(raw);
3566
+ } catch {
3567
+ }
3568
+ const artifactId = `mem-${randomBytes3(6).toString("hex")}`;
3569
+ entries[key] = {
3570
+ value: value2,
3571
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3572
+ artifactId
3573
+ };
3574
+ const tempFile = `${topicFile}.tmp-${randomBytes3(4).toString("hex")}`;
3575
+ await writeFile3(tempFile, JSON.stringify(entries, null, 2), "utf-8");
3576
+ await rename(tempFile, topicFile);
3577
+ });
3539
3578
  }
3540
3579
  const provenanceDir = resolve8(this.workingDir, ".oa", "provenance");
3541
3580
  try {
@@ -244487,7 +244526,7 @@ var init_src107 = __esm({
244487
244526
  });
244488
244527
 
244489
244528
  // ../node_modules/steno/lib/index.js
244490
- import { rename, writeFile as writeFile9 } from "node:fs/promises";
244529
+ import { rename as rename2, writeFile as writeFile9 } from "node:fs/promises";
244491
244530
  import { basename as basename5, dirname as dirname6, join as join22 } from "node:path";
244492
244531
  import { fileURLToPath as fileURLToPath2 } from "node:url";
244493
244532
  function getTempFilename(file) {
@@ -244534,7 +244573,7 @@ var init_lib3 = __esm({
244534
244573
  try {
244535
244574
  await writeFile9(this.#tempFilename, data, "utf-8");
244536
244575
  await retryAsyncOperation(async () => {
244537
- await rename(this.#tempFilename, this.#filename);
244576
+ await rename2(this.#tempFilename, this.#filename);
244538
244577
  }, 10, 100);
244539
244578
  this.#prev?.[0]();
244540
244579
  } catch (err) {
@@ -265382,6 +265421,35 @@ function cleanForStorage(text) {
265382
265421
  out = out.replace(/\s+/g, " ").trim();
265383
265422
  return out;
265384
265423
  }
265424
+ function extractTaskCompleteSummary(args) {
265425
+ if (args == null)
265426
+ return "";
265427
+ if (typeof args === "string")
265428
+ return stripThinkTags(args);
265429
+ if (typeof args === "object") {
265430
+ const obj = args;
265431
+ if (typeof obj.summary === "string" && obj.summary.trim().length > 0) {
265432
+ return stripThinkTags(obj.summary);
265433
+ }
265434
+ for (const alt of ["text", "message", "result", "output", "content", "response", "answer"]) {
265435
+ if (typeof obj[alt] === "string" && obj[alt].trim().length > 0) {
265436
+ return stripThinkTags(obj[alt]);
265437
+ }
265438
+ }
265439
+ if (typeof obj[""] === "string" && obj[""].trim().length > 0) {
265440
+ let value2 = obj[""];
265441
+ value2 = value2.replace(/^[^>]*>\s*\n?/, "");
265442
+ value2 = value2.replace(/\s*<\/[^>]+>\s*$/, "");
265443
+ return stripThinkTags(value2.trim());
265444
+ }
265445
+ const stringValues = Object.values(obj).filter((v) => typeof v === "string" && v.trim().length > 0);
265446
+ if (stringValues.length > 0) {
265447
+ const longest = stringValues.reduce((a2, b) => a2.length >= b.length ? a2 : b);
265448
+ return stripThinkTags(longest);
265449
+ }
265450
+ }
265451
+ return "";
265452
+ }
265385
265453
  var SIGNPOST_RE, NEW_TASK_RE, RESTORED_BLOCK_RE, SYSTEM_BLOCK_RE, THINK_BLOCK_RE, ANSI_ESCAPE_RE;
265386
265454
  var init_textSanitize = __esm({
265387
265455
  "packages/orchestrator/dist/textSanitize.js"() {
@@ -266080,6 +266148,15 @@ import { join as join63 } from "node:path";
266080
266148
  import { mkdirSync as mkdirSync24, existsSync as existsSync47 } from "node:fs";
266081
266149
  import { randomUUID as randomUUID5 } from "node:crypto";
266082
266150
  import { createHash as createHash3 } from "node:crypto";
266151
+ function sanitizeImportance(raw, fallback = 5) {
266152
+ if (typeof raw !== "number" || !Number.isFinite(raw))
266153
+ return fallback;
266154
+ if (raw < 0)
266155
+ return 0;
266156
+ if (raw > 10)
266157
+ return 10;
266158
+ return raw;
266159
+ }
266083
266160
  function autoImportance(toolName, modality, content) {
266084
266161
  if (toolName === "task_complete")
266085
266162
  return 9;
@@ -266180,7 +266257,8 @@ var init_episodeStore = __esm({
266180
266257
  const now = Date.now();
266181
266258
  const contentHash = createHash3("sha256").update(ep.content).digest("hex").slice(0, 16);
266182
266259
  const modality = ep.modality ?? "text";
266183
- const importance = ep.importance ?? autoImportance(ep.toolName ?? null, modality, ep.content);
266260
+ const rawImportance = ep.importance ?? autoImportance(ep.toolName ?? null, modality, ep.content);
266261
+ const importance = sanitizeImportance(rawImportance);
266184
266262
  const decayClass = ep.decayClass ?? autoDecayClass(ep.toolName ?? null, modality, ep.content);
266185
266263
  const existing = this.db.prepare("SELECT id FROM episodes WHERE content_hash = ? AND session_id = ? LIMIT 1").get(contentHash, ep.sessionId ?? null);
266186
266264
  if (existing)
@@ -266263,10 +266341,18 @@ var init_episodeStore = __esm({
266263
266341
  const params = sessionId ? [sessionId, limit] : [limit];
266264
266342
  return this.db.prepare(sql).all(...params).map((r2) => this.rowToEpisode(r2));
266265
266343
  }
266266
- /** Count episodes. */
266344
+ /** Count episodes.
266345
+ *
266346
+ * BUG FIX (2026-04-07): previously passed `sessionId` to `.get()` even
266347
+ * when the SQL had no placeholder, causing `RangeError: Too many
266348
+ * parameter values were provided` on every `count()` call without args.
266349
+ * Now we only bind when the placeholder is actually present.
266350
+ */
266267
266351
  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;
266352
+ if (sessionId) {
266353
+ return this.db.prepare("SELECT COUNT(*) as n FROM episodes WHERE session_id = ?").get(sessionId).n;
266354
+ }
266355
+ return this.db.prepare("SELECT COUNT(*) as n FROM episodes").get().n;
266270
266356
  }
266271
266357
  /** Prune expired session-class episodes (call at session end). */
266272
266358
  pruneExpired() {
@@ -266304,9 +266390,12 @@ var init_episodeStore = __esm({
266304
266390
  contentHash: row.content_hash,
266305
266391
  metadata: row.metadata ? JSON.parse(row.metadata) : null,
266306
266392
  embedding: row.embedding ? new Float32Array(new Uint8Array(row.embedding).buffer) : null,
266307
- importance: row.importance,
266393
+ // Belt-and-braces: rows from pre-fix DBs may have null importance
266394
+ // (from legacy inserts with NaN that SQLite coerced to NULL).
266395
+ // Re-sanitize on read so downstream code always sees a valid number.
266396
+ importance: sanitizeImportance(row.importance),
266308
266397
  decayClass: row.decay_class,
266309
- strength: row.strength,
266398
+ strength: typeof row.strength === "number" && Number.isFinite(row.strength) ? row.strength : 1,
266310
266399
  lastRetrieved: row.last_retrieved,
266311
266400
  gist: row.gist,
266312
266401
  sourceEpisodeId: row.source_episode_id
@@ -269410,7 +269499,7 @@ ${sr.result.output}`;
269410
269499
  messages2.push(this.buildToolMessage(output, matchTc.id));
269411
269500
  if (matchTc.name === "task_complete") {
269412
269501
  completed = true;
269413
- summary = matchTc.arguments.summary || "";
269502
+ summary = extractTaskCompleteSummary(matchTc.arguments);
269414
269503
  if (summary && !this._assistantTextEmitted) {
269415
269504
  this.emit({ type: "assistant_text", content: summary, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
269416
269505
  this._assistantTextEmitted = true;
@@ -269429,7 +269518,7 @@ ${sr.result.output}`;
269429
269518
  messages2.push(this.buildToolMessage(r2.output, r2.tc.id));
269430
269519
  if (r2.tc.name === "task_complete") {
269431
269520
  completed = true;
269432
- summary = r2.tc.arguments.summary || "";
269521
+ summary = extractTaskCompleteSummary(r2.tc.arguments);
269433
269522
  if (summary && !this._assistantTextEmitted) {
269434
269523
  this.emit({ type: "assistant_text", content: summary, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
269435
269524
  this._assistantTextEmitted = true;
@@ -269458,7 +269547,7 @@ ${sr.result.output}`;
269458
269547
  messages2.push(this.buildToolMessage(r2.output, r2.tc.id));
269459
269548
  if (r2.tc.name === "task_complete") {
269460
269549
  completed = true;
269461
- summary = r2.tc.arguments.summary || "";
269550
+ summary = extractTaskCompleteSummary(r2.tc.arguments);
269462
269551
  if (summary && !this._assistantTextEmitted) {
269463
269552
  this.emit({ type: "assistant_text", content: summary, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
269464
269553
  this._assistantTextEmitted = true;
@@ -269858,7 +269947,7 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
269858
269947
  messages2.push(toolMsg);
269859
269948
  if (tc.name === "task_complete") {
269860
269949
  completed = true;
269861
- summary = tc.arguments.summary || "";
269950
+ summary = extractTaskCompleteSummary(tc.arguments);
269862
269951
  if (summary && !this._assistantTextEmitted) {
269863
269952
  this.emit({ type: "assistant_text", content: summary, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
269864
269953
  this._assistantTextEmitted = true;
@@ -274014,6 +274103,7 @@ var init_coordinator = __esm({
274014
274103
  "use strict";
274015
274104
  init_agent_types();
274016
274105
  init_agent_task();
274106
+ init_textSanitize();
274017
274107
  }
274018
274108
  });
274019
274109
 
@@ -307861,6 +307951,7 @@ var init_dmn_engine = __esm({
307861
307951
  "packages/cli/src/tui/dmn-engine.ts"() {
307862
307952
  "use strict";
307863
307953
  init_dist8();
307954
+ init_dist8();
307864
307955
  init_dist4();
307865
307956
  init_project_context();
307866
307957
  init_render();
@@ -307920,7 +308011,9 @@ var init_dmn_engine = __esm({
307920
308011
  }
307921
308012
  /** Record a task failure for Reflexion-style learning */
307922
308013
  recordTaskFailure(summary, errorContext, category) {
307923
- const reflection = errorContext ? `FAILED: ${summary.slice(0, 200)} \u2014 Error: ${errorContext.slice(0, 300)}` : `FAILED: ${summary.slice(0, 500)}`;
308014
+ const cleanSummary = cleanForStorage(summary);
308015
+ const cleanError = errorContext ? cleanForStorage(errorContext) : "";
308016
+ const reflection = cleanError ? `FAILED: ${cleanSummary.slice(0, 200)} \u2014 Error: ${cleanError.slice(0, 300)}` : `FAILED: ${cleanSummary.slice(0, 500)}`;
307924
308017
  this.state.reflectionBuffer.push(reflection);
307925
308018
  if (this.state.reflectionBuffer.length > 5) {
307926
308019
  this.state.reflectionBuffer.shift();
@@ -315264,7 +315357,8 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
315264
315357
  return { success: false, output: "", error: "task is required" };
315265
315358
  }
315266
315359
  const agentId = `sub-agent-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
315267
- const agentLabel = `sub_agent: ${task.slice(0, 40)}${task.length > 40 ? "..." : ""}`;
315360
+ const cleanedLabelTask = cleanForStorage(task) || task;
315361
+ const agentLabel = `sub_agent: ${cleanedLabelTask.slice(0, 40)}${cleanedLabelTask.length > 40 ? "..." : ""}`;
315268
315362
  if (onViewRegister) {
315269
315363
  onViewRegister(agentId, agentLabel);
315270
315364
  }
@@ -315324,7 +315418,7 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
315324
315418
  if (onComplete) onComplete(agentId, task, result2.completed ? 0 : 1, output2);
315325
315419
  return output2;
315326
315420
  });
315327
- const taskId = taskManager.trackPromise(`sub_agent: ${task.slice(0, 80)}`, promise);
315421
+ const taskId = taskManager.trackPromise(`sub_agent: ${cleanedLabelTask.slice(0, 80)}`, promise);
315328
315422
  return {
315329
315423
  success: true,
315330
315424
  output: `Sub-agent started in background: ${taskId}
@@ -320951,7 +321045,8 @@ function statusCommand(jobId, repoPath) {
320951
321045
  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`;
320952
321046
  const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
320953
321047
  console.log(`${icon} ${job.id} [${job.status}] ${runtime}`);
320954
- console.log(` Task: ${job.task.slice(0, 80)}`);
321048
+ const cleanTask = cleanForStorage(job.task) || job.task;
321049
+ console.log(` Task: ${cleanTask.slice(0, 80)}`);
320955
321050
  console.log(` PID: ${job.pid}`);
320956
321051
  if (job.summary) console.log(` Summary: ${job.summary}`);
320957
321052
  if (job.error) console.log(` Error: ${job.error}`);
@@ -320970,7 +321065,8 @@ function jobsCommand(repoPath) {
320970
321065
  const job = JSON.parse(readFileSync61(join95(dir, file), "utf-8"));
320971
321066
  const icon = job.status === "completed" ? "\u2713" : job.status === "failed" ? "\u2717" : "\u25CF";
320972
321067
  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`;
320973
- console.log(` ${icon} ${job.id} [${job.status}] ${runtime} \u2014 ${job.task.slice(0, 60)}`);
321068
+ const cleanListTask = cleanForStorage(job.task) || job.task;
321069
+ console.log(` ${icon} ${job.id} [${job.status}] ${runtime} \u2014 ${cleanListTask.slice(0, 60)}`);
320974
321070
  } catch {
320975
321071
  }
320976
321072
  }
@@ -320979,6 +321075,7 @@ var init_run = __esm({
320979
321075
  "packages/cli/src/commands/run.ts"() {
320980
321076
  "use strict";
320981
321077
  init_interactive();
321078
+ init_dist8();
320982
321079
  }
320983
321080
  });
320984
321081
 
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.184",
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",