mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-27 00:17:29 +00:00
fix: restore ci after dedupe refactors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getRuntimeConfigSnapshot, type OpenClawConfig } from "@openclaw/plugin-sdk/config-runtime";
|
||||
import { jsonResult, readStringParam } from "@openclaw/plugin-sdk/provider-web-search";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { jsonResult, readStringParam } from "openclaw/plugin-sdk/provider-web-search";
|
||||
import {
|
||||
buildXaiCodeExecutionPayload,
|
||||
requestXaiCodeExecution,
|
||||
@@ -9,14 +9,6 @@ import {
|
||||
} from "./src/code-execution-shared.js";
|
||||
import { isXaiToolEnabled, resolveXaiToolApiKey } from "./src/tool-auth-shared.js";
|
||||
|
||||
type _XaiPluginConfig = NonNullable<
|
||||
NonNullable<OpenClawConfig["plugins"]>["entries"]
|
||||
>["xai"] extends {
|
||||
config?: infer Config;
|
||||
}
|
||||
? Config
|
||||
: undefined;
|
||||
|
||||
type CodeExecutionConfig = {
|
||||
enabled?: boolean;
|
||||
model?: string;
|
||||
@@ -30,12 +22,19 @@ function readCodeExecutionConfigRecord(
|
||||
return config && typeof config === "object" ? (config as Record<string, unknown>) : undefined;
|
||||
}
|
||||
|
||||
function readPluginCodeExecutionConfig(cfg?: OpenClawConfig): CodeExecutionConfig | undefined {
|
||||
const entries = cfg?.plugins?.entries;
|
||||
if (!entries || typeof entries !== "object") {
|
||||
function readPluginCodeExecutionConfig(cfg?: unknown): CodeExecutionConfig | undefined {
|
||||
if (!cfg || typeof cfg !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const xaiEntry = (entries as Record<string, unknown>).xai;
|
||||
const entries = (cfg as Record<string, unknown>).plugins;
|
||||
const pluginEntries =
|
||||
entries && typeof entries === "object"
|
||||
? ((entries as Record<string, unknown>).entries as Record<string, unknown> | undefined)
|
||||
: undefined;
|
||||
if (!pluginEntries) {
|
||||
return undefined;
|
||||
}
|
||||
const xaiEntry = pluginEntries.xai;
|
||||
if (!xaiEntry || typeof xaiEntry !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
@@ -51,20 +50,20 @@ function readPluginCodeExecutionConfig(cfg?: OpenClawConfig): CodeExecutionConfi
|
||||
}
|
||||
|
||||
function resolveCodeExecutionEnabled(params: {
|
||||
sourceConfig?: OpenClawConfig;
|
||||
runtimeConfig?: OpenClawConfig;
|
||||
sourceConfig?: unknown;
|
||||
runtimeConfig?: unknown;
|
||||
config?: CodeExecutionConfig;
|
||||
}): boolean {
|
||||
return isXaiToolEnabled({
|
||||
enabled: readCodeExecutionConfigRecord(params.config)?.enabled as boolean | undefined,
|
||||
runtimeConfig: params.runtimeConfig,
|
||||
sourceConfig: params.sourceConfig,
|
||||
runtimeConfig: params.runtimeConfig as never,
|
||||
sourceConfig: params.sourceConfig as never,
|
||||
});
|
||||
}
|
||||
|
||||
export function createCodeExecutionTool(options?: {
|
||||
config?: OpenClawConfig;
|
||||
runtimeConfig?: OpenClawConfig | null;
|
||||
config?: unknown;
|
||||
runtimeConfig?: Record<string, unknown> | null;
|
||||
}) {
|
||||
const runtimeConfig = options?.runtimeConfig ?? getRuntimeConfigSnapshot();
|
||||
const codeExecutionConfig =
|
||||
@@ -93,8 +92,8 @@ export function createCodeExecutionTool(options?: {
|
||||
}),
|
||||
execute: async (_toolCallId: string, args: Record<string, unknown>) => {
|
||||
const apiKey = resolveXaiToolApiKey({
|
||||
runtimeConfig: runtimeConfig ?? undefined,
|
||||
sourceConfig: options?.config,
|
||||
runtimeConfig: (runtimeConfig ?? undefined) as never,
|
||||
sourceConfig: options?.config as never,
|
||||
});
|
||||
if (!apiKey) {
|
||||
return jsonResult({
|
||||
|
||||
Reference in New Issue
Block a user