@livx.cc/agentx 0.99.125 → 0.99.127
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/cli.d.ts +1 -1
- package/dist/cli.js +25 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel-GFT69ax4.d.ts → secondChannel-CYU9qqwr.d.ts} +8 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as AgentOptions, H as Hooks, x as RunResult, k as Decider, b as Agent, q as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, y as SecondChannelOptions, S as SecondChannel } from './secondChannel-
|
|
2
|
-
export { A as ADVISE_LIMIT, a as AdvisorSetup, C as CC_WRITE_TOOLS, e as ChatFragment, f as ChatUsage, g as Classification, h as Classifier, i as CompactResult, j as ContextFileSpec, D as DEFAULT_MUTATING, l as Decision, M as ModelRouter, m as ModelRouterOptions, P as PLANNER_BLOCKED, n as PLANNER_REFUSAL, o as PLAN_FIRST, p as PermissionOptions, r as PermissionRule, s as PreToolUseDecision, R as ReasoningEffort, t as RecordingHooks, u as RecordingLifecycle, v as RouteDecision, w as RouterState, T as Tier, z as ToolUse, B as ToolUseMeta, W as WRITE_TOOLS, E as advisorFor, F as advisorPrompt, I as ccModeOptions, J as claudeCodeDisallowedTools, K as composeHooks, N as delegatePrompt, O as delegateTools, Q as delegateWorkerFor, U as estimateTokens, V as jevAvailable, X as jevClassifier, Y as loadContextFiles, Z as loadInstructions, _ as makeAdvisor, $ as meterWorkers, a0 as pickTier, a1 as planMode, a2 as plannerBlocks, a3 as reasoningToChatFragment } from './secondChannel-
|
|
1
|
+
import { c as AgentOptions, H as Hooks, x as RunResult, k as Decider, b as Agent, q as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, y as SecondChannelOptions, S as SecondChannel } from './secondChannel-CYU9qqwr.js';
|
|
2
|
+
export { A as ADVISE_LIMIT, a as AdvisorSetup, C as CC_WRITE_TOOLS, e as ChatFragment, f as ChatUsage, g as Classification, h as Classifier, i as CompactResult, j as ContextFileSpec, D as DEFAULT_MUTATING, l as Decision, M as ModelRouter, m as ModelRouterOptions, P as PLANNER_BLOCKED, n as PLANNER_REFUSAL, o as PLAN_FIRST, p as PermissionOptions, r as PermissionRule, s as PreToolUseDecision, R as ReasoningEffort, t as RecordingHooks, u as RecordingLifecycle, v as RouteDecision, w as RouterState, T as Tier, z as ToolUse, B as ToolUseMeta, W as WRITE_TOOLS, E as advisorFor, F as advisorPrompt, I as ccModeOptions, J as claudeCodeDisallowedTools, K as composeHooks, N as delegatePrompt, O as delegateTools, Q as delegateWorkerFor, U as estimateTokens, V as jevAvailable, X as jevClassifier, Y as loadContextFiles, Z as loadInstructions, _ as makeAdvisor, $ as meterWorkers, a0 as pickTier, a1 as planMode, a2 as plannerBlocks, a3 as reasoningToChatFragment } from './secondChannel-CYU9qqwr.js';
|
|
3
3
|
export { MODEL_ALIASES, ModelSwitch, ResolveModelSwitchOpts, latestClaude, 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
|
@@ -4610,10 +4610,15 @@ function delegateWorkerFor(planner, worker) {
|
|
|
4610
4610
|
function advisorFor(worker, advisor) {
|
|
4611
4611
|
return advisor && pairOk("advisor", worker, advisor) ? advisor : void 0;
|
|
4612
4612
|
}
|
|
4613
|
-
function delegateTools(tools, planner) {
|
|
4613
|
+
function delegateTools(tools, planner, plannerMay) {
|
|
4614
4614
|
return tools.map((t) => !plannerBlocks(t) ? t : {
|
|
4615
4615
|
...t,
|
|
4616
|
-
|
|
4616
|
+
// THROWN, not returned: a returned string read as a SUCCESSFUL write in every trace (isError false), so a host
|
|
4617
|
+
// counted a write that never happened (Blank prod 8834a8bd-d4b).
|
|
4618
|
+
run: async (...a) => {
|
|
4619
|
+
if (a[1]?.model === planner && !plannerMay?.(t.name, a[0])) throw new Error(PLANNER_REFUSAL);
|
|
4620
|
+
return t.run(...a);
|
|
4621
|
+
}
|
|
4617
4622
|
});
|
|
4618
4623
|
}
|
|
4619
4624
|
function delegatePrompt(worker) {
|
|
@@ -4944,7 +4949,9 @@ var AgentOptions = class {
|
|
|
4944
4949
|
subagents = false;
|
|
4945
4950
|
/** DELEGATE MODE: `model` plans, `worker` writes. The planner's Write/Edit/MultiEdit/ApplyEdits/bash/Shell are
|
|
4946
4951
|
* refused at execution; Task/TaskBatch are on (maxDepth 1, children default to `worker`) and children get the
|
|
4947
|
-
* parent's `postToolUse` too. Off when the models are equal or either is cursor/*. Wins over `advisor`.
|
|
4952
|
+
* parent's `postToolUse` too. Off when the models are equal or either is cursor/*. Wins over `advisor`.
|
|
4953
|
+
* `plannerMay(tool, args)`: a blocked call the planner may still make itself (the host's own carve-out, e.g. its
|
|
4954
|
+
* private notes) — say so in the host prompt, the planner prompt says it cannot write. */
|
|
4948
4955
|
delegate;
|
|
4949
4956
|
/** ADVISOR MODE: `model` does the work; an `Advise` tool asks `advisor.model` (≤`limit`, default 3) with only
|
|
4950
4957
|
* the request + `snapshot()` (host state, optional) + the question. The first write waits for one consult. */
|
|
@@ -5210,6 +5217,7 @@ var Agent = class _Agent {
|
|
|
5210
5217
|
return texts;
|
|
5211
5218
|
}
|
|
5212
5219
|
/** Fold any host-injected messages into the transcript as user turns. Returns true if any landed. */
|
|
5220
|
+
reopen = () => this.drainInjections();
|
|
5213
5221
|
drainInjections() {
|
|
5214
5222
|
if (!this.pendingInjections.length) return false;
|
|
5215
5223
|
for (const content of this.pendingInjections.splice(0)) this.transcript.push({ role: "user", content });
|
|
@@ -5327,7 +5335,7 @@ var Agent = class _Agent {
|
|
|
5327
5335
|
traceDir: o.traceDir,
|
|
5328
5336
|
permissions: o.permissions,
|
|
5329
5337
|
// a child obeys the parent's allow/deny rules (else Task is a one-call bypass)
|
|
5330
|
-
tools: worker ? delegateTools([...o.tools, ...this.injectedTools], o.model) : [...o.tools, ...this.injectedTools],
|
|
5338
|
+
tools: worker ? delegateTools([...o.tools, ...this.injectedTools], o.model, o.delegate?.plannerMay) : [...o.tools, ...this.injectedTools],
|
|
5331
5339
|
systemPrompt: o.systemPrompt,
|
|
5332
5340
|
// A child never resumes the parent's own claude-code session (the host's `resume` link is the parent's).
|
|
5333
5341
|
providerOptionsFor: o.providerOptionsFor ?? ((m) => modelProvider(m) === modelProvider(o.model) && o.providerOptions ? { ...o.providerOptions, resume: void 0, onClaudeCodeSession: void 0 } : void 0)
|
|
@@ -5341,7 +5349,7 @@ var Agent = class _Agent {
|
|
|
5341
5349
|
this.activeHooks = composeHooks(o.hooks, plan?.hooks, o.permissions?.hooks());
|
|
5342
5350
|
this.activeTools = [...tools, ...this.injectedTools];
|
|
5343
5351
|
if (worker) {
|
|
5344
|
-
this.activeTools = delegateTools(this.activeTools, o.model);
|
|
5352
|
+
this.activeTools = delegateTools(this.activeTools, o.model, o.delegate?.plannerMay);
|
|
5345
5353
|
systemPrompt += delegatePrompt(worker);
|
|
5346
5354
|
}
|
|
5347
5355
|
if (adv) {
|
|
@@ -5480,6 +5488,14 @@ var Agent = class _Agent {
|
|
|
5480
5488
|
};
|
|
5481
5489
|
const overBudget = () => !!o.maxTokens && spent >= o.maxTokens;
|
|
5482
5490
|
const canNudge = () => steps < o.maxSteps && !overBudget();
|
|
5491
|
+
this.reopen = () => {
|
|
5492
|
+
if (!this.pendingInjections.length) return false;
|
|
5493
|
+
if (steps >= o.maxSteps || overBudget()) {
|
|
5494
|
+
log9.warn(`answer finished with ${this.pendingInjections.length} injection(s) pending and no step/budget left \u2014 they wait for the next run`);
|
|
5495
|
+
return false;
|
|
5496
|
+
}
|
|
5497
|
+
return this.drainInjections();
|
|
5498
|
+
};
|
|
5483
5499
|
while (true) {
|
|
5484
5500
|
if (o.signal?.aborted) return kill("aborted");
|
|
5485
5501
|
if (steps >= o.maxSteps) return kill("max_steps");
|
|
@@ -5624,6 +5640,7 @@ var Agent = class _Agent {
|
|
|
5624
5640
|
usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
|
|
5625
5641
|
usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
|
|
5626
5642
|
const prompt = res.usage.promptTokens ?? 0, cacheRead = res.usage.cacheReadTokens ?? 0;
|
|
5643
|
+
const ctxTokens = res.usage.contextTokens ?? prompt;
|
|
5627
5644
|
usage.contextTokens = res.usage.contextTokens ?? prompt;
|
|
5628
5645
|
usage.contextWindow = res.usage.contextWindow || _Agent.contextCap(o);
|
|
5629
5646
|
if (prevPrompt < 0) {
|
|
@@ -5632,7 +5649,7 @@ var Agent = class _Agent {
|
|
|
5632
5649
|
}
|
|
5633
5650
|
const reused = Math.min(prompt, Math.max(cacheRead, prevPrompt));
|
|
5634
5651
|
spent += (res.usage.totalTokens ?? 0) - 0.9 * reused;
|
|
5635
|
-
prevPrompt = stepPrompt =
|
|
5652
|
+
prevPrompt = stepPrompt = ctxTokens;
|
|
5636
5653
|
}
|
|
5637
5654
|
const delegatedTools = res.delegatedTools ?? [];
|
|
5638
5655
|
if (delegatedTools.length) {
|
|
@@ -5672,7 +5689,7 @@ var Agent = class _Agent {
|
|
|
5672
5689
|
});
|
|
5673
5690
|
}
|
|
5674
5691
|
if (toolCalls.length === 0) {
|
|
5675
|
-
if (this.
|
|
5692
|
+
if (this.reopen()) continue;
|
|
5676
5693
|
if (emptyTurn && o.failEmptyTurns) {
|
|
5677
5694
|
if (!emptyNudged && canNudge()) {
|
|
5678
5695
|
emptyNudged = true;
|
|
@@ -5710,7 +5727,7 @@ var Agent = class _Agent {
|
|
|
5710
5727
|
const drained = await this.jobs.drain(o.signal);
|
|
5711
5728
|
if (o.signal?.aborted) return kill("aborted");
|
|
5712
5729
|
if (drained.length) lastProgressAt = Date.now();
|
|
5713
|
-
if (this.
|
|
5730
|
+
if (this.reopen()) continue;
|
|
5714
5731
|
this.releaseStaleImages();
|
|
5715
5732
|
await this.activeHooks?.onStop?.(res.content ?? "");
|
|
5716
5733
|
const claims = this.survivingClaims();
|