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

推荐订阅源

腾讯CDC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
I
InfoQ
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
G
Google Developers Blog
L
LangChain Blog
博客园_首页
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
月光博客
月光博客
IT之家
IT之家
量子位
宝玉的分享
宝玉的分享
S
SegmentFault 最新的问题
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网

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
test: tighten bedrock mantle discovery assertions · openc...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -17,6 +17,29 @@ function createTokenProviderFactory(tokenProvider: () => Promise<string>) {

1717

return vi.fn(() => tokenProvider);

1818

}

191920+

type MockWithCalls = {

21+

mock: { calls: unknown[][] };

22+

};

23+24+

function objectArgAt(

25+

mock: MockWithCalls,

26+

callIndex: number,

27+

argIndex: number,

28+

): Record<string, unknown> {

29+

const value = mock.mock.calls[callIndex]?.[argIndex];

30+

if (value === undefined || value === null || typeof value !== "object" || Array.isArray(value)) {

31+

throw new Error(`expected call ${callIndex} argument ${argIndex} to be an object`);

32+

}

33+

return value as Record<string, unknown>;

34+

}

35+36+

function recordField(value: unknown, field: string): Record<string, unknown> {

37+

if (value === undefined || value === null || typeof value !== "object" || Array.isArray(value)) {

38+

throw new Error(`expected ${field} to be an object`);

39+

}

40+

return value as Record<string, unknown>;

41+

}

42+2043

describe("bedrock mantle discovery", () => {

2144

const originalEnv = process.env;

2245

@@ -212,29 +235,19 @@ describe("bedrock mantle discovery", () => {

212235213236

expect(models).toHaveLength(3);

214237

// Models should be sorted alphabetically by id

215-

expect(models[0]).toMatchObject({

216-

id: "anthropic.claude-sonnet-4-6",

217-

name: "anthropic.claude-sonnet-4-6",

218-

reasoning: false,

219-

input: ["text"],

220-

});

221-

expect(models[1]).toMatchObject({

222-

id: "mistral.devstral-2-123b",

223-

reasoning: false,

224-

});

225-

expect(models[2]).toMatchObject({

226-

id: "openai.gpt-oss-120b",

227-

reasoning: true, // GPT-OSS 120B supports reasoning

228-

});

238+

expect(models[0]?.id).toBe("anthropic.claude-sonnet-4-6");

239+

expect(models[0]?.name).toBe("anthropic.claude-sonnet-4-6");

240+

expect(models[0]?.reasoning).toBe(false);

241+

expect(models[0]?.input).toEqual(["text"]);

242+

expect(models[1]?.id).toBe("mistral.devstral-2-123b");

243+

expect(models[1]?.reasoning).toBe(false);

244+

expect(models[2]?.id).toBe("openai.gpt-oss-120b");

245+

expect(models[2]?.reasoning).toBe(true); // GPT-OSS 120B supports reasoning

229246230247

// Verify correct endpoint and auth header

231-

expect(mockFetch).toHaveBeenCalledWith(

232-

"https://bedrock-mantle.us-east-1.api.aws/v1/models",

233-

expect.objectContaining({

234-

headers: expect.objectContaining({

235-

Authorization: "Bearer test-token",

236-

}),

237-

}),

248+

expect(mockFetch.mock.calls[0]?.[0]).toBe("https://bedrock-mantle.us-east-1.api.aws/v1/models");

249+

expect(recordField(objectArgAt(mockFetch, 0, 1).headers, "headers").Authorization).toBe(

250+

"Bearer test-token",

238251

);

239252

});

240253

@@ -414,22 +427,15 @@ describe("bedrock mantle discovery", () => {

414427

fetchFn: mockFetch as unknown as typeof fetch,

415428

});

416429417-

expect(provider).toMatchObject({

418-

baseUrl: "https://bedrock-mantle.us-east-1.api.aws/v1",

419-

api: "openai-completions",

420-

auth: "api-key",

421-

apiKey: "env:AWS_BEARER_TOKEN_BEDROCK",

422-

});

430+

expect(provider?.baseUrl).toBe("https://bedrock-mantle.us-east-1.api.aws/v1");

431+

expect(provider?.api).toBe("openai-completions");

432+

expect(provider?.auth).toBe("api-key");

433+

expect(provider?.apiKey).toBe("env:AWS_BEARER_TOKEN_BEDROCK");

423434

expect(provider?.models).toHaveLength(2);

424-

expect(

425-

provider?.models?.find((model) => model.id === "anthropic.claude-opus-4-7"),

426-

).toMatchObject({

427-

api: "anthropic-messages",

428-

reasoning: false,

429-

});

430-

expect(

431-

provider?.models?.find((model) => model.id === "anthropic.claude-opus-4-7"),

432-

).not.toHaveProperty("baseUrl");

435+

const opus = provider?.models?.find((model) => model.id === "anthropic.claude-opus-4-7");

436+

expect(opus?.api).toBe("anthropic-messages");

437+

expect(opus?.reasoning).toBe(false);

438+

expect(opus).not.toHaveProperty("baseUrl");

433439

});

434440435441

it("returns null when no auth is available", async () => {

@@ -464,15 +470,11 @@ describe("bedrock mantle discovery", () => {

464470

tokenProviderFactory,

465471

});

466472467-

expect(provider).toMatchObject({ apiKey: MANTLE_IAM_TOKEN_MARKER });

473+

expect(provider?.apiKey).toBe(MANTLE_IAM_TOKEN_MARKER);

468474

expect(tokenProvider).toHaveBeenCalledTimes(1);

469-

expect(mockFetch).toHaveBeenCalledWith(

470-

"https://bedrock-mantle.us-east-1.api.aws/v1/models",

471-

expect.objectContaining({

472-

headers: expect.objectContaining({

473-

Authorization: "Bearer bedrock-api-key-iam",

474-

}),

475-

}),

475+

expect(mockFetch.mock.calls[0]?.[0]).toBe("https://bedrock-mantle.us-east-1.api.aws/v1/models");

476+

expect(recordField(objectArgAt(mockFetch, 0, 1).headers, "headers").Authorization).toBe(

477+

"Bearer bedrock-api-key-iam",

476478

);

477479

});

478480

@@ -486,39 +488,33 @@ describe("bedrock mantle discovery", () => {

486488

tokenProviderFactory,

487489

});

488490489-

await expect(

490-

resolveMantleRuntimeBearerToken({

491-

apiKey: MANTLE_IAM_TOKEN_MARKER,

492-

env: {

493-

AWS_REGION: "us-east-1",

494-

} as NodeJS.ProcessEnv,

495-

now: () => 2000,

496-

tokenProviderFactory,

497-

}),

498-

).resolves.toMatchObject({

499-

apiKey: "bedrock-api-key-runtime",

500-

expiresAt: 1000 + 7200_000,

491+

const resolved = await resolveMantleRuntimeBearerToken({

492+

apiKey: MANTLE_IAM_TOKEN_MARKER,

493+

env: {

494+

AWS_REGION: "us-east-1",

495+

} as NodeJS.ProcessEnv,

496+

now: () => 2000,

497+

tokenProviderFactory,

501498

});

499+

expect(resolved?.apiKey).toBe("bedrock-api-key-runtime");

500+

expect(resolved?.expiresAt).toBe(1000 + 7200_000);

502501

expect(tokenProvider).toHaveBeenCalledTimes(1);

503502

});

504503505504

it("generates a fresh Mantle runtime IAM token when the cache is cold", async () => {

506505

const tokenProvider = vi.fn(async () => "bedrock-api-key-fresh"); // pragma: allowlist secret

507506

const tokenProviderFactory = createTokenProviderFactory(tokenProvider);

508507509-

await expect(

510-

resolveMantleRuntimeBearerToken({

511-

apiKey: MANTLE_IAM_TOKEN_MARKER,

512-

env: {

513-

AWS_REGION: "us-east-1",

514-

} as NodeJS.ProcessEnv,

515-

now: () => 5000,

516-

tokenProviderFactory,

517-

}),

518-

).resolves.toMatchObject({

519-

apiKey: "bedrock-api-key-fresh",

520-

expiresAt: 5000 + 7200_000,

508+

const resolved = await resolveMantleRuntimeBearerToken({

509+

apiKey: MANTLE_IAM_TOKEN_MARKER,

510+

env: {

511+

AWS_REGION: "us-east-1",

512+

} as NodeJS.ProcessEnv,

513+

now: () => 5000,

514+

tokenProviderFactory,

521515

});

516+

expect(resolved?.apiKey).toBe("bedrock-api-key-fresh");

517+

expect(resolved?.expiresAt).toBe(5000 + 7200_000);

522518

expect(tokenProvider).toHaveBeenCalledTimes(1);

523519

});

524520

@@ -547,10 +543,8 @@ describe("bedrock mantle discovery", () => {

547543

});

548544549545

expect(provider?.baseUrl).toBe("https://bedrock-mantle.us-east-1.api.aws/v1");

550-

expect(mockFetch).toHaveBeenCalledWith(

551-

"https://bedrock-mantle.us-east-1.api.aws/v1/models",

552-

expect.anything(),

553-

);

546+

expect(mockFetch.mock.calls[0]?.[0]).toBe("https://bedrock-mantle.us-east-1.api.aws/v1/models");

547+

expect(mockFetch.mock.calls[0]?.[1]).toBeDefined();

554548

});

555549556550

// ---------------------------------------------------------------------------