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

推荐订阅源

V
V2EX
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园 - 【当耐特】
月光博客
月光博客
C
Check Point Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
B
Blog
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
美团技术团队
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
L
LangChain 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
fix(ollama): support GLM-5.2 cloud discovery · openclaw/o...
steipete · 2026-06-22 · via Recent Commits to openclaw:main

@@ -41,6 +41,7 @@ import {

4141

OLLAMA_CLOUD_DEFAULT_MODELS,

4242

OLLAMA_CLOUD_PROVIDER_ID,

4343

OLLAMA_DEFAULT_BASE_URL,

44+

OLLAMA_GLM52_CLOUD_MODEL_ID,

4445

} from "./src/defaults.js";

4546

import {

4647

OLLAMA_DEFAULT_API_KEY,

@@ -79,8 +80,6 @@ const dynamicModelCache = new Map<string, ProviderRuntimeModel[]>();

7980

const OLLAMA_CLOUD_DEFAULT_MODEL_REF = `${OLLAMA_CLOUD_PROVIDER_ID}/${OLLAMA_CLOUD_DEFAULT_MODELS[0]}`;

8081

const OLLAMA_CONFIGURED_SHOW_CONCURRENCY = 4;

8182

const OLLAMA_CONFIGURED_SHOW_MAX_MODELS = 8;

82-

const OLLAMA_API_KEY_ENV_REF_RE = /^[A-Z_][A-Z0-9_]*$/u;

83-8483

function buildDynamicCacheKey(provider: string, baseUrl: string | undefined): string {

8584

return `${provider}\0${baseUrl ?? ""}`;

8685

}

@@ -182,10 +181,7 @@ function readEnvBackedOllamaApiKey(value: unknown, env: NodeJS.ProcessEnv): stri

182181

if (ref?.source === "env") {

183182

return readConcreteOllamaApiKey(env[ref.id.trim()]);

184183

}

185-

const apiKey = readConfiguredOllamaApiKey(value);

186-

return apiKey && OLLAMA_API_KEY_ENV_REF_RE.test(apiKey)

187-

? readConcreteOllamaApiKey(env[apiKey])

188-

: undefined;

184+

return undefined;

189185

}

190186191187

function isAmbientOllamaApiKeyMarker(value: string | undefined): boolean {

@@ -195,7 +191,7 @@ function isAmbientOllamaApiKeyMarker(value: string | undefined): boolean {

195191

function readUsableOllamaShowApiKey(params: {

196192

env: NodeJS.ProcessEnv;

197193

allowAmbientEnvFallback: boolean;

198-

explicitApiKey?: string;

194+

explicitApiKey?: unknown;

199195

resolved?: { apiKey?: unknown; discoveryApiKey?: unknown };

200196

}): string | undefined {

201197

const explicitEnvApiKey = readEnvBackedOllamaApiKey(params.explicitApiKey, params.env);

@@ -218,7 +214,7 @@ function readUsableOllamaShowApiKey(params: {

218214

return resolvedEnvApiKey;

219215

}

220216

const apiKey = readConcreteOllamaApiKey(params.resolved?.apiKey);

221-

if (apiKey && !OLLAMA_API_KEY_ENV_REF_RE.test(apiKey)) {

217+

if (apiKey) {

222218

return apiKey;

223219

}

224220

return params.allowAmbientEnvFallback

@@ -306,9 +302,36 @@ function buildStaticOllamaCloudProvider(): ModelProviderConfig {

306302

};

307303

}

308304309-

async function buildOllamaCloudProvider(): Promise<ModelProviderConfig> {

310-

const discovered = await buildOllamaProvider(OLLAMA_CLOUD_BASE_URL, { quiet: true });

311-

return discovered.models?.length ? discovered : buildStaticOllamaCloudProvider();

305+

async function buildOllamaCloudProvider(apiKey?: string): Promise<ModelProviderConfig> {

306+

const discovered = await buildOllamaProvider(OLLAMA_CLOUD_BASE_URL, {

307+

...(apiKey ? { apiKey } : {}),

308+

quiet: true,

309+

});

310+

if (!discovered.models?.length) {

311+

return buildStaticOllamaCloudProvider();

312+

}

313+

if (!apiKey || discovered.models.some((model) => model.id === OLLAMA_GLM52_CLOUD_MODEL_ID)) {

314+

return discovered;

315+

}

316+

const showInfo = await queryOllamaModelShowInfo(

317+

OLLAMA_CLOUD_BASE_URL,

318+

OLLAMA_GLM52_CLOUD_MODEL_ID,

319+

{ apiKey },

320+

);

321+

if (typeof showInfo.contextWindow !== "number" && (showInfo.capabilities?.length ?? 0) === 0) {

322+

return discovered;

323+

}

324+

return {

325+

...discovered,

326+

models: [

327+

...discovered.models,

328+

buildOllamaModelDefinition(

329+

OLLAMA_GLM52_CLOUD_MODEL_ID,

330+

showInfo.contextWindow,

331+

showInfo.capabilities,

332+

),

333+

],

334+

};

312335

}

313336314337

async function resolveRequestedDynamicOllamaModel(params: {

@@ -360,7 +383,7 @@ async function augmentConfiguredOllamaCatalogModels(params: {

360383

const showApiKey = readUsableOllamaShowApiKey({

361384

env: params.env,

362385

allowAmbientEnvFallback: !isLocalBaseUrl,

363-

explicitApiKey: readConfiguredOllamaApiKey(configuredProvider?.apiKey),

386+

explicitApiKey: configuredProvider?.apiKey,

364387

resolved: params.resolveProviderApiKey?.(params.provider),

365388

});

366389

if (!isLocalBaseUrl && !showApiKey) {

@@ -457,13 +480,19 @@ export default definePluginEntry({

457480

catalog: {

458481

order: "simple",

459482

run: async (ctx: ProviderCatalogContext) => {

460-

const apiKey = ctx.resolveProviderApiKey(OLLAMA_CLOUD_PROVIDER_ID).apiKey;

483+

const resolvedAuth = ctx.resolveProviderApiKey(OLLAMA_CLOUD_PROVIDER_ID);

484+

const apiKey = resolvedAuth.apiKey ?? resolvedAuth.discoveryApiKey;

461485

if (!apiKey) {

462486

return null;

463487

}

488+

const discoveryApiKey = readUsableOllamaShowApiKey({

489+

env: ctx.env,

490+

allowAmbientEnvFallback: true,

491+

resolved: resolvedAuth,

492+

});

464493

return {

465494

provider: {

466-

...(await buildOllamaCloudProvider()),

495+

...(await buildOllamaCloudProvider(discoveryApiKey)),

467496

apiKey,

468497

},

469498

};

@@ -495,6 +524,13 @@ export default definePluginEntry({

495524

resolveReasoningOutputMode: () => "native",

496525

resolveThinkingProfile: resolveOllamaThinkingProfile,

497526

wrapStreamFn: createConfiguredOllamaCompatStreamWrapper,

527+

resolveDynamicModel: ({ provider, modelId }) => {

528+

const cloudProvider = buildStaticOllamaCloudProvider();

529+

const model = cloudProvider.models?.find((entry) => entry.id === modelId);

530+

return model

531+

? toDynamicOllamaModel({ provider, providerConfig: cloudProvider, model })

532+

: undefined;

533+

},

498534

augmentModelCatalog: async (ctx) =>

499535

await augmentConfiguredOllamaCatalogModels({

500536

config: ctx.config,