@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/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { w as RouterState, H as Hooks, c as AgentOptions, x as RunResult, f as ChatUsage, R as ReasoningEffort, d as ChannelMode, b as Agent } from './secondChannel-
|
|
2
|
+
import { w as RouterState, H as Hooks, c as AgentOptions, x as RunResult, f as ChatUsage, R as ReasoningEffort, d as ChannelMode, b as Agent } from './secondChannel-CYU9qqwr.js';
|
|
3
3
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
4
4
|
import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, o as MessageContent } from './tools-DwfeF8VQ.js';
|
|
5
5
|
|
package/dist/cli.js
CHANGED
|
@@ -4719,10 +4719,15 @@ function delegateWorkerFor(planner, worker) {
|
|
|
4719
4719
|
function advisorFor(worker, advisor) {
|
|
4720
4720
|
return advisor && pairOk("advisor", worker, advisor) ? advisor : void 0;
|
|
4721
4721
|
}
|
|
4722
|
-
function delegateTools(tools, planner) {
|
|
4722
|
+
function delegateTools(tools, planner, plannerMay) {
|
|
4723
4723
|
return tools.map((t) => !plannerBlocks(t) ? t : {
|
|
4724
4724
|
...t,
|
|
4725
|
-
|
|
4725
|
+
// THROWN, not returned: a returned string read as a SUCCESSFUL write in every trace (isError false), so a host
|
|
4726
|
+
// counted a write that never happened (Blank prod 8834a8bd-d4b).
|
|
4727
|
+
run: async (...a) => {
|
|
4728
|
+
if (a[1]?.model === planner && !plannerMay?.(t.name, a[0])) throw new Error(PLANNER_REFUSAL);
|
|
4729
|
+
return t.run(...a);
|
|
4730
|
+
}
|
|
4726
4731
|
});
|
|
4727
4732
|
}
|
|
4728
4733
|
function delegatePrompt(worker) {
|
|
@@ -5053,7 +5058,9 @@ var AgentOptions = class {
|
|
|
5053
5058
|
subagents = false;
|
|
5054
5059
|
/** DELEGATE MODE: `model` plans, `worker` writes. The planner's Write/Edit/MultiEdit/ApplyEdits/bash/Shell are
|
|
5055
5060
|
* refused at execution; Task/TaskBatch are on (maxDepth 1, children default to `worker`) and children get the
|
|
5056
|
-
* parent's `postToolUse` too. Off when the models are equal or either is cursor/*. Wins over `advisor`.
|
|
5061
|
+
* parent's `postToolUse` too. Off when the models are equal or either is cursor/*. Wins over `advisor`.
|
|
5062
|
+
* `plannerMay(tool, args)`: a blocked call the planner may still make itself (the host's own carve-out, e.g. its
|
|
5063
|
+
* private notes) — say so in the host prompt, the planner prompt says it cannot write. */
|
|
5057
5064
|
delegate;
|
|
5058
5065
|
/** ADVISOR MODE: `model` does the work; an `Advise` tool asks `advisor.model` (≤`limit`, default 3) with only
|
|
5059
5066
|
* the request + `snapshot()` (host state, optional) + the question. The first write waits for one consult. */
|
|
@@ -5319,6 +5326,7 @@ var Agent = class _Agent {
|
|
|
5319
5326
|
return texts;
|
|
5320
5327
|
}
|
|
5321
5328
|
/** Fold any host-injected messages into the transcript as user turns. Returns true if any landed. */
|
|
5329
|
+
reopen = () => this.drainInjections();
|
|
5322
5330
|
drainInjections() {
|
|
5323
5331
|
if (!this.pendingInjections.length) return false;
|
|
5324
5332
|
for (const content of this.pendingInjections.splice(0)) this.transcript.push({ role: "user", content });
|
|
@@ -5436,7 +5444,7 @@ var Agent = class _Agent {
|
|
|
5436
5444
|
traceDir: o.traceDir,
|
|
5437
5445
|
permissions: o.permissions,
|
|
5438
5446
|
// a child obeys the parent's allow/deny rules (else Task is a one-call bypass)
|
|
5439
|
-
tools: worker ? delegateTools([...o.tools, ...this.injectedTools], o.model) : [...o.tools, ...this.injectedTools],
|
|
5447
|
+
tools: worker ? delegateTools([...o.tools, ...this.injectedTools], o.model, o.delegate?.plannerMay) : [...o.tools, ...this.injectedTools],
|
|
5440
5448
|
systemPrompt: o.systemPrompt,
|
|
5441
5449
|
// A child never resumes the parent's own claude-code session (the host's `resume` link is the parent's).
|
|
5442
5450
|
providerOptionsFor: o.providerOptionsFor ?? ((m) => modelProvider(m) === modelProvider(o.model) && o.providerOptions ? { ...o.providerOptions, resume: void 0, onClaudeCodeSession: void 0 } : void 0)
|
|
@@ -5450,7 +5458,7 @@ var Agent = class _Agent {
|
|
|
5450
5458
|
this.activeHooks = composeHooks(o.hooks, plan?.hooks, o.permissions?.hooks());
|
|
5451
5459
|
this.activeTools = [...tools, ...this.injectedTools];
|
|
5452
5460
|
if (worker) {
|
|
5453
|
-
this.activeTools = delegateTools(this.activeTools, o.model);
|
|
5461
|
+
this.activeTools = delegateTools(this.activeTools, o.model, o.delegate?.plannerMay);
|
|
5454
5462
|
systemPrompt += delegatePrompt(worker);
|
|
5455
5463
|
}
|
|
5456
5464
|
if (adv) {
|
|
@@ -5589,6 +5597,14 @@ var Agent = class _Agent {
|
|
|
5589
5597
|
};
|
|
5590
5598
|
const overBudget = () => !!o.maxTokens && spent >= o.maxTokens;
|
|
5591
5599
|
const canNudge = () => steps < o.maxSteps && !overBudget();
|
|
5600
|
+
this.reopen = () => {
|
|
5601
|
+
if (!this.pendingInjections.length) return false;
|
|
5602
|
+
if (steps >= o.maxSteps || overBudget()) {
|
|
5603
|
+
log9.warn(`answer finished with ${this.pendingInjections.length} injection(s) pending and no step/budget left \u2014 they wait for the next run`);
|
|
5604
|
+
return false;
|
|
5605
|
+
}
|
|
5606
|
+
return this.drainInjections();
|
|
5607
|
+
};
|
|
5592
5608
|
while (true) {
|
|
5593
5609
|
if (o.signal?.aborted) return kill("aborted");
|
|
5594
5610
|
if (steps >= o.maxSteps) return kill("max_steps");
|
|
@@ -5733,6 +5749,7 @@ var Agent = class _Agent {
|
|
|
5733
5749
|
usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
|
|
5734
5750
|
usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
|
|
5735
5751
|
const prompt = res.usage.promptTokens ?? 0, cacheRead = res.usage.cacheReadTokens ?? 0;
|
|
5752
|
+
const ctxTokens = res.usage.contextTokens ?? prompt;
|
|
5736
5753
|
usage.contextTokens = res.usage.contextTokens ?? prompt;
|
|
5737
5754
|
usage.contextWindow = res.usage.contextWindow || _Agent.contextCap(o);
|
|
5738
5755
|
if (prevPrompt < 0) {
|
|
@@ -5741,7 +5758,7 @@ var Agent = class _Agent {
|
|
|
5741
5758
|
}
|
|
5742
5759
|
const reused = Math.min(prompt, Math.max(cacheRead, prevPrompt));
|
|
5743
5760
|
spent += (res.usage.totalTokens ?? 0) - 0.9 * reused;
|
|
5744
|
-
prevPrompt = stepPrompt =
|
|
5761
|
+
prevPrompt = stepPrompt = ctxTokens;
|
|
5745
5762
|
}
|
|
5746
5763
|
const delegatedTools = res.delegatedTools ?? [];
|
|
5747
5764
|
if (delegatedTools.length) {
|
|
@@ -5781,7 +5798,7 @@ var Agent = class _Agent {
|
|
|
5781
5798
|
});
|
|
5782
5799
|
}
|
|
5783
5800
|
if (toolCalls.length === 0) {
|
|
5784
|
-
if (this.
|
|
5801
|
+
if (this.reopen()) continue;
|
|
5785
5802
|
if (emptyTurn && o.failEmptyTurns) {
|
|
5786
5803
|
if (!emptyNudged && canNudge()) {
|
|
5787
5804
|
emptyNudged = true;
|
|
@@ -5819,7 +5836,7 @@ var Agent = class _Agent {
|
|
|
5819
5836
|
const drained = await this.jobs.drain(o.signal);
|
|
5820
5837
|
if (o.signal?.aborted) return kill("aborted");
|
|
5821
5838
|
if (drained.length) lastProgressAt = Date.now();
|
|
5822
|
-
if (this.
|
|
5839
|
+
if (this.reopen()) continue;
|
|
5823
5840
|
this.releaseStaleImages();
|
|
5824
5841
|
await this.activeHooks?.onStop?.(res.content ?? "");
|
|
5825
5842
|
const claims = this.survivingClaims();
|