@livx.cc/agentx 0.99.23 → 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/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-CSCWkq0C.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-CSCWkq0C.js';
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-hAKTlzty.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-hAKTlzty.js';
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-CM4Eq9Jf.js';
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();
@@ -3714,6 +3720,12 @@ var Agent = class _Agent {
3714
3720
  }
3715
3721
  if (toolCalls.length === 0) {
3716
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
+ }
3717
3729
  log4.verbose(`completed in ${steps} step(s)`);
3718
3730
  await this.ctx.jobs?.drain();
3719
3731
  await this.activeHooks?.onStop?.(res.content ?? "");
@@ -3805,6 +3817,7 @@ var Agent = class _Agent {
3805
3817
  let usage;
3806
3818
  const delegated = /* @__PURE__ */ new Map();
3807
3819
  const delegatedOrder = [];
3820
+ let endedOnToolNoText = false;
3808
3821
  for await (const chunk of stream) {
3809
3822
  poke?.();
3810
3823
  if (this.options.signal?.aborted) break;
@@ -3824,9 +3837,11 @@ var Agent = class _Agent {
3824
3837
  if (a.output !== void 0) prev.output = a.output;
3825
3838
  prev.status = a.status;
3826
3839
  }
3840
+ endedOnToolNoText = true;
3827
3841
  }
3828
3842
  if (chunk.content) {
3829
3843
  content += chunk.content;
3844
+ if (chunk.content.trim()) endedOnToolNoText = false;
3830
3845
  this.options.host.notify({ kind: "text_delta", message: chunk.content });
3831
3846
  }
3832
3847
  if (chunk.finishReason) finishReason = chunk.finishReason;
@@ -3834,7 +3849,7 @@ var Agent = class _Agent {
3834
3849
  if (chunk.usage) usage = chunk.usage;
3835
3850
  }
3836
3851
  const delegatedTools = delegatedOrder.map((k) => delegated.get(k));
3837
- return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {} };
3852
+ return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {}, ...endedOnToolNoText ? { endedOnToolNoText: true } : {} };
3838
3853
  }
3839
3854
  async dispatch(tc) {
3840
3855
  const tool = this.activeTools.find((t) => t.name === tc.function.name);