fix(xai): wire plugin-owned codeExecution config

This commit is contained in:
huntharo
2026-03-28 17:14:02 -04:00
committed by Peter Steinberger
parent b7ab0ddb55
commit 216796f1e3
4 changed files with 100 additions and 132 deletions

View File

@@ -399,6 +399,29 @@ describe("applyPluginAutoEnable", () => {
expect(result.changes).toContain("xai tool configured, enabled automatically.");
});
it("auto-enables xai when the plugin-owned codeExecution config is configured", () => {
const result = applyPluginAutoEnable({
config: {
plugins: {
entries: {
xai: {
config: {
codeExecution: {
enabled: true,
model: "grok-4-1-fast",
},
},
},
},
},
},
env: {},
});
expect(result.config.plugins?.entries?.xai?.enabled).toBe(true);
expect(result.changes).toContain("xai tool configured, enabled automatically.");
});
it("auto-enables minimax when minimax-portal profiles exist", () => {
const result = applyPluginAutoEnable({
config: {

View File

@@ -149,11 +149,12 @@ function hasPluginOwnedWebSearchConfig(cfg: OpenClawConfig, pluginId: string): b
}
function hasPluginOwnedToolConfig(cfg: OpenClawConfig, pluginId: string): boolean {
// x_search is now plugin-owned by xAI, but the persisted config shape still
// lives under tools.web.x_search for backward compatibility. Treat that as
// plugin configuration so tool/runtime loading can activate xAI generically.
if (pluginId === "xai") {
return isRecord(cfg.tools?.web?.x_search as Record<string, unknown> | undefined);
const pluginConfig = cfg.plugins?.entries?.xai?.config;
return Boolean(
isRecord(cfg.tools?.web?.x_search as Record<string, unknown> | undefined) ||
(isRecord(pluginConfig) && isRecord(pluginConfig.codeExecution)),
);
}
return false;
}