agent.libx.js 0.93.31 → 0.93.33

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/README.md CHANGED
@@ -44,7 +44,8 @@ console.log(res.finishReason, await fs.readFile('/src/x.ts'));
44
44
  - **`Edit`** — exact unique-substring replace, with a read-before-edit staleness guard.
45
45
  - **`Grep`/`Glob`/`Write`/`MultiEdit`** — structured, typed results straight from the VFS (no `bash` parsing). The selectable tool set the self-evolution loop mutates over.
46
46
  - **`TodoWrite`** — a planning scratchpad; **`Task`** — spawn a depth-limited child agent over the VFS (`subagents: true`); **`SlashCommand`** — reusable prompt templates from `<dir>/*.md` (`commandsDir`); plus a real **MCP client** (`src/mcp.client.ts`, node-only — stdio/HTTP JSON-RPC handshake + discovery) that feeds the edge-safe **MCP adapter** (`mcpToolsToAgentTools`), so any MCP server's tools become agent tools.
47
- - **`WebFetch`/`WebSearch`** — opt-in network tools (not in the default set): fetch a URL as readable text, or search via a configured provider (`TAVILY_API_KEY`). Enable per project with `tools: [...,'WebFetch']` in config. Factory-built with an injectable `fetch`, so they stay edge-portable and testable.
47
+ - **`WebFetch`/`WebSearch`** — fetch a URL as readable text, or search the web. **Keyless by default** (WebSearch uses DuckDuckGo; auto-upgrades to Tavily when `TAVILY_API_KEY` is set) and **auto-enabled in the CLI**. Factory-built with an injectable `fetch`, so they stay edge-portable and testable. (In the library they're opt-in by name: `tools: [...,'WebSearch']`.)
48
+ - **Oversized-output pagination** — any tool result over a byte ceiling (`maxToolResultBytes`, default 60k) is cropped to page 1 with a marker (refine the query / read further), so one big `Grep`/`Read`/MCP/web result can't blow the context window. In the CLI (**on by default**; `--no-scratch` to disable) the full output instead spills **losslessly** to a **scratch** file and the model recovers specifics via `Grep`/`Read` or **`Ask`** — a cheap, context-isolated peek that returns just the answer (the raw blob never re-enters context).
48
49
 
49
50
  ## Agentic subsystems
50
51
 
package/cli/cli.ts CHANGED
@@ -113,7 +113,7 @@ function parseReasoning(raw: string): ReasoningEffort {
113
113
  }
114
114
 
115
115
  export function parseArgs(argv: string[]): Args {
116
- const a: Args = { stream: true, plan: false, ask: false, yes: false, vfs: false, shell: undefined, seed: false, subagents: false, help: false, version: false, cont: false, outputFormat: 'text', duplex: false, voice: false };
116
+ const a: Args = { stream: true, plan: false, ask: false, yes: false, vfs: false, shell: undefined, seed: false, subagents: false, help: false, version: false, cont: false, outputFormat: 'text', duplex: false, voice: false, scratch: true };
117
117
  const rest: string[] = [];
118
118
  // read the value that follows a flag, failing loudly if it's missing (instead of a surprise default)
119
119
  const val = (i: number, flag: string): string => { const v = argv[i]; if (v === undefined) throw new Error(`${flag} requires a value`); return v; };
@@ -142,6 +142,7 @@ export function parseArgs(argv: string[]): Args {
142
142
  else if (x === '--yes' || x === '-y') a.yes = true;
143
143
  else if (x === '--vfs' || x === '--sandbox') a.vfs = true;
144
144
  else if (x === '--scratch') a.scratch = true;
145
+ else if (x === '--no-scratch') a.scratch = false;
145
146
  else if (x === '--boddb') a.boddb = val(++i, x);
146
147
  else if (x === '--seed') a.seed = true;
147
148
  else if (x === '--shell') a.shell = true;
@@ -195,7 +196,8 @@ Flags:
195
196
  --no-stream disable token streaming
196
197
  (default: disk mode — full real filesystem access, like Claude Code)
197
198
  --vfs, --sandbox sandbox mode: work over an in-memory copy of cwd — real disk is NEVER modified
198
- --scratch spill big web outputs to scratch files (kept out of context; peek via Grep/Ask)
199
+ --no-scratch disable scratch (on by default): paginate oversized tool output recoverable
200
+ scratch files (peek via Grep/Read/Ask) instead of a lossy crop
199
201
  --boddb <dir> database-backed workspace: files live in a persistent bod-db store at <dir>,
200
202
  surviving across runs — real disk is NEVER modified (DB-native; add --seed below)
201
203
  --seed with --boddb: hydrate the store from cwd on the first run (empty DB) only
package/dist/cli.js CHANGED
@@ -1620,7 +1620,7 @@ var init_tools_shell = __esm({
1620
1620
  // cli/cli.ts
1621
1621
  import { createInterface } from "readline/promises";
1622
1622
  import { existsSync as existsSync8, readFileSync as readFileSync5, appendFileSync, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6, readdirSync as readdirSync2, statSync as statSync3 } from "fs";
1623
- import { homedir as homedir5, tmpdir } from "os";
1623
+ import { homedir as homedir5, tmpdir as tmpdir2 } from "os";
1624
1624
 
1625
1625
  // cli/clipboard.ts
1626
1626
  import { execFileSync } from "child_process";
@@ -5600,7 +5600,7 @@ function defaultOpenBrowser(url) {
5600
5600
  import { randomUUID } from "crypto";
5601
5601
  import { resolve, basename, join as join3 } from "path";
5602
5602
  import { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
5603
- import { platform, arch, release, userInfo, homedir } from "os";
5603
+ import { platform, arch, release, userInfo, homedir, tmpdir } from "os";
5604
5604
  init_tools_shell();
5605
5605
  import { BodDB as BodDB2 } from "@bod.ee/db";
5606
5606
  var DEFAULT_TOOLS = ["bash", "Read", "Edit", "Write", "Grep", "Glob", "MultiEdit", "ApplyEdits", "RepoMap", "TodoWrite"];
@@ -5738,7 +5738,7 @@ Reference files in them by their mount path (the left side).`;
5738
5738
  const jobs = new ShellJobRegistry({ cwd, killOnExit: true });
5739
5739
  realShell = [makeRealShellTool({ cwd, registry: jobs }), ...makeShellJobTools(jobs)];
5740
5740
  }
5741
- const scratchDir = o.scratch ? o.scratchDir ?? `${cwd}/.agent/scratch` : void 0;
5741
+ const scratchDir = o.scratch ? o.scratchDir ?? (virtual ? `${cwd}/.agent/scratch` : `${tmpdir()}/agentx-scratch-${process.pid}`) : void 0;
5742
5742
  const scratch = scratchDir ? new Scratch(fs, { dir: scratchDir }) : void 0;
5743
5743
  return new Agent({
5744
5744
  ai: o.ai,
@@ -7998,7 +7998,7 @@ function parseReasoning(raw) {
7998
7998
  throw new Error(`invalid --reasoning: ${raw} (use off|low|medium|high or a token budget)`);
7999
7999
  }
8000
8000
  function parseArgs(argv) {
8001
- const a = { stream: true, plan: false, ask: false, yes: false, vfs: false, shell: void 0, seed: false, subagents: false, help: false, version: false, cont: false, outputFormat: "text", duplex: false, voice: false };
8001
+ const a = { stream: true, plan: false, ask: false, yes: false, vfs: false, shell: void 0, seed: false, subagents: false, help: false, version: false, cont: false, outputFormat: "text", duplex: false, voice: false, scratch: true };
8002
8002
  const rest = [];
8003
8003
  const val = (i, flag) => {
8004
8004
  const v = argv[i];
@@ -8026,6 +8026,7 @@ function parseArgs(argv) {
8026
8026
  else if (x === "--yes" || x === "-y") a.yes = true;
8027
8027
  else if (x === "--vfs" || x === "--sandbox") a.vfs = true;
8028
8028
  else if (x === "--scratch") a.scratch = true;
8029
+ else if (x === "--no-scratch") a.scratch = false;
8029
8030
  else if (x === "--boddb") a.boddb = val(++i, x);
8030
8031
  else if (x === "--seed") a.seed = true;
8031
8032
  else if (x === "--shell") a.shell = true;
@@ -8079,7 +8080,8 @@ Flags:
8079
8080
  --no-stream disable token streaming
8080
8081
  (default: disk mode \u2014 full real filesystem access, like Claude Code)
8081
8082
  --vfs, --sandbox sandbox mode: work over an in-memory copy of cwd \u2014 real disk is NEVER modified
8082
- --scratch spill big web outputs to scratch files (kept out of context; peek via Grep/Ask)
8083
+ --no-scratch disable scratch (on by default): paginate oversized tool output \u2192 recoverable
8084
+ scratch files (peek via Grep/Read/Ask) instead of a lossy crop
8083
8085
  --boddb <dir> database-backed workspace: files live in a persistent bod-db store at <dir>,
8084
8086
  surviving across runs \u2014 real disk is NEVER modified (DB-native; add --seed below)
8085
8087
  --seed with --boddb: hydrate the store from cwd on the first run (empty DB) only
@@ -9086,7 +9088,7 @@ async function repl(args, ai, cfg, cwd) {
9086
9088
  };
9087
9089
  const pendingImages = [];
9088
9090
  const grabClipboardAttachment = () => {
9089
- const dir = join9(tmpdir(), "agentx-pasted");
9091
+ const dir = join9(tmpdir2(), "agentx-pasted");
9090
9092
  try {
9091
9093
  mkdirSync7(dir, { recursive: true });
9092
9094
  } catch {