Merge ce864cdb6eb79ba71a6cd29071ebb19b1f1e14f1 into 598f1826d8b2bc969aace2c6459824737667218c
This commit is contained in:
commit
3f767a8cd6
@ -316,7 +316,7 @@ export async function launchOpenClawChrome(
|
||||
args.push("about:blank");
|
||||
|
||||
return spawn(exe.path, args, {
|
||||
stdio: "pipe",
|
||||
stdio: ["ignore", "ignore", "ignore"],
|
||||
env: {
|
||||
...process.env,
|
||||
// Reduce accidental sharing with the user's env.
|
||||
|
||||
@ -769,22 +769,22 @@ export const usageHandlers: GatewayRequestHandlers = {
|
||||
.toSorted((a, b) => b.count - a.count),
|
||||
},
|
||||
byModel: Array.from(byModelMap.values()).toSorted((a, b) => {
|
||||
const costDiff = b.totals.totalCost - a.totals.totalCost;
|
||||
const costDiff = (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0);
|
||||
if (costDiff !== 0) {
|
||||
return costDiff;
|
||||
}
|
||||
return b.totals.totalTokens - a.totals.totalTokens;
|
||||
return (b.totals?.totalTokens ?? 0) - (a.totals?.totalTokens ?? 0);
|
||||
}),
|
||||
byProvider: Array.from(byProviderMap.values()).toSorted((a, b) => {
|
||||
const costDiff = b.totals.totalCost - a.totals.totalCost;
|
||||
const costDiff = (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0);
|
||||
if (costDiff !== 0) {
|
||||
return costDiff;
|
||||
}
|
||||
return b.totals.totalTokens - a.totals.totalTokens;
|
||||
return (b.totals?.totalTokens ?? 0) - (a.totals?.totalTokens ?? 0);
|
||||
}),
|
||||
byAgent: Array.from(byAgentMap.entries())
|
||||
.map(([id, totals]) => ({ agentId: id, totals }))
|
||||
.toSorted((a, b) => b.totals.totalCost - a.totals.totalCost),
|
||||
.toSorted((a, b) => (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0)),
|
||||
...tail,
|
||||
};
|
||||
|
||||
|
||||
@ -321,7 +321,7 @@ export async function recoverPendingDeliveries(opts: {
|
||||
log: RecoveryLogger;
|
||||
cfg: OpenClawConfig;
|
||||
stateDir?: string;
|
||||
/** Maximum wall-clock time for recovery in ms. Remaining entries are deferred to next restart. Default: 60 000. */
|
||||
/** Maximum wall-clock time for recovery in ms. Remaining entries are deferred to next startup. Default: 60 000. */
|
||||
maxRecoveryMs?: number;
|
||||
}): Promise<RecoverySummary> {
|
||||
const pending = await loadPendingDeliveries(opts.stateDir);
|
||||
@ -344,8 +344,7 @@ export async function recoverPendingDeliveries(opts: {
|
||||
for (const entry of pending) {
|
||||
const now = Date.now();
|
||||
if (now >= deadline) {
|
||||
const deferred = pending.length - recovered - failed - skippedMaxRetries - deferredBackoff;
|
||||
opts.log.warn(`Recovery time budget exceeded — ${deferred} entries deferred to next restart`);
|
||||
opts.log.warn(`Recovery time budget exceeded — remaining entries deferred to next startup`);
|
||||
break;
|
||||
}
|
||||
if (entry.retryCount >= MAX_RETRIES) {
|
||||
|
||||
@ -509,7 +509,7 @@ describe("delivery-queue", () => {
|
||||
expect(remaining).toHaveLength(3);
|
||||
|
||||
// Should have logged a warning about deferred entries.
|
||||
expect(log.warn).toHaveBeenCalledWith(expect.stringContaining("deferred to next restart"));
|
||||
expect(log.warn).toHaveBeenCalledWith(expect.stringContaining("deferred to next startup"));
|
||||
});
|
||||
|
||||
it("defers entries until backoff becomes eligible", async () => {
|
||||
|
||||
@ -707,11 +707,11 @@ export async function loadSessionCostSummary(params: {
|
||||
|
||||
const modelUsage = modelUsageMap.size
|
||||
? Array.from(modelUsageMap.values()).toSorted((a, b) => {
|
||||
const costDiff = b.totals.totalCost - a.totals.totalCost;
|
||||
const costDiff = (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0);
|
||||
if (costDiff !== 0) {
|
||||
return costDiff;
|
||||
}
|
||||
return b.totals.totalTokens - a.totals.totalTokens;
|
||||
return (b.totals?.totalTokens ?? 0) - (a.totals?.totalTokens ?? 0);
|
||||
})
|
||||
: undefined;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user