bfc507895b
When a user explicitly configures a model for the multimodal-looker agent (e.g. zhipuai-coding-plan/glm-5.1), treat that model as vision-capable even when its provider config does not declare modalities.input or capabilities.input.image. This unblocks vision-capable models that the provider config does not advertise. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
import type { OhMyOpenCodeConfig } from "../config";
|
|
import { setAdditionalAllowedMcpEnvVars } from "../features/claude-code-mcp-loader";
|
|
import type { ModelCacheState } from "../plugin-state";
|
|
import { log } from "../shared";
|
|
import { applyAgentConfig } from "./agent-config-handler";
|
|
import { applyCommandConfig } from "./command-config-handler";
|
|
import { applyHookConfig } from "./hook-config-handler";
|
|
import { applyMcpConfig } from "./mcp-config-handler";
|
|
import { applyProviderConfig } from "./provider-config-handler";
|
|
import { loadPluginComponents } from "./plugin-components-loader";
|
|
import { applyToolConfig } from "./tool-config-handler";
|
|
import { clearFormatterCache } from "../tools/hashline-edit/formatter-trigger"
|
|
|
|
export { resolveCategoryConfig } from "./category-config-resolver";
|
|
|
|
function collectTrustedVisionCapableModels(
|
|
pluginConfig: OhMyOpenCodeConfig,
|
|
): string[] {
|
|
const trusted: string[] = []
|
|
const multimodalLookerOverride = pluginConfig.agents?.["multimodal-looker"]
|
|
const configuredModel = multimodalLookerOverride?.model
|
|
if (typeof configuredModel === "string" && configuredModel.includes("/")) {
|
|
trusted.push(configuredModel)
|
|
}
|
|
return trusted
|
|
}
|
|
|
|
export interface ConfigHandlerDeps {
|
|
ctx: { directory: string; client?: any };
|
|
pluginConfig: OhMyOpenCodeConfig;
|
|
modelCacheState: ModelCacheState;
|
|
}
|
|
|
|
export function createConfigHandler(deps: ConfigHandlerDeps) {
|
|
const { ctx, pluginConfig, modelCacheState } = deps;
|
|
|
|
return async (config: Record<string, unknown>) => {
|
|
const formatterConfig = config.formatter;
|
|
|
|
setAdditionalAllowedMcpEnvVars(pluginConfig.mcp_env_allowlist ?? [])
|
|
applyProviderConfig({
|
|
config,
|
|
modelCacheState,
|
|
trustedVisionCapableModels: collectTrustedVisionCapableModels(pluginConfig),
|
|
});
|
|
clearFormatterCache()
|
|
|
|
const pluginComponents = await loadPluginComponents({ pluginConfig });
|
|
|
|
applyHookConfig({ pluginComponents, ctx });
|
|
|
|
const agentResult = await applyAgentConfig({
|
|
config,
|
|
pluginConfig,
|
|
ctx,
|
|
pluginComponents,
|
|
});
|
|
|
|
applyToolConfig({ config, pluginConfig, agentResult });
|
|
await applyMcpConfig({ config, pluginConfig, ctx, pluginComponents });
|
|
await applyCommandConfig({ config, pluginConfig, ctx, pluginComponents });
|
|
|
|
config.formatter = formatterConfig;
|
|
|
|
log("[config-handler] config handler applied", {
|
|
agentCount: Object.keys(agentResult).length,
|
|
commandCount: Object.keys((config.command as Record<string, unknown>) ?? {})
|
|
.length,
|
|
});
|
|
};
|
|
}
|