@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.
@@ -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-hAKTlzty.js';
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-CSCWkq0C.js';
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-hAKTlzty.js';
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();
@@ -3752,6 +3758,12 @@ var Agent = class _Agent {
3752
3758
  }
3753
3759
  if (toolCalls.length === 0) {
3754
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
+ }
3755
3767
  log4.verbose(`completed in ${steps} step(s)`);
3756
3768
  await this.ctx.jobs?.drain();
3757
3769
  await this.activeHooks?.onStop?.(res.content ?? "");
@@ -3843,6 +3855,7 @@ var Agent = class _Agent {
3843
3855
  let usage;
3844
3856
  const delegated = /* @__PURE__ */ new Map();
3845
3857
  const delegatedOrder = [];
3858
+ let endedOnToolNoText = false;
3846
3859
  for await (const chunk of stream) {
3847
3860
  poke?.();
3848
3861
  if (this.options.signal?.aborted) break;
@@ -3862,9 +3875,11 @@ var Agent = class _Agent {
3862
3875
  if (a.output !== void 0) prev.output = a.output;
3863
3876
  prev.status = a.status;
3864
3877
  }
3878
+ endedOnToolNoText = true;
3865
3879
  }
3866
3880
  if (chunk.content) {
3867
3881
  content += chunk.content;
3882
+ if (chunk.content.trim()) endedOnToolNoText = false;
3868
3883
  this.options.host.notify({ kind: "text_delta", message: chunk.content });
3869
3884
  }
3870
3885
  if (chunk.finishReason) finishReason = chunk.finishReason;
@@ -3872,7 +3887,7 @@ var Agent = class _Agent {
3872
3887
  if (chunk.usage) usage = chunk.usage;
3873
3888
  }
3874
3889
  const delegatedTools = delegatedOrder.map((k) => delegated.get(k));
3875
- return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {} };
3890
+ return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {}, ...endedOnToolNoText ? { endedOnToolNoText: true } : {} };
3876
3891
  }
3877
3892
  async dispatch(tc) {
3878
3893
  const tool = this.activeTools.find((t) => t.name === tc.function.name);