fix: restore status usage summary output

This commit is contained in:
Peter Steinberger
2026-01-16 02:49:10 +00:00
parent e7c16cc0e6
commit 29476b222d
6 changed files with 37 additions and 24 deletions

View File

@@ -15,6 +15,7 @@
- Docs: clarify multi-gateway rescue bot guidance. (#969) — thanks @bjesuiter.
- Agents: add Current Date & Time system prompt section with configurable time format (auto/12/24).
- Agents: avoid false positives when logging unsupported Google tool schema keywords.
- Status: restore usage summary line for current provider when no OAuth profiles exist.
- Tools: normalize Slack/Discord message timestamps with `timestampMs`/`timestampUtc` while keeping raw provider fields.
- Docs: add Date & Time guide and update prompt/timezone configuration docs.
- Messages: debounce rapid inbound messages across channels with per-connector overrides. (#971) — thanks @juanpablodlc.

View File

@@ -56,6 +56,7 @@ vi.mock("../skills.js", async (importOriginal) => {
describe("Agent-specific sandbox config", () => {
beforeEach(() => {
spawnCalls.length = 0;
vi.resetModules();
});
it("should use agent-specific workspaceRoot", async () => {

View File

@@ -15,6 +15,7 @@ import type { ClawdbotConfig } from "../../config/config.js";
import type { SessionEntry, SessionScope } from "../../config/sessions.js";
import { logVerbose } from "../../globals.js";
import {
formatUsageSummaryLine,
formatUsageWindowSummary,
loadProviderUsageSummary,
resolveUsageProviderId,
@@ -139,22 +140,34 @@ export async function buildStatusReply(params: {
(profile) => profile.type === "oauth" || profile.type === "token",
);
const usageProviders = Array.from(
new Set(
oauthProfiles
.map((profile) => resolveUsageProviderId(profile.provider))
.filter((entry): entry is UsageProviderId => Boolean(entry)),
),
);
const usageByProvider = new Map<string, string>();
if (usageProviders.length > 0) {
const usageProviders = new Set<UsageProviderId>();
for (const profile of oauthProfiles) {
const entry = resolveUsageProviderId(profile.provider);
if (entry) usageProviders.add(entry);
}
const currentUsageProvider = (() => {
try {
const usageSummary = await loadProviderUsageSummary({
return resolveUsageProviderId(provider);
} catch {
return undefined;
}
})();
if (usageProviders.size === 0 && currentUsageProvider) {
usageProviders.add(currentUsageProvider);
}
const usageByProvider = new Map<string, string>();
let usageSummaryCache:
| Awaited<ReturnType<typeof loadProviderUsageSummary>>
| null
| undefined;
if (usageProviders.size > 0) {
try {
usageSummaryCache = await loadProviderUsageSummary({
timeoutMs: 3500,
providers: usageProviders,
providers: Array.from(usageProviders),
agentDir: statusAgentDir,
});
for (const snapshot of usageSummary.providers) {
for (const snapshot of usageSummaryCache.providers) {
const formatted = formatUsageWindowSummary(snapshot, {
now: Date.now(),
maxWindows: 2,
@@ -168,10 +181,16 @@ export async function buildStatusReply(params: {
let usageLine: string | null = null;
try {
const usageProvider = resolveUsageProviderId(provider);
if (oauthProfiles.length === 0 && usageProvider) {
const usage = usageByProvider.get(usageProvider);
if (usage) usageLine = `📊 Usage: ${usage}`;
if (oauthProfiles.length === 0 && currentUsageProvider) {
const summaryLine = usageSummaryCache
? formatUsageSummaryLine(usageSummaryCache, { now: Date.now(), maxProviders: 1 })
: null;
if (summaryLine) {
usageLine = summaryLine;
} else {
const usage = usageByProvider.get(currentUsageProvider);
if (usage) usageLine = `📊 Usage: ${usage}`;
}
}
} catch {
usageLine = null;

View File

@@ -6,7 +6,6 @@ export const createTestRegistry = (overrides: Partial<PluginRegistry> = {}): Plu
tools: [],
providers: [],
channels: [],
providers: [],
gatewayHandlers: {},
httpHandlers: [],
cliRegistrars: [],

View File

@@ -191,7 +191,6 @@ function createPluginRecord(params: {
toolNames: [],
providerIds: [],
channelIds: [],
providerIds: [],
gatewayMethods: [],
cliCommands: [],
services: [],

View File

@@ -138,11 +138,6 @@ export type ClawdbotPluginChannelRegistration = {
dock?: ChannelDock;
};
export type ClawdbotPluginProviderRegistration = {
id: string;
[key: string]: unknown;
};
export type ClawdbotPluginDefinition = {
id?: string;
name?: string;
@@ -170,7 +165,6 @@ export type ClawdbotPluginApi = {
tool: AnyAgentTool | ClawdbotPluginToolFactory,
opts?: { name?: string; names?: string[] },
) => void;
registerProvider: (provider: ClawdbotPluginProviderRegistration) => void;
registerHttpHandler: (handler: ClawdbotPluginHttpHandler) => void;
registerChannel: (registration: ClawdbotPluginChannelRegistration | ChannelPlugin) => void;
registerGatewayMethod: (method: string, handler: GatewayRequestHandler) => void;