@livx.cc/agentx 0.99.22 → 0.99.24
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-CM7HL95r.d.ts → Agent-ChSs1QSx.d.ts} +6 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +58 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +56 -2
- package/dist/index.js.map +1 -1
- package/dist/{mcp-2wyAAfPQ.d.ts → mcp-DiAiMiG5.d.ts} +1 -1
- package/dist/mcp.client.d.ts +2 -2
- package/dist/{tools-ClgFZjUr.d.ts → tools-CJAPSBhS.d.ts} +13 -0
- package/dist/tools.shell.d.ts +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, U as UserQuestion } from './tools-
|
|
2
|
+
import { M as Message, H as HostBridge, A as AgentTool, C as ChatLike, e as MessageContent, U as UserQuestion } from './tools-CJAPSBhS.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hooks — deterministic interception points around tool execution, run by the
|
|
@@ -298,6 +298,11 @@ declare class AgentOptions {
|
|
|
298
298
|
traceDir?: string;
|
|
299
299
|
/** Stream tokens from the model. Takes effect only with a `host.notify`; off => current (non-stream) behavior. */
|
|
300
300
|
stream: boolean;
|
|
301
|
+
/** Closure reflex for delegated runtimes (cursor/claude-code): when such a turn ends on a tool call with
|
|
302
|
+
* no assistant text after it (the runtime went silent post-work), nudge ONE more step for a brief summary
|
|
303
|
+
* of what changed + what's pending — so the turn delivers a wrap-up instead of trailing off mid-narration.
|
|
304
|
+
* Fires at most once per run and only for delegated runtimes (native turns never emit the trigger). */
|
|
305
|
+
closeDelegatedTurns: boolean;
|
|
301
306
|
/** Fold the dropped middle of an over-long transcript into a synthetic summary (edge-safe, no LLM). Off => drop-oldest. */
|
|
302
307
|
compaction?: {
|
|
303
308
|
maxMessages: number;
|
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-ChSs1QSx.js';
|
|
3
3
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
4
|
-
import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, e as MessageContent } from './tools-
|
|
4
|
+
import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, e as MessageContent } from './tools-CJAPSBhS.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* On-disk session store for the CLI: each conversation is one JSON file at
|
package/dist/cli.js
CHANGED
|
@@ -3292,6 +3292,11 @@ var AgentOptions = class {
|
|
|
3292
3292
|
traceDir;
|
|
3293
3293
|
/** Stream tokens from the model. Takes effect only with a `host.notify`; off => current (non-stream) behavior. */
|
|
3294
3294
|
stream = false;
|
|
3295
|
+
/** Closure reflex for delegated runtimes (cursor/claude-code): when such a turn ends on a tool call with
|
|
3296
|
+
* no assistant text after it (the runtime went silent post-work), nudge ONE more step for a brief summary
|
|
3297
|
+
* of what changed + what's pending — so the turn delivers a wrap-up instead of trailing off mid-narration.
|
|
3298
|
+
* Fires at most once per run and only for delegated runtimes (native turns never emit the trigger). */
|
|
3299
|
+
closeDelegatedTurns = true;
|
|
3295
3300
|
/** Fold the dropped middle of an over-long transcript into a synthetic summary (edge-safe, no LLM). Off => drop-oldest. */
|
|
3296
3301
|
compaction;
|
|
3297
3302
|
/** Add `Checkpoint`/`Rollback` tools (requires the fs to be an OverlayFilesystem). */
|
|
@@ -3621,6 +3626,7 @@ var Agent = class _Agent {
|
|
|
3621
3626
|
let toolCallsTotal = 0;
|
|
3622
3627
|
let lastFp = "";
|
|
3623
3628
|
let repeats = 0;
|
|
3629
|
+
let closureNudged = false;
|
|
3624
3630
|
const kill = (finishReason) => {
|
|
3625
3631
|
log4.warn(`kill-switch: ${finishReason} (steps=${steps}, tokens=${usage.totalTokens}, budgetTokens=${Math.round(usage.totalTokens - 0.9 * usage.cacheReadTokens)}, ms=${Date.now() - start - this.parkedMs}${this.parkedMs ? ` +${this.parkedMs} parked` : ""})`);
|
|
3626
3632
|
this.ctx.jobs?.killAll();
|
|
@@ -3716,8 +3722,33 @@ var Agent = class _Agent {
|
|
|
3716
3722
|
usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
|
|
3717
3723
|
usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
|
|
3718
3724
|
}
|
|
3725
|
+
const delegatedTools = res.delegatedTools ?? [];
|
|
3726
|
+
if (delegatedTools.length) {
|
|
3727
|
+
const cap = this.options.maxToolResultBytes ?? 0;
|
|
3728
|
+
this.transcript.push({
|
|
3729
|
+
role: "assistant",
|
|
3730
|
+
content: "",
|
|
3731
|
+
tool_calls: delegatedTools.map((a) => ({ id: a.id, type: "function", function: { name: a.name || "tool", arguments: (() => {
|
|
3732
|
+
try {
|
|
3733
|
+
return JSON.stringify(a.input ?? {});
|
|
3734
|
+
} catch {
|
|
3735
|
+
return "{}";
|
|
3736
|
+
}
|
|
3737
|
+
})() } }))
|
|
3738
|
+
});
|
|
3739
|
+
for (const a of delegatedTools) {
|
|
3740
|
+
const out = typeof a.output === "string" ? a.output : a.output == null ? "" : (() => {
|
|
3741
|
+
try {
|
|
3742
|
+
return JSON.stringify(a.output);
|
|
3743
|
+
} catch {
|
|
3744
|
+
return String(a.output);
|
|
3745
|
+
}
|
|
3746
|
+
})();
|
|
3747
|
+
this.transcript.push({ role: "tool", tool_call_id: a.id, content: cap > 0 && out.length > cap ? cropResult(out, cap) : out });
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3719
3750
|
const toolCalls = res.toolCalls ?? [];
|
|
3720
|
-
const emptyTurn = toolCalls.length === 0 && contentText(res.content ?? "").trim() === "";
|
|
3751
|
+
const emptyTurn = toolCalls.length === 0 && delegatedTools.length === 0 && contentText(res.content ?? "").trim() === "";
|
|
3721
3752
|
if (!emptyTurn) {
|
|
3722
3753
|
this.transcript.push({
|
|
3723
3754
|
role: "assistant",
|
|
@@ -3727,6 +3758,12 @@ var Agent = class _Agent {
|
|
|
3727
3758
|
}
|
|
3728
3759
|
if (toolCalls.length === 0) {
|
|
3729
3760
|
if (this.drainInjections()) continue;
|
|
3761
|
+
if (o.closeDelegatedTurns && res.endedOnToolNoText && !closureNudged && steps < o.maxSteps) {
|
|
3762
|
+
closureNudged = true;
|
|
3763
|
+
log4.verbose("delegated turn went silent after a tool \u2014 nudging a closing summary");
|
|
3764
|
+
this.transcript.push({ role: "user", content: "Summarize what you did this turn and what (if anything) still needs doing. Be concise." });
|
|
3765
|
+
continue;
|
|
3766
|
+
}
|
|
3730
3767
|
log4.verbose(`completed in ${steps} step(s)`);
|
|
3731
3768
|
await this.ctx.jobs?.drain();
|
|
3732
3769
|
await this.activeHooks?.onStop?.(res.content ?? "");
|
|
@@ -3816,6 +3853,9 @@ var Agent = class _Agent {
|
|
|
3816
3853
|
let finishReason;
|
|
3817
3854
|
let toolCalls;
|
|
3818
3855
|
let usage;
|
|
3856
|
+
const delegated = /* @__PURE__ */ new Map();
|
|
3857
|
+
const delegatedOrder = [];
|
|
3858
|
+
let endedOnToolNoText = false;
|
|
3819
3859
|
for await (const chunk of stream) {
|
|
3820
3860
|
poke?.();
|
|
3821
3861
|
if (this.options.signal?.aborted) break;
|
|
@@ -3824,16 +3864,30 @@ var Agent = class _Agent {
|
|
|
3824
3864
|
const a = chunk.toolActivity;
|
|
3825
3865
|
const verb = a.status === "error" ? "\u2717" : a.status === "completed" ? "\u2713" : "\u2192";
|
|
3826
3866
|
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}` });
|
|
3867
|
+
const key = a.id ?? `${a.name}:${delegatedOrder.length}`;
|
|
3868
|
+
const prev = delegated.get(key);
|
|
3869
|
+
if (!prev) {
|
|
3870
|
+
delegated.set(key, { id: key, name: a.name, input: a.input, output: a.output, status: a.status });
|
|
3871
|
+
delegatedOrder.push(key);
|
|
3872
|
+
} else {
|
|
3873
|
+
if (a.name) prev.name = a.name;
|
|
3874
|
+
if (a.input !== void 0) prev.input = a.input;
|
|
3875
|
+
if (a.output !== void 0) prev.output = a.output;
|
|
3876
|
+
prev.status = a.status;
|
|
3877
|
+
}
|
|
3878
|
+
endedOnToolNoText = true;
|
|
3827
3879
|
}
|
|
3828
3880
|
if (chunk.content) {
|
|
3829
3881
|
content += chunk.content;
|
|
3882
|
+
if (chunk.content.trim()) endedOnToolNoText = false;
|
|
3830
3883
|
this.options.host.notify({ kind: "text_delta", message: chunk.content });
|
|
3831
3884
|
}
|
|
3832
3885
|
if (chunk.finishReason) finishReason = chunk.finishReason;
|
|
3833
3886
|
if (chunk.toolCalls?.length) toolCalls = chunk.toolCalls;
|
|
3834
3887
|
if (chunk.usage) usage = chunk.usage;
|
|
3835
3888
|
}
|
|
3836
|
-
|
|
3889
|
+
const delegatedTools = delegatedOrder.map((k) => delegated.get(k));
|
|
3890
|
+
return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {}, ...endedOnToolNoText ? { endedOnToolNoText: true } : {} };
|
|
3837
3891
|
}
|
|
3838
3892
|
async dispatch(tc) {
|
|
3839
3893
|
const tool = this.activeTools.find((t) => t.name === tc.function.name);
|
|
@@ -13051,7 +13105,8 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
|
|
|
13051
13105
|
const m = res.usageEstimated ? "~" : "";
|
|
13052
13106
|
const tok = res.usage?.totalTokens ? `${m}${(res.usage.totalTokens / 1e3).toFixed(1)}k tok \xB7 ${cost > 0 ? m + fmtUsd(cost) + " \xB7 " : ""}` : "";
|
|
13053
13107
|
const lastUser = res.messages.map((m2) => m2.role).lastIndexOf("user");
|
|
13054
|
-
|
|
13108
|
+
agent.options.host?.takeToolCount?.();
|
|
13109
|
+
const tools = res.messages.slice(lastUser).filter((m2) => m2.role === "tool").length;
|
|
13055
13110
|
const ok = res.finishReason === "stop";
|
|
13056
13111
|
const shortId = session.meta.id.replace(/^\d{8}-/, "");
|
|
13057
13112
|
const didWork = agent.transcript.slice(msgsBefore).some((m2) => m2.role === "assistant" || m2.role === "tool");
|