@livx.cc/agentx 0.99.15 → 0.99.17

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, h as RunResult, A as Agent } from './Agent-CsVuR2O0.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-CsVuR2O0.js';
1
+ import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-BfQS-MfB.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-BfQS-MfB.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
@@ -3368,6 +3368,43 @@ var Agent = class _Agent {
3368
3368
  if (this.options.tools) this.options.tools = this.options.tools.filter((t) => !s.has(t.name));
3369
3369
  return before - this.activeTools.length;
3370
3370
  }
3371
+ /** Messages the host queued to steer the RUNNING turn (Claude-Code-style mid-turn input). The loop
3372
+ * drains them at each step boundary — after tool results are appended, before the next model call —
3373
+ * so they ride along with the latest tool results. A no-op between turns (nothing drains it). */
3374
+ pendingInjections = [];
3375
+ /** Queue a user message into the in-flight turn. It lands as a `user` message at the next step
3376
+ * boundary; if the model was about to stop, the injection re-opens the loop so it's never lost.
3377
+ * Pushing onto `transcript` directly from outside would race the loop — this drains inside it. */
3378
+ inject(content) {
3379
+ this.pendingInjections.push(content);
3380
+ }
3381
+ /** Drop any queued-but-unconsumed injections. The REPL calls this after a LOCAL command (/cmd, !bash)
3382
+ * — which runs no send() to drain them — so a mid-command steer can't leak into the next real turn. */
3383
+ clearInjections() {
3384
+ this.pendingInjections.length = 0;
3385
+ }
3386
+ /** Pull queued injections that are plain TEXT, removing them, for a runtime that can accept mid-turn
3387
+ * steers over its own channel (claude-code's warm InputQueue via `providerOptions.steer`). Non-text
3388
+ * injections (images) stay queued for the step-boundary `drainInjections()` re-open — the text-only
3389
+ * steer channel can't carry them. Consumed DURING chat(); no overlap with drainInjections() (post-call). */
3390
+ drainPendingSteers() {
3391
+ if (!this.pendingInjections.length) return [];
3392
+ const texts = [];
3393
+ this.pendingInjections = this.pendingInjections.filter((c) => {
3394
+ if (typeof c === "string") {
3395
+ texts.push(c);
3396
+ return false;
3397
+ }
3398
+ return true;
3399
+ });
3400
+ return texts;
3401
+ }
3402
+ /** Fold any host-injected messages into the transcript as user turns. Returns true if any landed. */
3403
+ drainInjections() {
3404
+ if (!this.pendingInjections.length) return false;
3405
+ for (const content of this.pendingInjections.splice(0)) this.transcript.push({ role: "user", content });
3406
+ return true;
3407
+ }
3371
3408
  constructor(options) {
3372
3409
  this.options = { ...new AgentOptions(), ...options };
3373
3410
  if (this.options.fs) this.buildCtx();
@@ -3566,10 +3603,11 @@ var Agent = class _Agent {
3566
3603
  return typeof raw === "string" ? raw : raw.text;
3567
3604
  }
3568
3605
  } : void 0;
3606
+ const claudeSteerPo = o.model.startsWith("claude-code/") ? { steer: () => this.drainPendingSteers() } : void 0;
3569
3607
  const reasonOpts = {
3570
3608
  ...frag,
3571
3609
  ...o.promptCache ? { promptCache: true } : {},
3572
- ...o.providerOptions || cursorPo ? { providerOptions: { ...frag.providerOptions, ...o.providerOptions, ...cursorPo } } : {}
3610
+ ...o.providerOptions || cursorPo || claudeSteerPo ? { providerOptions: { ...frag.providerOptions, ...o.providerOptions, ...cursorPo, ...claudeSteerPo } } : {}
3573
3611
  };
3574
3612
  try {
3575
3613
  for (let attempt = 0; ; attempt++) {
@@ -3633,6 +3671,7 @@ var Agent = class _Agent {
3633
3671
  });
3634
3672
  }
3635
3673
  if (toolCalls.length === 0) {
3674
+ if (this.drainInjections()) continue;
3636
3675
  log4.verbose(`completed in ${steps} step(s)`);
3637
3676
  await this.ctx.jobs?.drain();
3638
3677
  await this.activeHooks?.onStop?.(res.content ?? "");
@@ -3657,6 +3696,7 @@ var Agent = class _Agent {
3657
3696
  }
3658
3697
  this.transcript.push({ role: "tool", tool_call_id: tc.id, name: tc.function.name, content });
3659
3698
  }
3699
+ this.drainInjections();
3660
3700
  }
3661
3701
  }
3662
3702
  /**