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

推荐订阅源

G
Google Developers Blog
宝玉的分享
宝玉的分享
月光博客
月光博客
B
Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
博客园_首页
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
A
About on SuperTechFans
Y
Y Combinator Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
D
Docker
爱范儿
爱范儿
博客园 - 司徒正美
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net

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 pi auth json assertions · openclaw/openclaw...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -31,6 +31,37 @@ async function readAuthJson(agentDir: string) {

3131

return JSON.parse(await fs.readFile(authPath, "utf8")) as Record<string, unknown>;

3232

}

333334+

function requireAuthEntry(

35+

auth: Record<string, unknown>,

36+

provider: string,

37+

): Record<string, unknown> {

38+

const entry = auth[provider];

39+

if (!entry || typeof entry !== "object") {

40+

throw new Error(`expected auth entry ${provider}`);

41+

}

42+

return entry as Record<string, unknown>;

43+

}

44+45+

function expectApiKeyAuth(auth: Record<string, unknown>, provider: string, key: string): void {

46+

const entry = requireAuthEntry(auth, provider);

47+

expect(entry.type).toBe("api_key");

48+

expect(entry.key).toBe(key);

49+

}

50+51+

function expectOAuthAuth(

52+

auth: Record<string, unknown>,

53+

provider: string,

54+

access: string,

55+

refresh?: string,

56+

): void {

57+

const entry = requireAuthEntry(auth, provider);

58+

expect(entry.type).toBe("oauth");

59+

expect(entry.access).toBe(access);

60+

if (refresh !== undefined) {

61+

expect(entry.refresh).toBe(refresh);

62+

}

63+

}

64+3465

describe("ensurePiAuthJsonFromAuthProfiles", () => {

3566

it("writes openai-codex oauth credentials into auth.json for pi-coding-agent discovery", async () => {

3667

const agentDir = await createAgentDir();

@@ -49,11 +80,7 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

4980

expect(first.wrote).toBe(true);

50815182

const auth = await readAuthJson(agentDir);

52-

expect(auth["openai-codex"]).toMatchObject({

53-

type: "oauth",

54-

access: "access-token",

55-

refresh: "refresh-token",

56-

});

83+

expectOAuthAuth(auth, "openai-codex", "access-token", "refresh-token");

57845885

const second = await ensurePiAuthJsonFromAuthProfiles(agentDir);

5986

expect(second.wrote).toBe(false);

@@ -74,10 +101,7 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

74101

expect(result.wrote).toBe(true);

7510276103

const auth = await readAuthJson(agentDir);

77-

expect(auth["openrouter"]).toMatchObject({

78-

type: "api_key",

79-

key: "sk-or-v1-test-key",

80-

});

104+

expectApiKeyAuth(auth, "openrouter", "sk-or-v1-test-key");

81105

});

8210683107

it("writes token credentials as api_key into auth.json", async () => {

@@ -95,10 +119,7 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

95119

expect(result.wrote).toBe(true);

9612097121

const auth = await readAuthJson(agentDir);

98-

expect(auth["anthropic"]).toMatchObject({

99-

type: "api_key",

100-

key: "sk-ant-test-token",

101-

});

122+

expectApiKeyAuth(auth, "anthropic", "sk-ant-test-token");

102123

});

103124104125

it("syncs multiple providers at once", async () => {

@@ -129,9 +150,9 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

129150130151

const auth = await readAuthJson(agentDir);

131152132-

expect(auth["openrouter"]).toMatchObject({ type: "api_key", key: "sk-or-key" });

133-

expect(auth["anthropic"]).toMatchObject({ type: "api_key", key: "sk-ant-token" });

134-

expect(auth["openai-codex"]).toMatchObject({ type: "oauth", access: "access" });

153+

expectApiKeyAuth(auth, "openrouter", "sk-or-key");

154+

expectApiKeyAuth(auth, "anthropic", "sk-ant-token");

155+

expectOAuthAuth(auth, "openai-codex", "access");

135156

});

136157137158

it("skips profiles with empty keys", async () => {

@@ -180,7 +201,7 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

180201

expect(result.wrote).toBe(true);

181202182203

const auth = await readAuthJson(agentDir);

183-

expect(auth["zai"]).toMatchObject({ type: "api_key", key: "sk-zai" });

204+

expectApiKeyAuth(auth, "zai", "sk-zai");

184205

expect(auth["z.ai"]).toBeUndefined();

185206

});

186207

@@ -205,8 +226,8 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

205226

await ensurePiAuthJsonFromAuthProfiles(agentDir);

206227207228

const auth = await readAuthJson(agentDir);

208-

expect(auth["legacy-provider"]).toMatchObject({ type: "api_key", key: "legacy-key" });

209-

expect(auth["openrouter"]).toMatchObject({ type: "api_key", key: "new-key" });

229+

expectApiKeyAuth(auth, "legacy-provider", "legacy-key");

230+

expectApiKeyAuth(auth, "openrouter", "new-key");

210231

});

211232212233

it("treats malformed existing provider entries as stale and replaces them", async () => {

@@ -228,6 +249,6 @@ describe("ensurePiAuthJsonFromAuthProfiles", () => {

228249

expect(result.wrote).toBe(true);

229250230251

const auth = await readAuthJson(agentDir);

231-

expect(auth["openrouter"]).toMatchObject({ type: "api_key", key: "new-key" });

252+

expectApiKeyAuth(auth, "openrouter", "new-key");

232253

});

233254

});