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

推荐订阅源

美团技术团队
Microsoft Azure Blog
Microsoft Azure Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
Y
Y Combinator Blog
博客园_首页
有赞技术团队
有赞技术团队
博客园 - Franky
腾讯CDC
G
Google Developers Blog
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
D
Docker
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
U
Unit 42
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学

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: resolve model suppressions from manifests · opencla...
shakkernerd · 2026-04-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,117 @@

1+

import type { OpenClawConfig } from "../config/types.openclaw.js";

2+

import {

3+

buildModelCatalogMergeKey,

4+

planManifestModelCatalogSuppressions,

5+

type ManifestModelCatalogSuppressionEntry,

6+

} from "../model-catalog/index.js";

7+

import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";

8+

import { loadPluginManifestRegistryForPluginRegistry } from "./plugin-registry.js";

9+10+

type ManifestSuppressionCache = Map<string, readonly ManifestModelCatalogSuppressionEntry[]>;

11+12+

let cacheWithoutConfig = new WeakMap<NodeJS.ProcessEnv, ManifestSuppressionCache>();

13+

let cacheByConfig = new WeakMap<

14+

OpenClawConfig,

15+

WeakMap<NodeJS.ProcessEnv, ManifestSuppressionCache>

16+

>();

17+18+

function resolveSuppressionCache(params: {

19+

config?: OpenClawConfig;

20+

env: NodeJS.ProcessEnv;

21+

}): ManifestSuppressionCache {

22+

if (!params.config) {

23+

let cache = cacheWithoutConfig.get(params.env);

24+

if (!cache) {

25+

cache = new Map();

26+

cacheWithoutConfig.set(params.env, cache);

27+

}

28+

return cache;

29+

}

30+

let envCaches = cacheByConfig.get(params.config);

31+

if (!envCaches) {

32+

envCaches = new WeakMap();

33+

cacheByConfig.set(params.config, envCaches);

34+

}

35+

let cache = envCaches.get(params.env);

36+

if (!cache) {

37+

cache = new Map();

38+

envCaches.set(params.env, cache);

39+

}

40+

return cache;

41+

}

42+43+

function cacheKey(params: { workspaceDir?: string }): string {

44+

return params.workspaceDir ?? "";

45+

}

46+47+

function listManifestModelCatalogSuppressions(params: {

48+

config?: OpenClawConfig;

49+

workspaceDir?: string;

50+

env: NodeJS.ProcessEnv;

51+

}): readonly ManifestModelCatalogSuppressionEntry[] {

52+

const cache = resolveSuppressionCache({

53+

config: params.config,

54+

env: params.env,

55+

});

56+

const key = cacheKey(params);

57+

const cached = cache.get(key);

58+

if (cached) {

59+

return cached;

60+

}

61+

const registry = loadPluginManifestRegistryForPluginRegistry({

62+

config: params.config,

63+

workspaceDir: params.workspaceDir,

64+

env: params.env,

65+

});

66+

const planned = planManifestModelCatalogSuppressions({ registry });

67+

cache.set(key, planned.suppressions);

68+

return planned.suppressions;

69+

}

70+71+

function buildManifestSuppressionError(params: {

72+

provider: string;

73+

modelId: string;

74+

reason?: string;

75+

}): string {

76+

const ref = `${params.provider}/${params.modelId}`;

77+

return params.reason ? `Unknown model: ${ref}. ${params.reason}` : `Unknown model: ${ref}.`;

78+

}

79+80+

export function clearManifestModelSuppressionCacheForTest(): void {

81+

cacheWithoutConfig = new WeakMap<NodeJS.ProcessEnv, ManifestSuppressionCache>();

82+

cacheByConfig = new WeakMap<

83+

OpenClawConfig,

84+

WeakMap<NodeJS.ProcessEnv, ManifestSuppressionCache>

85+

>();

86+

}

87+88+

export function resolveManifestBuiltInModelSuppression(params: {

89+

provider?: string | null;

90+

id?: string | null;

91+

config?: OpenClawConfig;

92+

workspaceDir?: string;

93+

env?: NodeJS.ProcessEnv;

94+

}) {

95+

const provider = normalizeLowercaseStringOrEmpty(params.provider);

96+

const modelId = normalizeLowercaseStringOrEmpty(params.id);

97+

if (!provider || !modelId) {

98+

return undefined;

99+

}

100+

const mergeKey = buildModelCatalogMergeKey(provider, modelId);

101+

const suppression = listManifestModelCatalogSuppressions({

102+

config: params.config,

103+

workspaceDir: params.workspaceDir,

104+

env: params.env ?? process.env,

105+

}).find((entry) => entry.mergeKey === mergeKey);

106+

if (!suppression) {

107+

return undefined;

108+

}

109+

return {

110+

suppress: true,

111+

errorMessage: buildManifestSuppressionError({

112+

provider,

113+

modelId,

114+

reason: suppression.reason,

115+

}),

116+

};

117+

}