mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 05:00:44 +00:00
Summary:
- Roll up transcript-backed session usage across logical session lineage.
- Preserve lineage through /new and /reset rotations.
- Add Control UI usage scope controls with legacy gateway fallback.
- Refresh generated protocol and Control UI locale fallback surfaces.
Verification:
- pnpm test src/auto-reply/reply/session.test.ts ui/src/ui/controllers/usage.node.test.ts src/gateway/server-methods/usage.sessions-usage.test.ts
- pnpm protocol:check
- pnpm ui:i18n:check
- pnpm ui:build
- git diff --check
- PR CI green on 10f10850ee
Closes #50701.
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import type { SessionSystemPromptReport } from "../config/sessions/types.js";
|
|
import type {
|
|
CostUsageSummary,
|
|
SessionCostSummary,
|
|
SessionDailyLatency,
|
|
SessionDailyModelUsage,
|
|
SessionLatencyStats,
|
|
SessionMessageCounts,
|
|
SessionModelUsage,
|
|
SessionToolUsage,
|
|
} from "../infra/session-cost-usage.js";
|
|
|
|
export type SessionUsageEntry = {
|
|
key: string;
|
|
label?: string;
|
|
sessionId?: string;
|
|
scope?: "instance" | "family";
|
|
sessionFamilyKey?: string;
|
|
currentSessionId?: string;
|
|
includedSessionIds?: string[];
|
|
historicalInstanceCount?: number;
|
|
updatedAt?: number;
|
|
agentId?: string;
|
|
channel?: string;
|
|
chatType?: string;
|
|
origin?: {
|
|
label?: string;
|
|
provider?: string;
|
|
surface?: string;
|
|
chatType?: string;
|
|
from?: string;
|
|
to?: string;
|
|
accountId?: string;
|
|
threadId?: string | number;
|
|
};
|
|
modelOverride?: string;
|
|
providerOverride?: string;
|
|
modelProvider?: string;
|
|
model?: string;
|
|
usage: SessionCostSummary | null;
|
|
contextWeight?: SessionSystemPromptReport | null;
|
|
};
|
|
|
|
export type SessionsUsageAggregates = {
|
|
messages: SessionMessageCounts;
|
|
tools: SessionToolUsage;
|
|
byModel: SessionModelUsage[];
|
|
byProvider: SessionModelUsage[];
|
|
byAgent: Array<{ agentId: string; totals: CostUsageSummary["totals"] }>;
|
|
byChannel: Array<{ channel: string; totals: CostUsageSummary["totals"] }>;
|
|
latency?: SessionLatencyStats;
|
|
dailyLatency?: SessionDailyLatency[];
|
|
modelDaily?: SessionDailyModelUsage[];
|
|
daily: Array<{
|
|
date: string;
|
|
tokens: number;
|
|
cost: number;
|
|
messages: number;
|
|
toolCalls: number;
|
|
errors: number;
|
|
}>;
|
|
};
|
|
|
|
export type SessionsUsageResult = {
|
|
updatedAt: number;
|
|
startDate: string;
|
|
endDate: string;
|
|
sessions: SessionUsageEntry[];
|
|
totals: CostUsageSummary["totals"];
|
|
aggregates: SessionsUsageAggregates;
|
|
cacheStatus?: CostUsageSummary["cacheStatus"];
|
|
};
|