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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
博客园 - Franky
IT之家
IT之家
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
腾讯CDC
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
博客园_首页
G
Google Developers 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
docs: document model command comments · openclaw/openclaw...
steipete · 2026-06-05 · via Recent Commits to openclaw:main

@@ -1,3 +1,4 @@

1+

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

12

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

23

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

34

import {

@@ -28,6 +29,7 @@ export const ensureFlagCompatibility = (opts: { json?: boolean; plain?: boolean

2829

}

2930

};

303132+

/** Formats token counts as compact K-suffixed labels. */

3133

export const formatTokenK = (value?: number | null) => {

3234

if (!value || !Number.isFinite(value)) {

3335

return "-";

@@ -38,6 +40,7 @@ export const formatTokenK = (value?: number | null) => {

3840

return `${Math.round(value / 1024)}k`;

3941

};

404243+

/** Formats millisecond durations for model command output. */

4144

export const formatMs = (value?: number | null) => {

4245

if (value === null || value === undefined) {

4346

return "-";

@@ -51,6 +54,7 @@ export const formatMs = (value?: number | null) => {

5154

return `${Math.round(value / 100) / 10}s`;

5255

};

535657+

/** Loads config from disk and throws a formatted error when validation fails. */

5458

export async function loadValidConfigOrThrow(): Promise<OpenClawConfig> {

5559

const snapshot = await readConfigFileSnapshot();

5660

if (!snapshot.valid) {

@@ -60,10 +64,12 @@ export async function loadValidConfigOrThrow(): Promise<OpenClawConfig> {

6064

return snapshot.runtimeConfig ?? snapshot.config;

6165

}

626667+

/** Runtime config snapshot supplied to model config mutators. */

6368

export type UpdateConfigContext = {

6469

runtimeConfig: OpenClawConfig;

6570

};

667172+

/** Reads source config, applies a mutator, and writes only the source-form config. */

6773

export async function updateConfig(

6874

mutator: (cfg: OpenClawConfig, context: UpdateConfigContext) => OpenClawConfig,

6975

): Promise<OpenClawConfig> {

@@ -74,6 +80,8 @@ export async function updateConfig(

7480

}

7581

const sourceConfig = structuredClone(snapshot.sourceConfig ?? snapshot.config);

7682

const runtimeConfig = structuredClone(snapshot.runtimeConfig ?? snapshot.config);

83+

// Mutate source config so SecretRefs and unresolved placeholders do not get

84+

// overwritten by runtime-resolved secret values.

7785

const next = mutator(sourceConfig, { runtimeConfig });

7886

await replaceConfigFile({

7987

nextConfig: next,

@@ -82,6 +90,7 @@ export async function updateConfig(

8290

return next;

8391

}

849293+

/** Resolves a CLI model reference through aliases and catalog provider aliases. */

8594

export function resolveModelTarget(params: { raw: string; cfg: OpenClawConfig }): {

8695

provider: string;

8796

model: string;

@@ -117,6 +126,7 @@ function resolveAuthoredModelAliasTarget(params: {

117126

return resolved?.alias ? resolved.ref : undefined;

118127

}

119128129+

/** Resolves model reference strings to canonical provider/model keys. */

120130

export function resolveModelKeysFromEntries(params: {

121131

cfg: OpenClawConfig;

122132

entries: readonly string[];

@@ -137,6 +147,7 @@ export function resolveModelKeysFromEntries(params: {

137147

.map((entry) => modelKey(entry.ref.provider, entry.ref.model));

138148

}

139149150+

/** Builds the configured model allowlist from agents.defaults.models keys. */

140151

export function buildAllowlistSet(cfg: OpenClawConfig): Set<string> {

141152

const allowed = new Set<string>();

142153

const models = cfg.agents?.defaults?.models ?? {};

@@ -150,6 +161,7 @@ export function buildAllowlistSet(cfg: OpenClawConfig): Set<string> {

150161

return allowed;

151162

}

152163164+

/** Validates an optional agent id against configured agents. */

153165

export function resolveKnownAgentId(params: {

154166

cfg: OpenClawConfig;

155167

rawAgentId?: string | null;

@@ -168,8 +180,10 @@ export function resolveKnownAgentId(params: {

168180

return agentId;

169181

}

170182183+

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

171184

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

172185186+

/** Upserts the canonical model entry and folds legacy key metadata into it. */

173187

export function upsertCanonicalModelConfigEntry(

174188

models: Record<string, AgentModelEntryConfig>,

175189

params: { provider: string; model: string },

@@ -196,6 +210,7 @@ export function upsertCanonicalModelConfigEntry(

196210

}

197211198212

if (legacyEntry) {

213+

// Preserve legacy per-model params while moving the entry to provider/model.

199214

models[key] = {

200215

...legacyEntry,

201216

...models[key],

@@ -213,6 +228,7 @@ export function upsertCanonicalModelConfigEntry(

213228

return key;

214229

}

215230231+

/** Merges primary/fallback patches while normalizing refs for config storage. */

216232

export function mergePrimaryFallbackConfig(

217233

existing: PrimaryFallbackConfig | undefined,

218234

patch: { primary?: string; fallbacks?: string[] },

@@ -230,6 +246,7 @@ export function mergePrimaryFallbackConfig(

230246

return next;

231247

}

232248249+

/** Applies a default text/image primary-model update and ensures the model entry exists. */

233250

export function applyDefaultModelPrimaryUpdate(params: {

234251

cfg: OpenClawConfig;

235252

resolveCfg?: OpenClawConfig;