惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
博客园 - 聂微东
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
D
Docker
B
Blog
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Y
Y Combinator Blog
N
Netflix TechBlog - Medium
月光博客
月光博客
F
Fortinet All Blogs
爱范儿
爱范儿
H
Help Net Security
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
The Cloudflare Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
U
Unit 42

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat(deepseek): show provider balance in usage status · o...
litang9 · 2026-06-01 · via Recent Commits to openclaw:main
11

import { beforeEach, describe, expect, it, vi } from "vitest";

22

import type { AuthHealthSummary } from "../../agents/auth-health.js";

33

import type { AuthProfileStore } from "../../agents/auth-profiles.js";

4+

import type { UsageSummary } from "../../infra/provider-usage.types.js";

45

import { MAX_DATE_TIMESTAMP_MS } from "../../shared/number-coercion.js";

56

import type { GatewayRequestHandlerOptions } from "./types.js";

678+

const emptyUsageSummary = (): UsageSummary => ({ updatedAt: 0, providers: [] });

9+710

const mocks = vi.hoisted(() => ({

811

getRuntimeConfig: vi.fn(() => ({})),

912

resolveDefaultAgentDir: vi.fn(() => "/tmp/agent"),

@@ -29,7 +32,7 @@ const mocks = vi.hoisted(() => ({

2932

buildAuthHealthSummary: vi.fn(

3033

(): AuthHealthSummary => ({ now: 0, warnAfterMs: 0, profiles: [], providers: [] }),

3134

),

32-

loadProviderUsageSummary: vi.fn(async () => ({ updatedAt: 0, providers: [] })),

35+

loadProviderUsageSummary: vi.fn(async (): Promise<UsageSummary> => emptyUsageSummary()),

3336

}));

34373538

vi.mock("../../config/config.js", () => ({

@@ -216,7 +219,7 @@ describe("models.authStatus", () => {

216219

profiles: [],

217220

providers: [],

218221

});

219-

mocks.loadProviderUsageSummary.mockResolvedValue({ updatedAt: 0, providers: [] });

222+

mocks.loadProviderUsageSummary.mockResolvedValue(emptyUsageSummary());

220223

});

221224222225

it("returns a serialisable snapshot on first call", async () => {

@@ -303,6 +306,65 @@ describe("models.authStatus", () => {

303306

expect(mocks.loadProviderUsageSummary).not.toHaveBeenCalled();

304307

});

305308309+

it("adds DeepSeek API-key balance summaries to auth status usage", async () => {

310+

mocks.buildAuthHealthSummary.mockReturnValue({

311+

now: 0,

312+

warnAfterMs: 0,

313+

profiles: [

314+

{

315+

profileId: "deepseek:default",

316+

provider: "deepseek",

317+

type: "api_key",

318+

status: "static",

319+

source: "store",

320+

label: "deepseek:default",

321+

},

322+

],

323+

providers: [

324+

{

325+

provider: "deepseek",

326+

status: "static",

327+

profiles: [

328+

{

329+

profileId: "deepseek:default",

330+

provider: "deepseek",

331+

type: "api_key",

332+

status: "static",

333+

source: "store",

334+

label: "deepseek:default",

335+

},

336+

],

337+

},

338+

],

339+

});

340+

mocks.loadProviderUsageSummary.mockResolvedValue({

341+

updatedAt: 0,

342+

providers: [

343+

{

344+

provider: "deepseek",

345+

displayName: "DeepSeek",

346+

windows: [],

347+

summary: "Balance ¥42.50",

348+

},

349+

],

350+

});

351+352+

const opts = createOptions();

353+

await handler(opts);

354+355+

expect(mocks.loadProviderUsageSummary).toHaveBeenCalledWith({

356+

providers: ["deepseek"],

357+

agentDir: "/tmp/agent",

358+

timeoutMs: 3500,

359+

});

360+

const [, payload] = firstRespondCall(opts) ?? [];

361+

const result = payload as ModelAuthStatusResult;

362+

expect(result.providers[0]?.usage).toEqual({

363+

windows: [],

364+

summary: "Balance ¥42.50",

365+

});

366+

});

367+306368

it("scopes external CLI auth overlays to configured providers", async () => {

307369

mocks.getRuntimeConfig.mockReturnValue({

308370

auth: {