@livx.cc/agentx 0.99.79 → 0.99.81

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, n as RunResult, A as Agent, g as PermissionPolicy } from './Agent-BK-heHrw.js';
2
- export { C as ChatFragment, b as Classification, c as Classifier, d as CompactResult, D as DEFAULT_MUTATING, e as Decision, M as ModelRouter, f as ModelRouterOptions, P as PermissionOptions, h as PermissionRule, i as PreToolUseDecision, R as ReasoningEffort, j as RecordingHooks, k as RecordingLifecycle, l as RouteDecision, m as RouterState, T as Tier, o as ToolUse, p as ToolUseMeta, q as claudeCodeDisallowedTools, r as composeHooks, s as estimateTokens, t as jevAvailable, u as jevClassifier, v as pickTier, w as planMode, x as reasoningToChatFragment } from './Agent-BK-heHrw.js';
1
+ import { a as AgentOptions, H as Hooks, n as RunResult, A as Agent, g as PermissionPolicy } from './Agent-RHsiEAiP.js';
2
+ export { C as ChatFragment, b as Classification, c as Classifier, d as CompactResult, D as DEFAULT_MUTATING, e as Decision, M as ModelRouter, f as ModelRouterOptions, P as PermissionOptions, h as PermissionRule, i as PreToolUseDecision, R as ReasoningEffort, j as RecordingHooks, k as RecordingLifecycle, l as RouteDecision, m as RouterState, T as Tier, o as ToolUse, p as ToolUseMeta, q as claudeCodeDisallowedTools, r as composeHooks, s as estimateTokens, t as jevAvailable, u as jevClassifier, v as pickTier, w as planMode, x as reasoningToChatFragment } from './Agent-RHsiEAiP.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
@@ -5057,10 +5057,11 @@ var Agent = class _Agent {
5057
5057
  * retained window → halve the window → drop-oldest backstop. Deterministic, no LLM call.
5058
5058
  * `focus` (e.g. `/compact keep the API details`) preserves matching lines from the dropped span verbatim.
5059
5059
  * Returns before/after token estimates so the caller can report honestly (0 freed => say so).
5060
+ * `target` (tokens): a tighter budget than half the window — a host compacting at its own threshold.
5060
5061
  */
5061
- compactNow(maxMessages = 12, focus) {
5062
+ compactNow(maxMessages = 12, focus, target) {
5062
5063
  const cap = _Agent.contextCap(this.options);
5063
- const target = Math.round(cap * _Agent.COMPACT_TARGET);
5064
+ target = Math.min(Math.round(cap * _Agent.COMPACT_TARGET), target || Infinity);
5064
5065
  const kr = this.options.keepRecentImages ?? 1;
5065
5066
  const vis = this.sendsImages();
5066
5067
  const tokensBefore = estimateTokens(this.transcript, kr, vis);
@@ -5268,6 +5269,8 @@ var Agent = class _Agent {
5268
5269
  usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
5269
5270
  usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
5270
5271
  const prompt = res.usage.promptTokens ?? 0, cacheRead = res.usage.cacheReadTokens ?? 0;
5272
+ usage.contextTokens = res.usage.contextTokens ?? prompt;
5273
+ usage.contextWindow = res.usage.contextWindow || _Agent.contextCap(o);
5271
5274
  if (prevPrompt < 0) {
5272
5275
  const u = sent.map((m) => m.role).lastIndexOf("user");
5273
5276
  prevPrompt = u > 0 ? estimateTokens(sent.slice(0, u)) : 0;