@livx.cc/agentx 0.99.3 → 0.99.5
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-B_JD31Zx.d.ts → Agent-DYMSg21f.d.ts} +1 -1
- package/dist/cli.d.ts +8 -3
- package/dist/cli.js +63 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/{mcp-BZcizHav.d.ts → mcp-DopVRDLx.d.ts} +1 -1
- package/dist/mcp.client.d.ts +2 -2
- package/dist/{tools-DmrqMJcI.d.ts → tools-DKf3hN4M.d.ts} +25 -0
- package/dist/tools.shell.d.ts +1 -1
- package/dist/tools.shell.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
2
|
-
import { M as Message, H as HostBridge, A as AgentTool, C as ChatLike, e as MessageContent } from './tools-
|
|
2
|
+
import { M as Message, H as HostBridge, A as AgentTool, C as ChatLike, e as MessageContent } from './tools-DKf3hN4M.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hooks — deterministic interception points around tool execution, run by the
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { H as Hooks, h as RunResult, R as ReasoningEffort, A as Agent } from './Agent-
|
|
2
|
+
import { H as Hooks, h as RunResult, R as ReasoningEffort, A as Agent } from './Agent-DYMSg21f.js';
|
|
3
3
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
4
|
-
import { M as Message, c as ContentPart, e as MessageContent } from './tools-
|
|
4
|
+
import { M as Message, H as HostBridge, c as ContentPart, e as MessageContent } from './tools-DKf3hN4M.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* On-disk session store for the CLI: each conversation is one JSON file at
|
|
@@ -146,6 +146,11 @@ interface Args {
|
|
|
146
146
|
update?: boolean;
|
|
147
147
|
}
|
|
148
148
|
declare function parseArgs(argv: string[]): Args;
|
|
149
|
+
declare function makeHost(format?: 'text' | 'json' | 'stream-json', opts?: {
|
|
150
|
+
stream?: boolean;
|
|
151
|
+
}): HostBridge & {
|
|
152
|
+
flushText: () => void;
|
|
153
|
+
};
|
|
149
154
|
/** Hooks that render tool activity to stderr: a preToolUse header, and for edits a colorized diff.
|
|
150
155
|
* `opts.background` marks the agent as a BACKGROUND one (duplex workers): its chrome lands async on
|
|
151
156
|
* top of a live prompt, so it must never drive the foreground spinner (the 'agentx › '/'⠹ thinking…'
|
|
@@ -293,4 +298,4 @@ declare function runTurn(agent: Agent, store: SessionStore, session: SessionData
|
|
|
293
298
|
res?: RunResult;
|
|
294
299
|
}>;
|
|
295
300
|
|
|
296
|
-
export { type PermMode, abortActiveTurn, appendMemoryNote, cacheMultipliers, condenseReplay, costOf, estimateTranscriptTokens, expandMentions, exportMarkdown, fmtUsd, formatHistory, formatStatus, formatTranscriptFull, jsonResult, mcpMentionResolver, mentionRefs, parseArgs, pastePathClassifier, readImageParts, readMultiline, resolvePermMode, runShellLine, runTurn, setMcpMentionResolver, summarizeResult };
|
|
301
|
+
export { type PermMode, abortActiveTurn, appendMemoryNote, cacheMultipliers, condenseReplay, costOf, estimateTranscriptTokens, expandMentions, exportMarkdown, fmtUsd, formatHistory, formatStatus, formatTranscriptFull, jsonResult, makeHost, mcpMentionResolver, mentionRefs, parseArgs, pastePathClassifier, readImageParts, readMultiline, resolvePermMode, runShellLine, runTurn, setMcpMentionResolver, summarizeResult };
|
package/dist/cli.js
CHANGED
|
@@ -3681,6 +3681,11 @@ var Agent = class _Agent {
|
|
|
3681
3681
|
for await (const chunk of stream) {
|
|
3682
3682
|
if (this.options.signal?.aborted) break;
|
|
3683
3683
|
if (chunk.reasoningContent) this.options.host.notify({ kind: "thinking_delta", message: chunk.reasoningContent });
|
|
3684
|
+
if (chunk.toolActivity) {
|
|
3685
|
+
const a = chunk.toolActivity;
|
|
3686
|
+
const verb = a.status === "error" ? "\u2717" : a.status === "completed" ? "\u2713" : "\u2192";
|
|
3687
|
+
this.options.host.notify({ kind: "tool_activity", id: a.id, name: a.name, input: a.input, output: a.output, status: a.status, truncated: a.truncated, message: `${verb} ${a.name}` });
|
|
3688
|
+
}
|
|
3684
3689
|
if (chunk.content) {
|
|
3685
3690
|
content += chunk.content;
|
|
3686
3691
|
this.options.host.notify({ kind: "text_delta", message: chunk.content });
|
|
@@ -9051,6 +9056,17 @@ function renderMdLine(line, inFence, p, cols = 80, fenceLang) {
|
|
|
9051
9056
|
if (b) return { out: b[1] + p.cyan("\u2022") + " " + mdInline(vis(b[2]), p), inFence };
|
|
9052
9057
|
return { out: mdInline(vis(line), p), inFence };
|
|
9053
9058
|
}
|
|
9059
|
+
function renderMdBlock(text, p, cols = 80) {
|
|
9060
|
+
let inFence = false, fenceLang;
|
|
9061
|
+
const out = [];
|
|
9062
|
+
for (const line of text.split("\n")) {
|
|
9063
|
+
const r = renderMdLine(line, inFence, p, cols, fenceLang);
|
|
9064
|
+
inFence = r.inFence;
|
|
9065
|
+
fenceLang = r.fenceLang;
|
|
9066
|
+
out.push(r.inFence || /^\s*```/.test(line) ? r.out : wrapAnsi(r.out, cols, hangIndent(line)));
|
|
9067
|
+
}
|
|
9068
|
+
return out.join("\n");
|
|
9069
|
+
}
|
|
9054
9070
|
function isTableRow(line) {
|
|
9055
9071
|
return /^\s*\|.*\|\s*$/.test(line);
|
|
9056
9072
|
}
|
|
@@ -10697,6 +10713,7 @@ var yellow = C("33");
|
|
|
10697
10713
|
var italic = C("3");
|
|
10698
10714
|
var strike = C("9");
|
|
10699
10715
|
var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
|
|
10716
|
+
var mdPalette = { bold, dim, cyan, italic, strike, green, link };
|
|
10700
10717
|
var err = (s) => process.stderr.write(s);
|
|
10701
10718
|
var log23 = forComponent("cli");
|
|
10702
10719
|
var VERSION = (() => {
|
|
@@ -11000,7 +11017,7 @@ function apiKeysFromEnv() {
|
|
|
11000
11017
|
function makeHost(format = "text", opts) {
|
|
11001
11018
|
const streamJson = format === "stream-json";
|
|
11002
11019
|
const cleanStdout = format === "json";
|
|
11003
|
-
const md = format === "text" && useColor && opts?.stream ? new MarkdownStream(
|
|
11020
|
+
const md = format === "text" && useColor && opts?.stream ? new MarkdownStream(mdPalette, process.stdout.columns ?? 80) : null;
|
|
11004
11021
|
if (md) process.on("SIGWINCH", () => md.resize(process.stdout.columns ?? 80));
|
|
11005
11022
|
const flushText = () => {
|
|
11006
11023
|
if (md && md.pending()) process.stdout.write(md.commit());
|
|
@@ -11012,10 +11029,14 @@ function makeHost(format = "text", opts) {
|
|
|
11012
11029
|
openReasonLine = false;
|
|
11013
11030
|
}
|
|
11014
11031
|
};
|
|
11032
|
+
const activitySeen = /* @__PURE__ */ new Set();
|
|
11015
11033
|
return {
|
|
11016
11034
|
flushText,
|
|
11017
11035
|
notify(e) {
|
|
11018
|
-
if (e.kind === "turn_start")
|
|
11036
|
+
if (e.kind === "turn_start") {
|
|
11037
|
+
activitySeen.clear();
|
|
11038
|
+
return;
|
|
11039
|
+
}
|
|
11019
11040
|
spinner.stop();
|
|
11020
11041
|
if (e.kind === "text_delta") {
|
|
11021
11042
|
flushLookupGroup();
|
|
@@ -11039,6 +11060,43 @@ function makeHost(format = "text", opts) {
|
|
|
11039
11060
|
}
|
|
11040
11061
|
return;
|
|
11041
11062
|
}
|
|
11063
|
+
if (e.kind === "tool_activity") {
|
|
11064
|
+
const a = e;
|
|
11065
|
+
flushLookupGroup();
|
|
11066
|
+
closeReasonLine();
|
|
11067
|
+
flushText();
|
|
11068
|
+
if (streamJson) {
|
|
11069
|
+
process.stdout.write(JSON.stringify({ type: "tool_activity", id: a.id, name: a.name, input: a.input, output: a.output, status: a.status }) + "\n");
|
|
11070
|
+
return;
|
|
11071
|
+
}
|
|
11072
|
+
const clip = (s) => s.length > 200 ? s.slice(0, 200) + "\u2026" : s;
|
|
11073
|
+
const terminal = a.status === "completed" || a.status === "error";
|
|
11074
|
+
if (!terminal || !a.id || !activitySeen.has(a.id)) {
|
|
11075
|
+
if (a.id) activitySeen.add(a.id);
|
|
11076
|
+
const argHint = summarizeCall(a.name, a.input) + (a.truncated?.args ? " \u2026" : "");
|
|
11077
|
+
err(cyan(` \u2699 ${a.name}`) + (argHint ? dim(" " + argHint) : "") + "\n");
|
|
11078
|
+
}
|
|
11079
|
+
if (terminal) {
|
|
11080
|
+
if (a.id) activitySeen.delete(a.id);
|
|
11081
|
+
const raw = a.output == null ? "" : typeof a.output === "string" ? a.output : JSON.stringify(a.output);
|
|
11082
|
+
const text = raw.replace(/\s+$/, "");
|
|
11083
|
+
const paint = a.status === "error" ? red : dim;
|
|
11084
|
+
if (!text) {
|
|
11085
|
+
if (a.status === "error") err(paint(" \u23BF (error)\n"));
|
|
11086
|
+
spinner.start();
|
|
11087
|
+
return;
|
|
11088
|
+
}
|
|
11089
|
+
const lines = text.split("\n");
|
|
11090
|
+
const shown = lines.slice(0, previewLines());
|
|
11091
|
+
err(paint(" \u23BF " + clip(shown[0])) + "\n");
|
|
11092
|
+
for (const ln of shown.slice(1)) err(dim(" " + clip(ln)) + "\n");
|
|
11093
|
+
const more = lines.length - shown.length;
|
|
11094
|
+
if (more > 0 || a.truncated?.result) err(dim(` \u2026 (${more > 0 ? `+${more} more line${more > 1 ? "s" : ""}` : "truncated by backend"}${a.truncated?.result && more > 0 ? ", truncated" : ""} \xB7 ctrl+o expands)
|
|
11095
|
+
`));
|
|
11096
|
+
}
|
|
11097
|
+
spinner.start();
|
|
11098
|
+
return;
|
|
11099
|
+
}
|
|
11042
11100
|
if (!("message" in e)) return;
|
|
11043
11101
|
flushLookupGroup();
|
|
11044
11102
|
closeReasonLine();
|
|
@@ -11219,7 +11277,7 @@ function formatHistory(messages) {
|
|
|
11219
11277
|
if (t) out.push("\n" + bold(cyan(" \u203A ")) + (t.length > 1500 ? clipReplay(t, 1500) + dim(" \u2026") : t) + "\n");
|
|
11220
11278
|
} else if (m.role === "assistant") {
|
|
11221
11279
|
const at = contentText(m.content);
|
|
11222
|
-
if (at.trim()) out.push(
|
|
11280
|
+
if (at.trim()) out.push(renderMdBlock(at.trim(), mdPalette, (process.stderr.columns ?? 80) - 2).replace(/^/gm, " ") + "\n");
|
|
11223
11281
|
for (const tc of m.tool_calls ?? []) {
|
|
11224
11282
|
let args = {};
|
|
11225
11283
|
try {
|
|
@@ -11255,7 +11313,7 @@ function formatTranscriptFull(messages, opts) {
|
|
|
11255
11313
|
if (t) out.push("\n" + bold(cyan(" \u203A ")) + t.replace(/\n/g, "\n ") + "\n");
|
|
11256
11314
|
} else if (m.role === "assistant") {
|
|
11257
11315
|
const at = contentText(m.content).trim();
|
|
11258
|
-
if (at) out.push(
|
|
11316
|
+
if (at) out.push(renderMdBlock(at, mdPalette, (process.stderr.columns ?? 80) - 2).replace(/^/gm, " ") + "\n");
|
|
11259
11317
|
for (const tc of m.tool_calls ?? []) {
|
|
11260
11318
|
let args = {};
|
|
11261
11319
|
try {
|
|
@@ -14135,6 +14193,7 @@ export {
|
|
|
14135
14193
|
formatStatus,
|
|
14136
14194
|
formatTranscriptFull,
|
|
14137
14195
|
jsonResult,
|
|
14196
|
+
makeHost,
|
|
14138
14197
|
mcpMentionResolver,
|
|
14139
14198
|
mentionRefs,
|
|
14140
14199
|
parseArgs,
|