@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
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-
|
|
2
|
-
export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-
|
|
1
|
+
import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-ChSs1QSx.js';
|
|
2
|
+
export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-ChSs1QSx.js';
|
|
3
3
|
export { MODEL_ALIASES, ModelSwitch, ResolveModelSwitchOpts, modelShortLabel, resolveModelAlias, resolveModelSwitch } from './models.js';
|
|
4
4
|
import { IFilesystem, FileMetadata } from '@livx.cc/wcli/core';
|
|
5
5
|
export { CommandExecutor, FileMetadata, IFilesystem, IndexedDbFilesystem, MemFilesystem, registerHeadlessCommands } from '@livx.cc/wcli/core';
|
|
6
6
|
import { BodDB } from '@bod.ee/db';
|
|
7
|
-
import { A as AgentTool, C as ChatLike, a as ChatOptions, b as ChatResponse, h as ToolCall, H as HostBridge, U as UserQuestion, e as MessageContent } from './tools-
|
|
8
|
-
export { c as ContentPart, d as HostEvent, M as Message, R as Role, S as SandboxJobRegistry, f as StreamChunk, T as TodoItem, g as Tool, i as ToolContext, j as bashTool, k as contentText, l as defaultTools, m as editTool, n as exitSessionTool, o as imagePart, p as makeContext, q as makeJobTools, r as readTool, t as toWireTools, s as todoWriteTool, u as toolRegistry, v as toolsByName } from './tools-
|
|
7
|
+
import { A as AgentTool, C as ChatLike, a as ChatOptions, b as ChatResponse, h as ToolCall, H as HostBridge, U as UserQuestion, e as MessageContent } from './tools-CJAPSBhS.js';
|
|
8
|
+
export { c as ContentPart, d as HostEvent, M as Message, R as Role, S as SandboxJobRegistry, f as StreamChunk, T as TodoItem, g as Tool, i as ToolContext, j as bashTool, k as contentText, l as defaultTools, m as editTool, n as exitSessionTool, o as imagePart, p as makeContext, q as makeJobTools, r as readTool, t as toWireTools, s as todoWriteTool, u as toolRegistry, v as toolsByName } from './tools-CJAPSBhS.js';
|
|
9
9
|
import { SpokenSplitter } from '@bod.ee/voice';
|
|
10
10
|
export { AudioSink, AudioSource, AuthProvider, CartesiaTTS, CartesiaTTSOptions, STT_SAMPLE_RATE, SonioxSTT, SonioxSTTOptions, SttLike, TTS_SAMPLE_RATE, TtsLike, VoiceEngine, VoiceEngineOptions, VoiceState, resolveAuth } from '@bod.ee/voice';
|
|
11
|
-
export { M as McpCall, a as McpImage, b as McpRoute, c as McpRouteResolver, d as McpToolResult, e as McpToolSearchOptions, f as McpToolSpec, g as MountedMcpLike, h as buildMcpCatalog, m as makeLazyMcpToolSearch, i as makeMcpToolSearch, j as makeMcpToolSearchFromMounted, k as mcpToolToAgentTool, l as mcpToolsToAgentTools } from './mcp-
|
|
11
|
+
export { M as McpCall, a as McpImage, b as McpRoute, c as McpRouteResolver, d as McpToolResult, e as McpToolSearchOptions, f as McpToolSpec, g as MountedMcpLike, h as buildMcpCatalog, m as makeLazyMcpToolSearch, i as makeMcpToolSearch, j as makeMcpToolSearchFromMounted, k as mcpToolToAgentTool, l as mcpToolsToAgentTools } from './mcp-DiAiMiG5.js';
|
|
12
12
|
import * as libx_js_src_modules_log from 'libx.js/src/modules/log';
|
|
13
13
|
export { log } from 'libx.js/src/modules/log';
|
|
14
14
|
|
package/dist/index.js
CHANGED
|
@@ -3254,6 +3254,11 @@ var AgentOptions = class {
|
|
|
3254
3254
|
traceDir;
|
|
3255
3255
|
/** Stream tokens from the model. Takes effect only with a `host.notify`; off => current (non-stream) behavior. */
|
|
3256
3256
|
stream = false;
|
|
3257
|
+
/** Closure reflex for delegated runtimes (cursor/claude-code): when such a turn ends on a tool call with
|
|
3258
|
+
* no assistant text after it (the runtime went silent post-work), nudge ONE more step for a brief summary
|
|
3259
|
+
* of what changed + what's pending — so the turn delivers a wrap-up instead of trailing off mid-narration.
|
|
3260
|
+
* Fires at most once per run and only for delegated runtimes (native turns never emit the trigger). */
|
|
3261
|
+
closeDelegatedTurns = true;
|
|
3257
3262
|
/** Fold the dropped middle of an over-long transcript into a synthetic summary (edge-safe, no LLM). Off => drop-oldest. */
|
|
3258
3263
|
compaction;
|
|
3259
3264
|
/** Add `Checkpoint`/`Rollback` tools (requires the fs to be an OverlayFilesystem). */
|
|
@@ -3583,6 +3588,7 @@ var Agent = class _Agent {
|
|
|
3583
3588
|
let toolCallsTotal = 0;
|
|
3584
3589
|
let lastFp = "";
|
|
3585
3590
|
let repeats = 0;
|
|
3591
|
+
let closureNudged = false;
|
|
3586
3592
|
const kill = (finishReason) => {
|
|
3587
3593
|
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` : ""})`);
|
|
3588
3594
|
this.ctx.jobs?.killAll();
|
|
@@ -3678,8 +3684,33 @@ var Agent = class _Agent {
|
|
|
3678
3684
|
usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
|
|
3679
3685
|
usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
|
|
3680
3686
|
}
|
|
3687
|
+
const delegatedTools = res.delegatedTools ?? [];
|
|
3688
|
+
if (delegatedTools.length) {
|
|
3689
|
+
const cap = this.options.maxToolResultBytes ?? 0;
|
|
3690
|
+
this.transcript.push({
|
|
3691
|
+
role: "assistant",
|
|
3692
|
+
content: "",
|
|
3693
|
+
tool_calls: delegatedTools.map((a) => ({ id: a.id, type: "function", function: { name: a.name || "tool", arguments: (() => {
|
|
3694
|
+
try {
|
|
3695
|
+
return JSON.stringify(a.input ?? {});
|
|
3696
|
+
} catch {
|
|
3697
|
+
return "{}";
|
|
3698
|
+
}
|
|
3699
|
+
})() } }))
|
|
3700
|
+
});
|
|
3701
|
+
for (const a of delegatedTools) {
|
|
3702
|
+
const out = typeof a.output === "string" ? a.output : a.output == null ? "" : (() => {
|
|
3703
|
+
try {
|
|
3704
|
+
return JSON.stringify(a.output);
|
|
3705
|
+
} catch {
|
|
3706
|
+
return String(a.output);
|
|
3707
|
+
}
|
|
3708
|
+
})();
|
|
3709
|
+
this.transcript.push({ role: "tool", tool_call_id: a.id, content: cap > 0 && out.length > cap ? cropResult(out, cap) : out });
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3681
3712
|
const toolCalls = res.toolCalls ?? [];
|
|
3682
|
-
const emptyTurn = toolCalls.length === 0 && contentText(res.content ?? "").trim() === "";
|
|
3713
|
+
const emptyTurn = toolCalls.length === 0 && delegatedTools.length === 0 && contentText(res.content ?? "").trim() === "";
|
|
3683
3714
|
if (!emptyTurn) {
|
|
3684
3715
|
this.transcript.push({
|
|
3685
3716
|
role: "assistant",
|
|
@@ -3689,6 +3720,12 @@ var Agent = class _Agent {
|
|
|
3689
3720
|
}
|
|
3690
3721
|
if (toolCalls.length === 0) {
|
|
3691
3722
|
if (this.drainInjections()) continue;
|
|
3723
|
+
if (o.closeDelegatedTurns && res.endedOnToolNoText && !closureNudged && steps < o.maxSteps) {
|
|
3724
|
+
closureNudged = true;
|
|
3725
|
+
log4.verbose("delegated turn went silent after a tool \u2014 nudging a closing summary");
|
|
3726
|
+
this.transcript.push({ role: "user", content: "Summarize what you did this turn and what (if anything) still needs doing. Be concise." });
|
|
3727
|
+
continue;
|
|
3728
|
+
}
|
|
3692
3729
|
log4.verbose(`completed in ${steps} step(s)`);
|
|
3693
3730
|
await this.ctx.jobs?.drain();
|
|
3694
3731
|
await this.activeHooks?.onStop?.(res.content ?? "");
|
|
@@ -3778,6 +3815,9 @@ var Agent = class _Agent {
|
|
|
3778
3815
|
let finishReason;
|
|
3779
3816
|
let toolCalls;
|
|
3780
3817
|
let usage;
|
|
3818
|
+
const delegated = /* @__PURE__ */ new Map();
|
|
3819
|
+
const delegatedOrder = [];
|
|
3820
|
+
let endedOnToolNoText = false;
|
|
3781
3821
|
for await (const chunk of stream) {
|
|
3782
3822
|
poke?.();
|
|
3783
3823
|
if (this.options.signal?.aborted) break;
|
|
@@ -3786,16 +3826,30 @@ var Agent = class _Agent {
|
|
|
3786
3826
|
const a = chunk.toolActivity;
|
|
3787
3827
|
const verb = a.status === "error" ? "\u2717" : a.status === "completed" ? "\u2713" : "\u2192";
|
|
3788
3828
|
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}` });
|
|
3829
|
+
const key = a.id ?? `${a.name}:${delegatedOrder.length}`;
|
|
3830
|
+
const prev = delegated.get(key);
|
|
3831
|
+
if (!prev) {
|
|
3832
|
+
delegated.set(key, { id: key, name: a.name, input: a.input, output: a.output, status: a.status });
|
|
3833
|
+
delegatedOrder.push(key);
|
|
3834
|
+
} else {
|
|
3835
|
+
if (a.name) prev.name = a.name;
|
|
3836
|
+
if (a.input !== void 0) prev.input = a.input;
|
|
3837
|
+
if (a.output !== void 0) prev.output = a.output;
|
|
3838
|
+
prev.status = a.status;
|
|
3839
|
+
}
|
|
3840
|
+
endedOnToolNoText = true;
|
|
3789
3841
|
}
|
|
3790
3842
|
if (chunk.content) {
|
|
3791
3843
|
content += chunk.content;
|
|
3844
|
+
if (chunk.content.trim()) endedOnToolNoText = false;
|
|
3792
3845
|
this.options.host.notify({ kind: "text_delta", message: chunk.content });
|
|
3793
3846
|
}
|
|
3794
3847
|
if (chunk.finishReason) finishReason = chunk.finishReason;
|
|
3795
3848
|
if (chunk.toolCalls?.length) toolCalls = chunk.toolCalls;
|
|
3796
3849
|
if (chunk.usage) usage = chunk.usage;
|
|
3797
3850
|
}
|
|
3798
|
-
|
|
3851
|
+
const delegatedTools = delegatedOrder.map((k) => delegated.get(k));
|
|
3852
|
+
return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {}, ...endedOnToolNoText ? { endedOnToolNoText: true } : {} };
|
|
3799
3853
|
}
|
|
3800
3854
|
async dispatch(tc) {
|
|
3801
3855
|
const tool = this.activeTools.find((t) => t.name === tc.function.name);
|