@livx.cc/agentx 0.99.71 → 0.99.73

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.
@@ -1,4 +1,4 @@
1
- import { A as AgentTool } from './tools-DV4SkkQs.js';
1
+ import { A as AgentTool } from './tools-wVQBhYwm.js';
2
2
 
3
3
  /**
4
4
  * MCP bridge — adapt a Model Context Protocol tool list into the agent's AgentTool[],
@@ -1,5 +1,5 @@
1
- import { e as McpToolSearchOptions, f as McpToolSpec } from './mcp-DGd2If0Z.js';
2
- import { A as AgentTool } from './tools-DV4SkkQs.js';
1
+ import { e as McpToolSearchOptions, f as McpToolSpec } from './mcp-8_lBApgs.js';
2
+ import { A as AgentTool } from './tools-wVQBhYwm.js';
3
3
  import '@livx.cc/wcli/core';
4
4
 
5
5
  /** Hard cap for `tools/call`. NOT the 30s protocol timeout: a tool call is real work (an image render, a crawl)
@@ -127,17 +127,17 @@ declare function elideStaleImages(messages: Message[], keepRecent?: number): Mes
127
127
  * AND legacy inline base64) collapse to the elision stub. Pure view: the caller's messages are never mutated.
128
128
  * A missing/unreadable file (or an unregistered ref) degrades to the same stub and is LOGGED — never throws.
129
129
  */
130
- declare function expandImagesForSend(messages: Message[], keepRecent?: number, stub?: string): Message[];
130
+ declare function expandImagesForSend(messages: Message[], keepRecent?: number, stub?: string, vision?: boolean): Message[];
131
131
  /**
132
132
  * Byte-weight of a transcript AS IT WILL GO ON THE WIRE — refs inside the keep window weigh their
133
133
  * file's base64 size, everything stale weighs the stub — WITHOUT materializing a single byte of
134
134
  * base64. This is the honest number for `/context` and the CLI footer, where the old behaviour made
135
135
  * every historical screenshot immortal and produced false "90% full" warnings.
136
136
  */
137
- declare function sendBytes(messages: Message[], keepRecent?: number, stub?: string): number;
137
+ declare function sendBytes(messages: Message[], keepRecent?: number, vision?: boolean, stub?: string): number;
138
138
  /** `sendBytes` split per message — same window, same weights. Lets a budgeter drop/shave message-by-
139
139
  * message without re-deriving the window (and without charging a stale ref its file weight). */
140
- declare function sendBytesPer(messages: Message[], keepRecent?: number, stub?: string): number[];
140
+ declare function sendBytesPer(messages: Message[], keepRecent?: number, vision?: boolean, stub?: string): number[];
141
141
  interface Tool {
142
142
  type: 'function';
143
143
  function: {
@@ -1,4 +1,4 @@
1
- import { k as JobRegistry, A as AgentTool } from './tools-DV4SkkQs.js';
1
+ import { k as JobRegistry, A as AgentTool } from './tools-wVQBhYwm.js';
2
2
  import '@livx.cc/wcli/core';
3
3
 
4
4
  /**
@@ -2,7 +2,7 @@
2
2
  import { CommandExecutor, registerHeadlessCommands } from "@livx.cc/wcli/core";
3
3
 
4
4
  // src/llm.ts
5
- import { readFileSync, statSync, realpathSync } from "fs";
5
+ import { statSync as statSync2, realpathSync } from "fs";
6
6
  import { resolve, sep } from "path";
7
7
  import { randomBytes } from "crypto";
8
8
 
@@ -10,8 +10,18 @@ import { randomBytes } from "crypto";
10
10
  import { log } from "libx.js/src/modules/log";
11
11
  var forComponent = (name) => log.forComponent(name);
12
12
 
13
+ // src/imageWire.ts
14
+ import { readFileSync, writeFileSync, statSync, mkdtempSync, rmSync } from "fs";
15
+ import { spawnSync } from "child_process";
16
+ import { createHash } from "crypto";
17
+ import { tmpdir } from "os";
18
+ import { join } from "path";
19
+ import { PNG } from "pngjs";
20
+ import jpeg from "jpeg-js";
21
+ var log2 = forComponent("imageWire");
22
+
13
23
  // src/llm.ts
14
- var log2 = forComponent("llm");
24
+ var log3 = forComponent("llm");
15
25
 
16
26
  // src/redact.ts
17
27
  var REDACTED = "\u2039redacted\u203A";
@@ -214,7 +224,7 @@ var globTool = makeGlobTool();
214
224
  var grepTool = makeGrepTool();
215
225
 
216
226
  // src/tools.web.ts
217
- var log3 = forComponent("web");
227
+ var log4 = forComponent("web");
218
228
  function htmlToText(html) {
219
229
  let s = html.replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<title[\s\S]*?<\/title>/gi, " ").replace(/<noscript[\s\S]*?<\/noscript>/gi, " ").replace(/<textarea[\s\S]*?<\/textarea>/gi, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<\/(p|div|li|h[1-6]|tr|section|article|header|footer|nav)>/gi, "\n").replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, " ");
220
230
  s = s.replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#0?39;/g, "'").replace(/&#x27;/gi, "'");
@@ -338,7 +348,7 @@ function makeWebFetchTool(options = {}) {
338
348
 
339
349
  ${capped}`;
340
350
  } catch (e) {
341
- log3.debug(`WebFetch ${u} failed`, e);
351
+ log4.debug(`WebFetch ${u} failed`, e);
342
352
  return `Error fetching ${u}: ${e?.name === "AbortError" ? `timed out after ${timeoutMs}ms` : e?.message ?? e}`;
343
353
  } finally {
344
354
  clearTimeout(timer);
@@ -462,7 +472,7 @@ function makeWebSearchTool(options = {}) {
462
472
  if (!res.ok) return `Error: search returned ${res.status} ${res.statusText}`;
463
473
  return formatHits(parseDdgHtml(await res.text(), maxResults));
464
474
  } catch (e) {
465
- log3.debug("WebSearch failed", e);
475
+ log4.debug("WebSearch failed", e);
466
476
  return `Error searching: ${e?.name === "AbortError" ? `timed out after ${timeoutMs}ms` : e?.message ?? e}`;
467
477
  } finally {
468
478
  clearTimeout(timer);
@@ -479,7 +489,7 @@ function makeWebSearchAnthropicTool(opts = {}) {
479
489
  var webSearchAnthropicTool = makeWebSearchAnthropicTool();
480
490
 
481
491
  // src/tools.ts
482
- var log4 = forComponent("tools");
492
+ var log5 = forComponent("tools");
483
493
  function truncateOutput(s, headLines = 80, tailLines = 20) {
484
494
  const lines = s.split("\n");
485
495
  if (lines.length <= headLines + tailLines + 1) return s;
@@ -534,7 +544,7 @@ async function findSandboxWrapper(platform = process.platform) {
534
544
  }
535
545
 
536
546
  // src/tools.jobs.ts
537
- var log5 = forComponent("jobs");
547
+ var log6 = forComponent("jobs");
538
548
  var JobRegistryOptions = class {
539
549
  /** Tail buffer cap per job (chars). */
540
550
  maxBuffer = 256 * 1024;
@@ -713,7 +723,7 @@ var JobRegistry = class {
713
723
  try {
714
724
  onExit({ id: job.id, kind: job.kind, label: job.label, status, reason: job.reason, tail: job.buf.slice(-4e3), result });
715
725
  } catch (e) {
716
- log5.warn(`job onExit handler threw for ${job.id}: ${e}`);
726
+ log6.warn(`job onExit handler threw for ${job.id}: ${e}`);
717
727
  }
718
728
  }
719
729
  }
@@ -767,7 +777,7 @@ var JobRegistry = class {
767
777
  try {
768
778
  j.onKill?.(reason);
769
779
  } catch (e) {
770
- log5.warn(`onKill for ${id} threw: ${e}`);
780
+ log6.warn(`onKill for ${id} threw: ${e}`);
771
781
  }
772
782
  }
773
783
  return true;
@@ -814,7 +824,7 @@ var JobRegistry = class {
814
824
  try {
815
825
  cpu = await j.cpuTime();
816
826
  } catch (e) {
817
- log5.debug(`cpu probe for ${j.id} failed: ${e}`);
827
+ log6.debug(`cpu probe for ${j.id} failed: ${e}`);
818
828
  }
819
829
  if (cpu != null && j.lastCpu != null && cpu > j.lastCpu) j.lastActivityAt = this.options.now();
820
830
  const prev = j.lastCpu;
@@ -822,7 +832,7 @@ var JobRegistry = class {
822
832
  const verdict = this.verdict(j, now);
823
833
  if (!verdict?.idle || j.status !== "running") continue;
824
834
  if (cpu == null) {
825
- log5.debug(`not reaping ${j.id}: ${verdict.reason} but CPU unknown`);
835
+ log6.debug(`not reaping ${j.id}: ${verdict.reason} but CPU unknown`);
826
836
  continue;
827
837
  }
828
838
  if (prev == null) continue;
@@ -836,7 +846,7 @@ var JobRegistry = class {
836
846
  return null;
837
847
  }
838
848
  stuck(j, reason, now) {
839
- log5.warn(`reaping ${j.id} (${j.kind} "${j.label}"): ${reason} \u2014 age ${secs(now - j.startedAt)}, last activity ${secs(now - j.lastActivityAt)} ago, idleMs=${j.idleMs}, hardCapMs=${j.hardCapMs}, ${j.bytes} byte(s) output`);
849
+ log6.warn(`reaping ${j.id} (${j.kind} "${j.label}"): ${reason} \u2014 age ${secs(now - j.startedAt)}, last activity ${secs(now - j.lastActivityAt)} ago, idleMs=${j.idleMs}, hardCapMs=${j.hardCapMs}, ${j.bytes} byte(s) output`);
840
850
  if (j.onKill) j.notify = true;
841
851
  this.kill(j.id, reason);
842
852
  }
@@ -850,7 +860,7 @@ var JobRegistry = class {
850
860
  this.timer = void 0;
851
861
  return;
852
862
  }
853
- void this.sweep().catch((e) => log5.warn(`job sweep failed: ${e}`));
863
+ void this.sweep().catch((e) => log6.warn(`job sweep failed: ${e}`));
854
864
  }, this.options.sweepMs);
855
865
  this.timer.unref?.();
856
866
  }
@@ -862,7 +872,7 @@ var JobRegistry = class {
862
872
  };
863
873
 
864
874
  // src/tools.shell.ts
865
- var log6 = forComponent("shell");
875
+ var log7 = forComponent("shell");
866
876
  var clean = (s) => truncateOutput(redactSecrets(s.replace(/\n+$/, "")));
867
877
  var DETACHED = { stdio: ["ignore", "pipe", "pipe"], detached: true };
868
878
  function killGroup(proc, signal) {
@@ -910,7 +920,7 @@ async function psGroupCpuSeconds(pgid) {
910
920
  const out = await new Promise((res, rej) => execFile("ps", ["-A", "-o", "pid=,ppid=,pgid=,time="], { timeout: 5e3, env: { ...process.env, LC_ALL: "C" } }, (e, so) => e ? rej(e) : res(String(so))));
911
921
  return sumTreeCpu(out, pgid);
912
922
  } catch (e) {
913
- log6.debug(`ps cpu probe failed for group ${pgid}: ${e}`);
923
+ log7.debug(`ps cpu probe failed for group ${pgid}: ${e}`);
914
924
  return void 0;
915
925
  }
916
926
  }
@@ -1196,7 +1206,7 @@ function makeRealShellTool(options) {
1196
1206
  proc.stderr?.on("data", collect);
1197
1207
  proc.on("error", (err) => {
1198
1208
  if (err?.name === "AbortError" || ctl.signal.aborted) return finish(reasonFor(timedOut, timeoutMs, clean(out)));
1199
- log6.debug("shell spawn error", err);
1209
+ log7.debug("shell spawn error", err);
1200
1210
  finish(`[exit 1] ${err?.message ?? err}${out ? "\n" + clean(out) : ""}`);
1201
1211
  });
1202
1212
  proc.on("close", (code) => {