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

推荐订阅源

雷峰网
雷峰网
B
Blog
博客园_首页
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
罗磊的独立博客
Jina AI
Jina AI
C
Check Point Blog
Martin Fowler
Martin Fowler
J
Java Code Geeks
博客园 - 司徒正美
美团技术团队
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
小众软件
小众软件

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: move model catalog normalization into core pack...
steipete · 2026-05-31 · via Recent Commits to openclaw:main

@@ -2,44 +2,66 @@ import {

22

buildModelCatalogMergeKey,

33

buildModelCatalogRef,

44

normalizeModelCatalogProviderId,

5-

} from "@openclaw/model-catalog-core/model-catalog-refs";

5+

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

66

import {

7-

MODEL_APIS,

8-

isModelThinkingFormat,

9-

type ModelApi,

10-

type ModelCompatConfig,

11-

type ModelImageInputConfig,

12-

type ModelMediaInputConfig,

13-

} from "../config/types.models.js";

14-

import { isBlockedObjectKey } from "../infra/prototype-keys.js";

15-

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

16-

import {

17-

normalizeOptionalTrimmedStringList,

18-

normalizeTrimmedStringList,

19-

} from "../shared/string-normalization.js";

20-

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

21-

import type {

22-

ModelCatalog,

23-

ModelCatalogAlias,

24-

ModelCatalogCost,

25-

ModelCatalogDiscovery,

26-

ModelCatalogInput,

27-

ModelCatalogModel,

28-

ModelCatalogProvider,

29-

ModelCatalogSource,

30-

ModelCatalogStatus,

31-

ModelCatalogSuppression,

32-

ModelCatalogTieredCost,

33-

NormalizedModelCatalogRow,

34-

} from "./types.js";

7+

MODEL_CATALOG_APIS,

8+

isModelCatalogThinkingFormat,

9+

type ModelCatalog,

10+

type ModelCatalogAlias,

11+

type ModelCatalogApi,

12+

type ModelCatalogCompatConfig,

13+

type ModelCatalogCost,

14+

type ModelCatalogDiscovery,

15+

type ModelCatalogImageInputConfig,

16+

type ModelCatalogInput,

17+

type ModelCatalogMediaInputConfig,

18+

type ModelCatalogModel,

19+

type ModelCatalogProvider,

20+

type ModelCatalogSource,

21+

type ModelCatalogStatus,

22+

type ModelCatalogSuppression,

23+

type ModelCatalogTieredCost,

24+

type NormalizedModelCatalogRow,

25+

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

35263627

const MODEL_CATALOG_INPUTS = new Set(["text", "image", "document"]);

3728

const MODEL_CATALOG_DISCOVERY_MODES = new Set(["static", "refreshable", "runtime"]);

3829

const MODEL_CATALOG_STATUSES = new Set(["available", "preview", "deprecated", "disabled"]);

39-

const MODEL_CATALOG_APIS = new Set<string>(MODEL_APIS);

30+

const MODEL_CATALOG_API_SET = new Set<string>(MODEL_CATALOG_APIS);

4031

const DEFAULT_MODEL_INPUT: ModelCatalogInput[] = ["text"];

4132

const DEFAULT_MODEL_STATUS: ModelCatalogStatus = "available";

423334+

function isRecord(value: unknown): value is Record<string, unknown> {

35+

return typeof value === "object" && value !== null && !Array.isArray(value);

36+

}

37+38+

function isBlockedObjectKey(key: string): boolean {

39+

return key === "__proto__" || key === "prototype" || key === "constructor";

40+

}

41+42+

function normalizeOptionalString(value: unknown): string | undefined {

43+

if (typeof value !== "string") {

44+

return undefined;

45+

}

46+

const trimmed = value.trim();

47+

return trimmed ? trimmed : undefined;

48+

}

49+50+

function normalizeTrimmedStringList(value: unknown): string[] {

51+

if (!Array.isArray(value)) {

52+

return [];

53+

}

54+

return value.flatMap((entry) => {

55+

const normalized = normalizeOptionalString(entry);

56+

return normalized ? [normalized] : [];

57+

});

58+

}

59+60+

function normalizeOptionalTrimmedStringList(value: unknown): string[] | undefined {

61+

const normalized = normalizeTrimmedStringList(value);

62+

return normalized.length > 0 ? normalized : undefined;

63+

}

64+4365

function normalizeSafeRecordKey(value: unknown): string {

4466

const key = normalizeOptionalString(value) ?? "";

4567

return key && !isBlockedObjectKey(key) ? key : "";

@@ -81,9 +103,9 @@ function mergeStringMaps(

81103

return { ...base, ...override };

82104

}

8310584-

function normalizeModelCatalogApi(value: unknown): ModelApi | undefined {

106+

function normalizeModelCatalogApi(value: unknown): ModelCatalogApi | undefined {

85107

const api = normalizeOptionalString(value) ?? "";

86-

return MODEL_CATALOG_APIS.has(api) ? (api as ModelApi) : undefined;

108+

return MODEL_CATALOG_API_SET.has(api) ? (api as ModelCatalogApi) : undefined;

87109

}

8811089111

function normalizeModelCatalogInputs(value: unknown): ModelCatalogInput[] | undefined {

@@ -165,7 +187,7 @@ function normalizeModelCatalogCost(value: unknown): ModelCatalogCost | undefined

165187

return Object.keys(cost).length > 0 ? cost : undefined;

166188

}

167189168-

function normalizeModelCatalogCompat(value: unknown): ModelCompatConfig | undefined {

190+

function normalizeModelCatalogCompat(value: unknown): ModelCatalogCompatConfig | undefined {

169191

if (!isRecord(value)) {

170192

return undefined;

171193

}

@@ -230,27 +252,29 @@ function normalizeModelCatalogCompat(value: unknown): ModelCompatConfig | undefi

230252

}

231253232254

const thinkingFormat = normalizeOptionalString(value.thinkingFormat) ?? "";

233-

if (isModelThinkingFormat(thinkingFormat)) {

255+

if (isModelCatalogThinkingFormat(thinkingFormat)) {

234256

compat.thinkingFormat = thinkingFormat;

235257

}

236258237-

return Object.keys(compat).length > 0 ? (compat as ModelCompatConfig) : undefined;

259+

return Object.keys(compat).length > 0 ? (compat as ModelCatalogCompatConfig) : undefined;

238260

}

239261240262

function normalizeModelCatalogStatus(value: unknown): ModelCatalogStatus | undefined {

241263

const status = normalizeOptionalString(value) ?? "";

242264

return MODEL_CATALOG_STATUSES.has(status) ? (status as ModelCatalogStatus) : undefined;

243265

}

244266245-

function normalizeModelCatalogImageTokenMode(value: unknown): ModelImageInputConfig["tokenMode"] {

267+

function normalizeModelCatalogImageTokenMode(

268+

value: unknown,

269+

): ModelCatalogImageInputConfig["tokenMode"] {

246270

const tokenMode = normalizeOptionalString(value) ?? "";

247271

if (tokenMode === "tile" || tokenMode === "detail" || tokenMode === "provider") {

248272

return tokenMode;

249273

}

250274

return undefined;

251275

}

252276253-

function normalizeModelCatalogMediaInput(value: unknown): ModelMediaInputConfig | undefined {

277+

function normalizeModelCatalogMediaInput(value: unknown): ModelCatalogMediaInputConfig | undefined {

254278

if (!isRecord(value) || !isRecord(value.image)) {

255279

return undefined;

256280

}