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

推荐订阅源

博客园 - 叶小钗
V
Visual Studio Blog
雷峰网
雷峰网
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
C
Check Point Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
V2EX
D
Docker
IT之家
IT之家
博客园 - 聂微东
腾讯CDC
U
Unit 42
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog

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
refactor(models): share auth command agent resolution · o...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

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

1010

externalCliDiscoveryForProviderAuth: vi.fn(() => ({ kind: "none" })),

1111

loadModelsConfig: vi.fn(),

1212

resolveAuthProfileDisplayLabel: vi.fn(({ profileId }: { profileId: string }) => profileId),

13-

resolveKnownAgentId: vi.fn(({ rawAgentId }: { rawAgentId?: string }) => rawAgentId ?? undefined),

13+

resolveModelsTargetAgent: vi.fn((_cfg: OpenClawConfig, rawAgentId?: string) => {

14+

const agentId = rawAgentId ?? "main";

15+

return { agentDir: `/tmp/openclaw/agents/${agentId}`, agentId };

16+

}),

1417

}));

1518
1619

vi.mock("../../agents/agent-scope.js", () => ({

@@ -30,7 +33,7 @@ vi.mock("./load-config.js", () => ({

3033

}));

3134
3235

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

33-

resolveKnownAgentId: mocks.resolveKnownAgentId,

36+

resolveModelsTargetAgent: mocks.resolveModelsTargetAgent,

3437

}));

3538
3639

function createRuntime(): OutputRuntimeEnv & { logs: string[]; jsonPayloads: unknown[] } {

@@ -59,7 +62,7 @@ describe("modelsAuthListCommand", () => {

5962

mocks.ensureAuthProfileStore.mockReset();

6063

mocks.externalCliDiscoveryForProviderAuth.mockClear();

6164

mocks.resolveAuthProfileDisplayLabel.mockClear();

62-

mocks.resolveKnownAgentId.mockClear();

65+

mocks.resolveModelsTargetAgent.mockClear();

6366

});

6467
6568

it("filters profiles by provider and redacts credential material in JSON output", async () => {

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,5 @@

11

/** Command helpers for listing saved model auth profiles. */

22

import { timestampMsToIsoString } from "@openclaw/normalization-core/number-coercion";

3-

import { resolveAgentDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";

43

import {

54

ensureAuthProfileStore,

65

externalCliDiscoveryForProviderAuth,

@@ -14,7 +13,7 @@ import { resolveProviderIdForAuth } from "../../agents/provider-auth-aliases.js"

1413

import { type RuntimeEnv, writeRuntimeJson } from "../../runtime.js";

1514

import { shortenHomePath } from "../../utils.js";

1615

import { loadModelsConfig } from "./load-config.js";

17-

import { resolveKnownAgentId } from "./shared.js";

16+

import { resolveModelsTargetAgent } from "./shared.js";

1817
1918

type AuthProfileSummary = {

2019

id: string;

@@ -48,18 +47,6 @@ function resolveProviderFilter(rawProvider: string | undefined): {

4847

};

4948

}

5049
51-

function resolveTargetAgent(

52-

cfg: Awaited<ReturnType<typeof loadModelsConfig>>,

53-

raw?: string,

54-

): {

55-

agentId: string;

56-

agentDir: string;

57-

} {

58-

const agentId = resolveKnownAgentId({ cfg, rawAgentId: raw }) ?? resolveDefaultAgentId(cfg);

59-

const agentDir = resolveAgentDir(cfg, agentId);

60-

return { agentId, agentDir };

61-

}

62-
6350

function formatTimestamp(value: number | undefined): string | undefined {

6451

return timestampMsToIsoString(value);

6552

}

@@ -115,7 +102,7 @@ export async function modelsAuthListCommand(

115102

runtime: RuntimeEnv,

116103

) {

117104

const cfg = await loadModelsConfig({ commandName: "models auth list", runtime });

118-

const { agentId, agentDir } = resolveTargetAgent(cfg, opts.agent);

105+

const { agentId, agentDir } = resolveModelsTargetAgent(cfg, opts.agent);

119106

const providerFilter = resolveProviderFilter(opts.provider);

120107

const store = ensureAuthProfileStore(

121108

agentDir,

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,5 @@

11

/** Commands for viewing and editing per-agent provider auth profile order. */

22

import { normalizeStringEntries } from "@openclaw/normalization-core/string-normalization";

3-

import { resolveAgentDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";

43

import {

54

type AuthProfileStore,

65

externalCliDiscoveryForProviderAuth,

@@ -13,19 +12,7 @@ import { formatCliCommand } from "../../cli/command-format.js";

1312

import { type RuntimeEnv, writeRuntimeJson } from "../../runtime.js";

1413

import { shortenHomePath } from "../../utils.js";

1514

import { loadModelsConfig } from "./load-config.js";

16-

import { resolveKnownAgentId } from "./shared.js";

17-
18-

function resolveTargetAgent(

19-

cfg: Awaited<ReturnType<typeof loadModelsConfig>>,

20-

raw?: string,

21-

): {

22-

agentId: string;

23-

agentDir: string;

24-

} {

25-

const agentId = resolveKnownAgentId({ cfg, rawAgentId: raw }) ?? resolveDefaultAgentId(cfg);

26-

const agentDir = resolveAgentDir(cfg, agentId);

27-

return { agentId, agentDir };

28-

}

15+

import { resolveModelsTargetAgent } from "./shared.js";

2916
3017

function describeOrder(store: AuthProfileStore, provider: string): string[] {

3118

const providerKey = normalizeProviderId(provider);

@@ -45,7 +32,7 @@ async function resolveAuthOrderContext(

4532

}

4633

const provider = normalizeProviderId(rawProvider);

4734

const cfg = await loadModelsConfig({ commandName: "models auth-order", runtime });

48-

const { agentId, agentDir } = resolveTargetAgent(cfg, opts.agent);

35+

const { agentId, agentDir } = resolveModelsTargetAgent(cfg, opts.agent);

4936

return { cfg, agentId, agentDir, provider };

5037

}

5138
Original file line numberDiff line numberDiff line change

@@ -1,5 +1,5 @@

11

/** Shared helpers for model commands that read or mutate model config. */

2-

import { listAgentIds } from "../../agents/agent-scope.js";

2+

import { resolveAgentDir, resolveDefaultAgentId, listAgentIds } from "../../agents/agent-scope.js";

33

import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js";

44

import {

55

buildModelAliasIndex,

@@ -163,6 +163,19 @@ export function resolveKnownAgentId(params: {

163163

return agentId;

164164

}

165165
166+

/** Resolves the selected model-command agent and its profile directory. */

167+

export function resolveModelsTargetAgent(

168+

cfg: OpenClawConfig,

169+

rawAgentId?: string,

170+

): {

171+

agentId: string;

172+

agentDir: string;

173+

} {

174+

const agentId = resolveKnownAgentId({ cfg, rawAgentId }) ?? resolveDefaultAgentId(cfg);

175+

const agentDir = resolveAgentDir(cfg, agentId);

176+

return { agentId, agentDir };

177+

}

178+
166179

/** Normalized primary/fallback config shape used by text and image defaults. */

167180

export type PrimaryFallbackConfig = { primary?: string; fallbacks?: string[] };

168181