diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c37614ea..e4f6057c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/agents/sandbox-agent-config.agent-specific-sandbox-config.should-use-agent-specific-workspaceroot.test.ts b/src/agents/sandbox-agent-config.agent-specific-sandbox-config.should-use-agent-specific-workspaceroot.test.ts index 373900d4f..ca669ec90 100644 --- a/src/agents/sandbox-agent-config.agent-specific-sandbox-config.should-use-agent-specific-workspaceroot.test.ts +++ b/src/agents/sandbox-agent-config.agent-specific-sandbox-config.should-use-agent-specific-workspaceroot.test.ts @@ -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 () => { diff --git a/src/auto-reply/reply/commands-status.ts b/src/auto-reply/reply/commands-status.ts index b746ae052..93ec426c5 100644 --- a/src/auto-reply/reply/commands-status.ts +++ b/src/auto-reply/reply/commands-status.ts @@ -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(); - if (usageProviders.length > 0) { + const usageProviders = new Set(); + 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(); + let usageSummaryCache: + | Awaited> + | 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; diff --git a/src/gateway/server/__tests__/test-utils.ts b/src/gateway/server/__tests__/test-utils.ts index 4438af804..2cb403a05 100644 --- a/src/gateway/server/__tests__/test-utils.ts +++ b/src/gateway/server/__tests__/test-utils.ts @@ -6,7 +6,6 @@ export const createTestRegistry = (overrides: Partial = {}): Plu tools: [], providers: [], channels: [], - providers: [], gatewayHandlers: {}, httpHandlers: [], cliRegistrars: [], diff --git a/src/plugins/loader.ts b/src/plugins/loader.ts index b7c9ad1e5..70e70a4f9 100644 --- a/src/plugins/loader.ts +++ b/src/plugins/loader.ts @@ -191,7 +191,6 @@ function createPluginRecord(params: { toolNames: [], providerIds: [], channelIds: [], - providerIds: [], gatewayMethods: [], cliCommands: [], services: [], diff --git a/src/plugins/types.ts b/src/plugins/types.ts index a0eb9d49c..69ccfe501 100644 --- a/src/plugins/types.ts +++ b/src/plugins/types.ts @@ -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;