oh-pi 0.1.60 → 0.1.61
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/package.json
CHANGED
|
@@ -169,16 +169,11 @@ async function runAntWave(opts: WaveOptions): Promise<"ok" | "budget"> {
|
|
|
169
169
|
const retriedTasks = new Set<string>(); // 防止重复重试
|
|
170
170
|
|
|
171
171
|
const runOne = async (): Promise<"done" | "empty" | "rate_limited" | "budget"> => {
|
|
172
|
-
// Budget
|
|
172
|
+
// Budget 刹车:预算用完就不出发(drone 免费,不检查)
|
|
173
173
|
const state = nest.getState();
|
|
174
174
|
if (state.maxCost != null && caste !== "drone") {
|
|
175
175
|
const spent = state.ants.reduce((s, a) => s + a.usage.cost, 0);
|
|
176
|
-
|
|
177
|
-
const doneAnts = state.ants.filter(a => a.status === "done" && a.usage.cost > 0);
|
|
178
|
-
const avgCost = doneAnts.length > 0
|
|
179
|
-
? doneAnts.reduce((s, a) => s + a.usage.cost, 0) / doneAnts.length
|
|
180
|
-
: 0.05;
|
|
181
|
-
if (remaining < avgCost * 1.5) return "budget";
|
|
176
|
+
if (spent >= state.maxCost) return "budget";
|
|
182
177
|
}
|
|
183
178
|
|
|
184
179
|
const task = nest.nextPendingTask(caste);
|