@livx.cc/agentx 0.99.74 → 0.99.75
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/{Agent-Bs2ufrIU.d.ts → Agent-BBlKI8uD.d.ts} +7 -0
- package/dist/cli.d.ts +6 -1
- package/dist/cli.js +13 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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-
|
|
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-
|
|
1
|
+
import { a as AgentOptions, H as Hooks, n as RunResult, A as Agent, g as PermissionPolicy } from './Agent-BBlKI8uD.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-BBlKI8uD.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
|
@@ -4867,6 +4867,7 @@ var Agent = class _Agent {
|
|
|
4867
4867
|
let steps = 0;
|
|
4868
4868
|
const usage = { promptTokens: 0, completionTokens: 0, totalTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
4869
4869
|
let usageEstimated = false;
|
|
4870
|
+
let spent = 0, prevPrompt = -1, stepPrompt = 0;
|
|
4870
4871
|
const start = Date.now();
|
|
4871
4872
|
this.parkedMs = 0;
|
|
4872
4873
|
this.ctx.needsInput = void 0;
|
|
@@ -4877,12 +4878,12 @@ var Agent = class _Agent {
|
|
|
4877
4878
|
let closureNudged = false;
|
|
4878
4879
|
let lastProgressAt = start;
|
|
4879
4880
|
const kill = (finishReason) => {
|
|
4880
|
-
log8.warn(`kill-switch: ${finishReason} (steps=${steps}, tokens=${usage.totalTokens}, budgetTokens=${Math.round(
|
|
4881
|
+
log8.warn(`kill-switch: ${finishReason} (steps=${steps}, tokens=${usage.totalTokens}, budgetTokens=${Math.round(spent)}, ms=${Date.now() - start - this.parkedMs}${finishReason === "timeout" ? `, idle=${Date.now() - lastProgressAt - this.parkedMs}ms` : ""}${this.parkedMs ? ` +${this.parkedMs} parked` : ""})`);
|
|
4881
4882
|
this.jobs.killAll(`run ended: ${finishReason}`, true);
|
|
4882
4883
|
const claims = this.survivingClaims();
|
|
4883
|
-
return { text: lastAssistantText(this.transcript), steps, finishReason, messages: this.transcript, usage, usageEstimated, ...claims.length ? { fabricatedToolClaims: claims } : {} };
|
|
4884
|
+
return { text: lastAssistantText(this.transcript), steps, finishReason, messages: this.transcript, usage, usageEstimated, ...finishReason === "budget" ? { budget: { spent: Math.round(spent), limit: o.maxTokens, stepPrompt } } : {}, ...claims.length ? { fabricatedToolClaims: claims } : {} };
|
|
4884
4885
|
};
|
|
4885
|
-
const overBudget = () => !!o.maxTokens &&
|
|
4886
|
+
const overBudget = () => !!o.maxTokens && spent >= o.maxTokens;
|
|
4886
4887
|
const canNudge = () => steps < o.maxSteps && !overBudget();
|
|
4887
4888
|
while (true) {
|
|
4888
4889
|
if (o.signal?.aborted) return kill("aborted");
|
|
@@ -5036,6 +5037,14 @@ var Agent = class _Agent {
|
|
|
5036
5037
|
usage.totalTokens += res.usage.totalTokens ?? 0;
|
|
5037
5038
|
usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
|
|
5038
5039
|
usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
|
|
5040
|
+
const prompt = res.usage.promptTokens ?? 0, cacheRead = res.usage.cacheReadTokens ?? 0;
|
|
5041
|
+
if (prevPrompt < 0) {
|
|
5042
|
+
const u = sent.map((m) => m.role).lastIndexOf("user");
|
|
5043
|
+
prevPrompt = u > 0 ? estimateTokens(sent.slice(0, u)) : 0;
|
|
5044
|
+
}
|
|
5045
|
+
const reused = Math.min(prompt, Math.max(cacheRead, prevPrompt));
|
|
5046
|
+
spent += (res.usage.totalTokens ?? 0) - 0.9 * reused;
|
|
5047
|
+
prevPrompt = stepPrompt = prompt;
|
|
5039
5048
|
}
|
|
5040
5049
|
const delegatedTools = res.delegatedTools ?? [];
|
|
5041
5050
|
if (delegatedTools.length) {
|