feat(gateway): xAI tools detection + configurable array (gateway.xaiTools) before agentCommand

Includes schema + UI updates

Signed-off-by: Clawdbot Subagent <subagent@clawdbot>
This commit is contained in:
Clawdbot Subagent 2026-01-27 00:57:47 -06:00
parent 9daa846457
commit 66fb1c899c
3 changed files with 9 additions and 0 deletions

View File

@ -208,7 +208,9 @@ const FIELD_LABELS: Record<string, string> = {
"gateway.nodes.browser.mode": "Gateway Node Browser Mode",
"gateway.nodes.browser.node": "Gateway Node Browser Pin",
"gateway.nodes.allowCommands": "Gateway Node Allowlist (Extra Commands)",
"gateway.xaiTools": "Configurable allowlist of Clawdbot tools enabled for xAI/Grok requests in OpenAI gateway (empty enables all).",
"gateway.nodes.denyCommands": "Gateway Node Denylist",
"gateway.xaiTools": "xAI Tools",
"nodeHost.browserProxy.enabled": "Node Browser Proxy Enabled",
"nodeHost.browserProxy.allowProfiles": "Node Browser Proxy Allowed Profiles",
"skills.load.watch": "Watch Skills",

View File

@ -442,6 +442,7 @@ export const ClawdbotSchema = z
})
.strict()
.optional(),
xaiTools: z.array(z.string()).optional(),
})
.strict()
.optional(),

View File

@ -16,6 +16,7 @@ import {
writeDone,
} from "./http-common.js";
import { getBearerToken, resolveAgentIdForRequest, resolveSessionKey } from "./http-utils.js";
import { loadConfig } from "../../config/config.js";
type OpenAiHttpOptions = {
auth: ResolvedGatewayAuth;
@ -184,6 +185,9 @@ export async function handleOpenAiHttpRequest(
const model = typeof payload.model === "string" ? payload.model : "clawdbot";
const user = typeof payload.user === "string" ? payload.user : undefined;
const cfg = loadConfig();
const isXaiModel = typeof model === "string" && model.startsWith("grok-");
const agentId = resolveAgentIdForRequest({ req, model });
const sessionKey = resolveOpenAiSessionKey({ req, agentId, user });
const prompt = buildAgentPrompt(payload.messages);
@ -211,6 +215,7 @@ export async function handleOpenAiHttpRequest(
deliver: false,
messageChannel: "webchat",
bestEffortDeliver: false,
clientTools: isXaiModel ? cfg.gateway?.xaiTools ?? [] : undefined,
},
defaultRuntime,
deps,
@ -318,6 +323,7 @@ export async function handleOpenAiHttpRequest(
deliver: false,
messageChannel: "webchat",
bestEffortDeliver: false,
clientTools: isXaiModel ? cfg.gateway?.xaiTools ?? [] : undefined,
},
defaultRuntime,
deps,