From 66fb1c899c2126e07f9f5a8507e55c2e35756766 Mon Sep 17 00:00:00 2001 From: Clawdbot Subagent Date: Tue, 27 Jan 2026 00:57:47 -0600 Subject: [PATCH] feat(gateway): xAI tools detection + configurable array (gateway.xaiTools) before agentCommand Includes schema + UI updates Signed-off-by: Clawdbot Subagent <subagent@clawdbot> --- src/config/schema.ts | 2 ++ src/config/zod-schema.ts | 1 + src/gateway/openai-http.ts | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/src/config/schema.ts b/src/config/schema.ts index 69846236e..6942ba653 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -208,7 +208,9 @@ const FIELD_LABELS: Record = { "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", diff --git a/src/config/zod-schema.ts b/src/config/zod-schema.ts index 3c83d2c09..2ad95dc69 100644 --- a/src/config/zod-schema.ts +++ b/src/config/zod-schema.ts @@ -442,6 +442,7 @@ export const ClawdbotSchema = z }) .strict() .optional(), + xaiTools: z.array(z.string()).optional(), }) .strict() .optional(), diff --git a/src/gateway/openai-http.ts b/src/gateway/openai-http.ts index 824e5c222..150931241 100644 --- a/src/gateway/openai-http.ts +++ b/src/gateway/openai-http.ts @@ -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,