@livx.cc/agentx 0.99.72 → 0.99.74
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/dist/{Agent-CuXPAfSY.d.ts → Agent-Bs2ufrIU.d.ts} +9 -2
- package/dist/cli.d.ts +3 -6
- package/dist/cli.js +430 -295
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +295 -178
- package/dist/index.js.map +1 -1
- package/dist/{mcp-DGd2If0Z.d.ts → mcp-BhTxN2I7.d.ts} +1 -1
- package/dist/mcp.client.d.ts +2 -2
- package/dist/{tools-DV4SkkQs.d.ts → tools-lC3jn60o.d.ts} +5 -5
- package/dist/tools.shell.d.ts +1 -1
- package/dist/tools.shell.js +21 -16
- package/dist/tools.shell.js.map +1 -1
- package/package.json +2 -2
package/dist/mcp.client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as McpToolSearchOptions, f as McpToolSpec } from './mcp-
|
|
2
|
-
import { A as AgentTool } from './tools-
|
|
1
|
+
import { e as McpToolSearchOptions, f as McpToolSpec } from './mcp-BhTxN2I7.js';
|
|
2
|
+
import { A as AgentTool } from './tools-lC3jn60o.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
|
-
*
|
|
133
|
-
*
|
|
132
|
+
* Token-estimate weight (chars; /4 = tokens) of a transcript AS IT WILL GO ON THE WIRE — an image inside
|
|
133
|
+
* the keep window weighs its pixel tokens ×4 (`wiredImageWeight`, never its base64 length), 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: {
|
package/dist/tools.shell.d.ts
CHANGED
package/dist/tools.shell.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { CommandExecutor, registerHeadlessCommands } from "@livx.cc/wcli/core";
|
|
3
3
|
|
|
4
4
|
// src/llm.ts
|
|
5
|
-
import {
|
|
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,13 @@ 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, statSync } from "fs";
|
|
15
|
+
import { imageWireOf, inlineImageForWire, scrubBase64Text, imageSize, imageNote, IMAGE_MAX_SIDE, IMAGE_MAX_BYTES } from "ai.libx.js";
|
|
16
|
+
var log2 = forComponent("imageWire");
|
|
17
|
+
|
|
13
18
|
// src/llm.ts
|
|
14
|
-
var
|
|
19
|
+
var log3 = forComponent("llm");
|
|
15
20
|
|
|
16
21
|
// src/redact.ts
|
|
17
22
|
var REDACTED = "\u2039redacted\u203A";
|
|
@@ -214,7 +219,7 @@ var globTool = makeGlobTool();
|
|
|
214
219
|
var grepTool = makeGrepTool();
|
|
215
220
|
|
|
216
221
|
// src/tools.web.ts
|
|
217
|
-
var
|
|
222
|
+
var log4 = forComponent("web");
|
|
218
223
|
function htmlToText(html) {
|
|
219
224
|
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
225
|
s = s.replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;/g, "'").replace(/'/gi, "'");
|
|
@@ -338,7 +343,7 @@ function makeWebFetchTool(options = {}) {
|
|
|
338
343
|
|
|
339
344
|
${capped}`;
|
|
340
345
|
} catch (e) {
|
|
341
|
-
|
|
346
|
+
log4.debug(`WebFetch ${u} failed`, e);
|
|
342
347
|
return `Error fetching ${u}: ${e?.name === "AbortError" ? `timed out after ${timeoutMs}ms` : e?.message ?? e}`;
|
|
343
348
|
} finally {
|
|
344
349
|
clearTimeout(timer);
|
|
@@ -462,7 +467,7 @@ function makeWebSearchTool(options = {}) {
|
|
|
462
467
|
if (!res.ok) return `Error: search returned ${res.status} ${res.statusText}`;
|
|
463
468
|
return formatHits(parseDdgHtml(await res.text(), maxResults));
|
|
464
469
|
} catch (e) {
|
|
465
|
-
|
|
470
|
+
log4.debug("WebSearch failed", e);
|
|
466
471
|
return `Error searching: ${e?.name === "AbortError" ? `timed out after ${timeoutMs}ms` : e?.message ?? e}`;
|
|
467
472
|
} finally {
|
|
468
473
|
clearTimeout(timer);
|
|
@@ -479,7 +484,7 @@ function makeWebSearchAnthropicTool(opts = {}) {
|
|
|
479
484
|
var webSearchAnthropicTool = makeWebSearchAnthropicTool();
|
|
480
485
|
|
|
481
486
|
// src/tools.ts
|
|
482
|
-
var
|
|
487
|
+
var log5 = forComponent("tools");
|
|
483
488
|
function truncateOutput(s, headLines = 80, tailLines = 20) {
|
|
484
489
|
const lines = s.split("\n");
|
|
485
490
|
if (lines.length <= headLines + tailLines + 1) return s;
|
|
@@ -534,7 +539,7 @@ async function findSandboxWrapper(platform = process.platform) {
|
|
|
534
539
|
}
|
|
535
540
|
|
|
536
541
|
// src/tools.jobs.ts
|
|
537
|
-
var
|
|
542
|
+
var log6 = forComponent("jobs");
|
|
538
543
|
var JobRegistryOptions = class {
|
|
539
544
|
/** Tail buffer cap per job (chars). */
|
|
540
545
|
maxBuffer = 256 * 1024;
|
|
@@ -713,7 +718,7 @@ var JobRegistry = class {
|
|
|
713
718
|
try {
|
|
714
719
|
onExit({ id: job.id, kind: job.kind, label: job.label, status, reason: job.reason, tail: job.buf.slice(-4e3), result });
|
|
715
720
|
} catch (e) {
|
|
716
|
-
|
|
721
|
+
log6.warn(`job onExit handler threw for ${job.id}: ${e}`);
|
|
717
722
|
}
|
|
718
723
|
}
|
|
719
724
|
}
|
|
@@ -767,7 +772,7 @@ var JobRegistry = class {
|
|
|
767
772
|
try {
|
|
768
773
|
j.onKill?.(reason);
|
|
769
774
|
} catch (e) {
|
|
770
|
-
|
|
775
|
+
log6.warn(`onKill for ${id} threw: ${e}`);
|
|
771
776
|
}
|
|
772
777
|
}
|
|
773
778
|
return true;
|
|
@@ -814,7 +819,7 @@ var JobRegistry = class {
|
|
|
814
819
|
try {
|
|
815
820
|
cpu = await j.cpuTime();
|
|
816
821
|
} catch (e) {
|
|
817
|
-
|
|
822
|
+
log6.debug(`cpu probe for ${j.id} failed: ${e}`);
|
|
818
823
|
}
|
|
819
824
|
if (cpu != null && j.lastCpu != null && cpu > j.lastCpu) j.lastActivityAt = this.options.now();
|
|
820
825
|
const prev = j.lastCpu;
|
|
@@ -822,7 +827,7 @@ var JobRegistry = class {
|
|
|
822
827
|
const verdict = this.verdict(j, now);
|
|
823
828
|
if (!verdict?.idle || j.status !== "running") continue;
|
|
824
829
|
if (cpu == null) {
|
|
825
|
-
|
|
830
|
+
log6.debug(`not reaping ${j.id}: ${verdict.reason} but CPU unknown`);
|
|
826
831
|
continue;
|
|
827
832
|
}
|
|
828
833
|
if (prev == null) continue;
|
|
@@ -836,7 +841,7 @@ var JobRegistry = class {
|
|
|
836
841
|
return null;
|
|
837
842
|
}
|
|
838
843
|
stuck(j, reason, now) {
|
|
839
|
-
|
|
844
|
+
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
845
|
if (j.onKill) j.notify = true;
|
|
841
846
|
this.kill(j.id, reason);
|
|
842
847
|
}
|
|
@@ -850,7 +855,7 @@ var JobRegistry = class {
|
|
|
850
855
|
this.timer = void 0;
|
|
851
856
|
return;
|
|
852
857
|
}
|
|
853
|
-
void this.sweep().catch((e) =>
|
|
858
|
+
void this.sweep().catch((e) => log6.warn(`job sweep failed: ${e}`));
|
|
854
859
|
}, this.options.sweepMs);
|
|
855
860
|
this.timer.unref?.();
|
|
856
861
|
}
|
|
@@ -862,7 +867,7 @@ var JobRegistry = class {
|
|
|
862
867
|
};
|
|
863
868
|
|
|
864
869
|
// src/tools.shell.ts
|
|
865
|
-
var
|
|
870
|
+
var log7 = forComponent("shell");
|
|
866
871
|
var clean = (s) => truncateOutput(redactSecrets(s.replace(/\n+$/, "")));
|
|
867
872
|
var DETACHED = { stdio: ["ignore", "pipe", "pipe"], detached: true };
|
|
868
873
|
function killGroup(proc, signal) {
|
|
@@ -910,7 +915,7 @@ async function psGroupCpuSeconds(pgid) {
|
|
|
910
915
|
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
916
|
return sumTreeCpu(out, pgid);
|
|
912
917
|
} catch (e) {
|
|
913
|
-
|
|
918
|
+
log7.debug(`ps cpu probe failed for group ${pgid}: ${e}`);
|
|
914
919
|
return void 0;
|
|
915
920
|
}
|
|
916
921
|
}
|
|
@@ -1196,7 +1201,7 @@ function makeRealShellTool(options) {
|
|
|
1196
1201
|
proc.stderr?.on("data", collect);
|
|
1197
1202
|
proc.on("error", (err) => {
|
|
1198
1203
|
if (err?.name === "AbortError" || ctl.signal.aborted) return finish(reasonFor(timedOut, timeoutMs, clean(out)));
|
|
1199
|
-
|
|
1204
|
+
log7.debug("shell spawn error", err);
|
|
1200
1205
|
finish(`[exit 1] ${err?.message ?? err}${out ? "\n" + clean(out) : ""}`);
|
|
1201
1206
|
});
|
|
1202
1207
|
proc.on("close", (code) => {
|