open-agents-ai 0.143.0 → 0.144.0

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 +94 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1492,6 +1492,61 @@ ${stderr}` : ""),
1492
1492
  // packages/execution/dist/tools/file-read.js
1493
1493
  import { readFile } from "node:fs/promises";
1494
1494
  import { resolve } from "node:path";
1495
+ function computeMaxUngatedLines(contextWindow) {
1496
+ if (contextWindow <= 0)
1497
+ return 200;
1498
+ const budget = Math.floor(contextWindow * 0.15);
1499
+ const maxLines = Math.floor(budget / 10);
1500
+ return Math.max(80, Math.min(500, maxLines));
1501
+ }
1502
+ function buildStructuralPreview(lines, filePath, maxLines) {
1503
+ const total = lines.length;
1504
+ const HEAD = Math.min(30, Math.floor(maxLines * 0.35));
1505
+ const TAIL = Math.min(15, Math.floor(maxLines * 0.15));
1506
+ const parts = [];
1507
+ parts.push(`# ${filePath} \u2014 ${total} lines (showing structural preview)
1508
+ `);
1509
+ parts.push(`## Lines 1-${HEAD}:`);
1510
+ for (let i = 0; i < HEAD; i++) {
1511
+ parts.push(`${String(i + 1).padStart(6)} | ${lines[i]}`);
1512
+ }
1513
+ const sigs = [];
1514
+ for (let i = HEAD; i < total - TAIL; i++) {
1515
+ const line = lines[i];
1516
+ if (SIG_PATTERNS.some((p) => p.test(line))) {
1517
+ sigs.push(`${String(i + 1).padStart(6)} | ${line}`);
1518
+ }
1519
+ }
1520
+ if (sigs.length > 0) {
1521
+ parts.push(`
1522
+ ## Signatures (lines ${HEAD + 1}-${total - TAIL}) \u2014 ${sigs.length} found:`);
1523
+ const maxSigs = Math.floor(maxLines * 0.4);
1524
+ if (sigs.length > maxSigs) {
1525
+ parts.push(...sigs.slice(0, maxSigs));
1526
+ parts.push(` ... ${sigs.length - maxSigs} more signatures`);
1527
+ } else {
1528
+ parts.push(...sigs);
1529
+ }
1530
+ } else {
1531
+ parts.push(`
1532
+ ## Lines ${HEAD + 1}-${total - TAIL}: ${total - HEAD - TAIL} lines (no signatures detected)`);
1533
+ }
1534
+ if (TAIL > 0) {
1535
+ const tailStart = total - TAIL;
1536
+ parts.push(`
1537
+ ## Lines ${tailStart + 1}-${total}:`);
1538
+ for (let i = tailStart; i < total; i++) {
1539
+ parts.push(`${String(i + 1).padStart(6)} | ${lines[i]}`);
1540
+ }
1541
+ }
1542
+ parts.push(``);
1543
+ parts.push(`To read a specific section: file_read(path="${filePath}", offset=LINE, limit=50)`);
1544
+ parts.push(`To search for a pattern: grep_search(pattern="...", path="${filePath}")`);
1545
+ if (sigs.length > 0) {
1546
+ parts.push(`To explore interactively: file_explore(strategy="search", path="${filePath}", query="...")`);
1547
+ }
1548
+ return parts.join("\n");
1549
+ }
1495
1550
  function extractPath(args) {
1496
1551
  if (typeof args["path"] === "string" && args["path"].trim()) {
1497
1552
  return args["path"].trim();
@@ -1516,13 +1571,25 @@ function extractPath(args) {
1516
1571
  }
1517
1572
  return null;
1518
1573
  }
1519
- var FileReadTool;
1574
+ var SIG_PATTERNS, FileReadTool;
1520
1575
  var init_file_read = __esm({
1521
1576
  "packages/execution/dist/tools/file-read.js"() {
1522
1577
  "use strict";
1578
+ SIG_PATTERNS = [
1579
+ /^\s*(export\s+)?(async\s+)?function\s+\w+/,
1580
+ /^\s*(export\s+)?(abstract\s+)?class\s+\w+/,
1581
+ /^\s*(export\s+)?interface\s+\w+/,
1582
+ /^\s*(export\s+)?type\s+\w+\s*=/,
1583
+ /^\s*(export\s+)?enum\s+\w+/,
1584
+ /^\s*(?:public|private|protected|static|async|get|set)\s+\w+\s*[(<]/,
1585
+ /^\s*(pub\s+)?(async\s+)?fn\s+\w+/,
1586
+ /^\s*(pub\s+)?struct\s+\w+/,
1587
+ /^\s*def\s+\w+/,
1588
+ /^\s*class\s+\w+/
1589
+ ];
1523
1590
  FileReadTool = class {
1524
1591
  name = "file_read";
1525
- description = "Read the contents of a file";
1592
+ description = "Read the contents of a file. For large files (200+ lines), returns a structural preview with signatures \u2014 use offset/limit to read specific sections.";
1526
1593
  parameters = {
1527
1594
  type: "object",
1528
1595
  properties: {
@@ -1537,7 +1604,7 @@ var init_file_read = __esm({
1537
1604
  constructor(workingDir) {
1538
1605
  this.workingDir = workingDir;
1539
1606
  }
1540
- /** Set actual context window size to enable auto-windowing for small contexts */
1607
+ /** Set actual context window size for proportional auto-windowing */
1541
1608
  setContextWindowSize(size) {
1542
1609
  this._contextWindowSize = size;
1543
1610
  }
@@ -1559,24 +1626,25 @@ var init_file_read = __esm({
1559
1626
  const content = await readFile(fullPath, "utf-8");
1560
1627
  let lines = content.split("\n");
1561
1628
  const totalLines = lines.length;
1562
- if (offset !== void 0) {
1563
- const startIdx = Math.max(0, offset - 1);
1629
+ if (offset !== void 0 || limit !== void 0) {
1630
+ const startIdx = Math.max(0, (offset ?? 1) - 1);
1564
1631
  lines = lines.slice(startIdx, limit ? startIdx + limit : void 0);
1565
- } else if (this._contextWindowSize > 0 && this._contextWindowSize <= 32768 && !limit) {
1566
- const maxLines = this._contextWindowSize <= 16384 ? 80 : 120;
1567
- if (totalLines > maxLines) {
1568
- lines = lines.slice(0, maxLines);
1569
- const numbered2 = lines.map((line, i) => `${String(i + 1).padStart(6)} | ${line}`).join("\n");
1570
- return {
1571
- success: true,
1572
- output: `${numbered2}
1573
-
1574
- [File has ${totalLines} lines \u2014 showing first ${maxLines}. Use offset/limit to see more.]`,
1575
- durationMs: performance.now() - start
1576
- };
1577
- }
1632
+ const numbered2 = lines.map((line, i) => `${String(startIdx + i + 1).padStart(6)} | ${line}`).join("\n");
1633
+ return {
1634
+ success: true,
1635
+ output: numbered2,
1636
+ durationMs: performance.now() - start
1637
+ };
1638
+ }
1639
+ const maxLines = computeMaxUngatedLines(this._contextWindowSize);
1640
+ if (totalLines > maxLines) {
1641
+ return {
1642
+ success: true,
1643
+ output: buildStructuralPreview(lines, filePath, maxLines),
1644
+ durationMs: performance.now() - start
1645
+ };
1578
1646
  }
1579
- const numbered = lines.map((line, i) => `${String(i + (offset ?? 1)).padStart(6)} | ${line}`).join("\n");
1647
+ const numbered = lines.map((line, i) => `${String(i + 1).padStart(6)} | ${line}`).join("\n");
1580
1648
  return {
1581
1649
  success: true,
1582
1650
  output: numbered,
@@ -18987,14 +19055,14 @@ import { execFile as execFile4 } from "node:child_process";
18987
19055
  import { promisify as promisify3 } from "node:util";
18988
19056
  function getPatterns(filePath) {
18989
19057
  if (/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath))
18990
- return SIG_PATTERNS.ts;
19058
+ return SIG_PATTERNS2.ts;
18991
19059
  if (/\.py$/.test(filePath))
18992
- return SIG_PATTERNS.py;
19060
+ return SIG_PATTERNS2.py;
18993
19061
  if (/\.rs$/.test(filePath))
18994
- return SIG_PATTERNS.rs;
19062
+ return SIG_PATTERNS2.rs;
18995
19063
  if (/\.go$/.test(filePath))
18996
- return SIG_PATTERNS.go;
18997
- return SIG_PATTERNS.default;
19064
+ return SIG_PATTERNS2.go;
19065
+ return SIG_PATTERNS2.default;
18998
19066
  }
18999
19067
  function clearExploreNotes() {
19000
19068
  sessionNotes.length = 0;
@@ -19002,13 +19070,13 @@ function clearExploreNotes() {
19002
19070
  function getExploreNotes() {
19003
19071
  return sessionNotes;
19004
19072
  }
19005
- var execFileAsync3, sessionNotes, SIG_PATTERNS, FileExploreTool;
19073
+ var execFileAsync3, sessionNotes, SIG_PATTERNS2, FileExploreTool;
19006
19074
  var init_file_explore = __esm({
19007
19075
  "packages/execution/dist/tools/file-explore.js"() {
19008
19076
  "use strict";
19009
19077
  execFileAsync3 = promisify3(execFile4);
19010
19078
  sessionNotes = [];
19011
- SIG_PATTERNS = {
19079
+ SIG_PATTERNS2 = {
19012
19080
  ts: [
19013
19081
  /^\s*(export\s+)?(async\s+)?function\s+\w+/,
19014
19082
  /^\s*(export\s+)?(abstract\s+)?class\s+\w+/,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.143.0",
3
+ "version": "0.144.0",
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",