@livx.cc/agentx 0.99.42 → 0.99.44

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,5 +1,5 @@
1
- import { a as AgentOptions, H as Hooks, i as RunResult, A as Agent } from './Agent-DydgLoT-.js';
2
- export { C as ChatFragment, b as CompactResult, D as DEFAULT_MUTATING, c as Decision, P as PermissionOptions, d as PermissionPolicy, e as PermissionRule, f as PreToolUseDecision, R as ReasoningEffort, g as RecordingHooks, h as RecordingLifecycle, T as ToolUse, j as ToolUseMeta, k as composeHooks, l as estimateTokens, p as planMode, r as reasoningToChatFragment } from './Agent-DydgLoT-.js';
1
+ import { a as AgentOptions, H as Hooks, i as RunResult, A as Agent } from './Agent-f4um2q8E.js';
2
+ export { C as ChatFragment, b as CompactResult, D as DEFAULT_MUTATING, c as Decision, P as PermissionOptions, d as PermissionPolicy, e as PermissionRule, f as PreToolUseDecision, R as ReasoningEffort, g as RecordingHooks, h as RecordingLifecycle, T as ToolUse, j as ToolUseMeta, k as composeHooks, l as estimateTokens, p as planMode, r as reasoningToChatFragment } from './Agent-f4um2q8E.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';
package/dist/index.js CHANGED
@@ -3849,7 +3849,9 @@ var AgentOptions = class {
3849
3849
  /** Retry budget for an EMPTY/silent-turn (a delegated-runtime wedge: cursor's warm helper spins then
3850
3850
  * returns a content-less end, surfaced as `code:'empty'`/`code:'cursor_silent'`). Tuned WIDER than the
3851
3851
  * network-drop budget (fixed 2) because clearing a wedge needs several reap+respawn cycles — each retry
3852
- * hits a FRESH cursor session (the adapter evicts the wedged warm helper on the silent-end). Still bounded:
3852
+ * hits a FRESH cursor session (the adapter evicts the wedged warm helper on the silent-end; a stall-watchdog
3853
+ * cancel is NOT this class — it is classified `stall`, and the watchdog's coded abort reason is what tells
3854
+ * the adapter to evict on that path too). Still bounded:
3853
3855
  * after exhaustion the turn surfaces `finishReason:'empty'` (non-zero exit), never infinite, never silent.
3854
3856
  * Env: AGENTX_EMPTY_RETRIES. */
3855
3857
  emptyRetries = envInt("AGENTX_EMPTY_RETRIES", 4);
@@ -4368,6 +4370,7 @@ var Agent = class _Agent {
4368
4370
  try {
4369
4371
  const r = await o.ai.chat({ model: o.model, messages: sent, tools: sentTools, stream: true, signal: stall.signal, ...o.toolChoice ? { toolChoice: o.toolChoice } : {}, ...reasonOpts });
4370
4372
  res = await this.consumeStream(r, stall.poke);
4373
+ if (stall.stalled()) throw stall.reclassify(void 0);
4371
4374
  } catch (err) {
4372
4375
  throw stall.reclassify(err);
4373
4376
  } finally {
@@ -4402,7 +4405,7 @@ var Agent = class _Agent {
4402
4405
  if (err?.code === "budget") return kill("budget");
4403
4406
  if (err?.code === "stall") {
4404
4407
  log6.warn(`model stalled out after retries: ${err?.message ?? err}`);
4405
- return kill("timeout");
4408
+ return { ...kill("timeout"), error: err };
4406
4409
  }
4407
4410
  if (o.signal?.aborted || isAbortError(err)) return kill("aborted");
4408
4411
  if (err?.code === "empty" || err?.code === "cursor_silent") {
@@ -4550,31 +4553,30 @@ var Agent = class _Agent {
4550
4553
  if (parent?.aborted) ac.abort();
4551
4554
  else parent?.addEventListener("abort", onParentAbort, { once: true });
4552
4555
  let timer;
4556
+ const stallError = () => {
4557
+ const e = new Error(`model stalled: no stream output for ${stallMs >= 1e3 ? `${Math.round(stallMs / 1e3)}s` : `${stallMs}ms`}`);
4558
+ e.code = "stall";
4559
+ return e;
4560
+ };
4553
4561
  const poke = () => {
4554
4562
  if (!stallMs) return;
4555
4563
  if (timer) clearTimeout(timer);
4556
4564
  timer = setTimeout(() => {
4557
4565
  fired = true;
4558
- ac.abort();
4566
+ ac.abort(stallError());
4559
4567
  }, stallMs);
4560
4568
  };
4561
4569
  poke();
4570
+ const stalled = () => fired && !parent?.aborted;
4562
4571
  return {
4563
4572
  signal: ac.signal,
4564
4573
  poke,
4574
+ stalled,
4565
4575
  clear: () => {
4566
4576
  if (timer) clearTimeout(timer);
4567
4577
  parent?.removeEventListener("abort", onParentAbort);
4568
4578
  },
4569
- // Distinguish OUR abort (silent provider) from a parent/user cancel, which must stay an abort.
4570
- reclassify: (err) => {
4571
- if (fired && !parent?.aborted) {
4572
- const e = new Error(`model stalled: no stream output for ${stallMs >= 1e3 ? `${Math.round(stallMs / 1e3)}s` : `${stallMs}ms`}`);
4573
- e.code = "stall";
4574
- return e;
4575
- }
4576
- return err;
4577
- }
4579
+ reclassify: (err) => stalled() ? stallError() : err
4578
4580
  };
4579
4581
  }
4580
4582
  /** A clean-stop turn that carries no assistant text AND no tool calls (native or delegated) — a