From 4ca87fa4b0c606eee5b247bd3f7525f23c3ea17b Mon Sep 17 00:00:00 2001 From: Josh Lehman Date: Tue, 17 Mar 2026 22:14:56 -0700 Subject: [PATCH] fix: restore main build (#49478) * Build: restore main build * Config: align model compat schema --- extensions/signal/src/accounts.ts | 2 +- extensions/xai/web-search.ts | 7 ++++--- src/config/types.models.ts | 27 ++++++++++++++++----------- src/config/zod-schema.core.ts | 23 ++++++++++++++++++++++- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/extensions/signal/src/accounts.ts b/extensions/signal/src/accounts.ts index f167654ef3f..2cc323dd33d 100644 --- a/extensions/signal/src/accounts.ts +++ b/extensions/signal/src/accounts.ts @@ -4,7 +4,7 @@ import { resolveAccountEntry, type OpenClawConfig, } from "openclaw/plugin-sdk/account-resolution"; -import type { SignalAccountConfig } from "../runtime-api.js"; +import type { SignalAccountConfig } from "../../../src/config/types.signal.js"; export type ResolvedSignalAccount = { accountId: string; diff --git a/extensions/xai/web-search.ts b/extensions/xai/web-search.ts index ec69073e359..d1e3a03eb82 100644 --- a/extensions/xai/web-search.ts +++ b/extensions/xai/web-search.ts @@ -14,6 +14,7 @@ import { wrapWebContent, writeCache, } from "openclaw/plugin-sdk/provider-web-search"; +import type { WebSearchProviderPlugin } from "../../src/plugins/types.js"; const XAI_WEB_SEARCH_ENDPOINT = "https://api.x.ai/v1/responses"; const XAI_DEFAULT_WEB_SEARCH_MODEL = "grok-4-1-fast"; @@ -200,7 +201,7 @@ async function runXaiWebSearch(params: { return payload; } -export function createXaiWebSearchProvider() { +export function createXaiWebSearchProvider(): WebSearchProviderPlugin { return { id: "grok", label: "Grok (xAI)", @@ -210,8 +211,8 @@ export function createXaiWebSearchProvider() { signupUrl: "https://console.x.ai/", docsUrl: "https://docs.openclaw.ai/tools/web", autoDetectOrder: 30, - credentialPath: "tools.web.search.grok.apiKey", - inactiveSecretPaths: ["tools.web.search.grok.apiKey"], + credentialPath: "plugins.entries.xai.config.webSearch.apiKey", + inactiveSecretPaths: ["plugins.entries.xai.config.webSearch.apiKey"], getCredentialValue: (searchConfig?: Record) => getScopedCredentialValue(searchConfig, "grok"), setCredentialValue: (searchConfigTarget: Record, value: unknown) => diff --git a/src/config/types.models.ts b/src/config/types.models.ts index 3c8c5debd6a..bc79f24943f 100644 --- a/src/config/types.models.ts +++ b/src/config/types.models.ts @@ -1,3 +1,4 @@ +import type { OpenAICompletionsCompat } from "@mariozechner/pi-ai"; import type { SecretInput } from "./types.secrets.js"; export const MODEL_APIS = [ @@ -13,21 +14,25 @@ export const MODEL_APIS = [ export type ModelApi = (typeof MODEL_APIS)[number]; -export type ModelCompatConfig = { - supportsStore?: boolean; - supportsDeveloperRole?: boolean; - supportsReasoningEffort?: boolean; - supportsUsageInStreaming?: boolean; +type SupportedOpenAICompatFields = Pick< + OpenAICompletionsCompat, + | "supportsStore" + | "supportsDeveloperRole" + | "supportsReasoningEffort" + | "supportsUsageInStreaming" + | "supportsStrictMode" + | "maxTokensField" + | "thinkingFormat" + | "requiresToolResultName" + | "requiresAssistantAfterToolResult" + | "requiresThinkingAsText" +>; + +export type ModelCompatConfig = SupportedOpenAICompatFields & { supportsTools?: boolean; - supportsStrictMode?: boolean; toolSchemaProfile?: "xai"; nativeWebSearchTool?: boolean; toolCallArgumentsEncoding?: "html-entities"; - maxTokensField?: "max_completion_tokens" | "max_tokens"; - thinkingFormat?: "openai" | "zai" | "qwen"; - requiresToolResultName?: boolean; - requiresAssistantAfterToolResult?: boolean; - requiresThinkingAsText?: boolean; requiresMistralToolIds?: boolean; requiresOpenAiAnthropicToolPayload?: boolean; }; diff --git a/src/config/zod-schema.core.ts b/src/config/zod-schema.core.ts index 199637bba52..22c589c8490 100644 --- a/src/config/zod-schema.core.ts +++ b/src/config/zod-schema.core.ts @@ -6,6 +6,7 @@ import { isValidExecSecretRefId, isValidFileSecretRefId, } from "../secrets/ref-contract.js"; +import type { ModelCompatConfig } from "./types.models.js"; import { MODEL_APIS } from "./types.models.js"; import { createAllowDenyChannelRulesSchema } from "./zod-schema.allowdeny.js"; import { sensitive } from "./zod-schema.sensitive.js"; @@ -191,16 +192,36 @@ export const ModelCompatSchema = z maxTokensField: z .union([z.literal("max_completion_tokens"), z.literal("max_tokens")]) .optional(), - thinkingFormat: z.union([z.literal("openai"), z.literal("zai"), z.literal("qwen")]).optional(), + thinkingFormat: z + .union([ + z.literal("openai"), + z.literal("zai"), + z.literal("qwen"), + z.literal("qwen-chat-template"), + ]) + .optional(), requiresToolResultName: z.boolean().optional(), requiresAssistantAfterToolResult: z.boolean().optional(), requiresThinkingAsText: z.boolean().optional(), + toolSchemaProfile: z.literal("xai").optional(), + nativeWebSearchTool: z.boolean().optional(), + toolCallArgumentsEncoding: z.literal("html-entities").optional(), requiresMistralToolIds: z.boolean().optional(), requiresOpenAiAnthropicToolPayload: z.boolean().optional(), }) .strict() .optional(); +type AssertAssignable<_T extends U, U> = true; +type _ModelCompatSchemaAssignableToType = AssertAssignable< + z.infer, + ModelCompatConfig | undefined +>; +type _ModelCompatTypeAssignableToSchema = AssertAssignable< + ModelCompatConfig | undefined, + z.infer +>; + export const ModelDefinitionSchema = z .object({ id: z.string().min(1),