惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
G
Google Developers Blog
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
小众软件
小众软件
月光博客
月光博客
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
P
Proofpoint News Feed
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
The Cloudflare Blog
博客园_首页
美团技术团队
大猫的无限游戏
大猫的无限游戏
B
Blog
IT之家
IT之家
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: share xai code execution tool config · openclaw...
openclaw · 2026-05-29 · via Recent Commits to openclaw:main
11

import { jsonResult, readStringParam } from "openclaw/plugin-sdk/provider-web-search";

22

import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";

3-

import { Type } from "typebox";

3+

import {

4+

buildMissingCodeExecutionApiKeyPayload,

5+

createCodeExecutionToolDefinition,

6+

} from "./code-execution-tool-shared.js";

7+

import {

8+

readCodeExecutionConfigRecord,

9+

readPluginCodeExecutionConfig,

10+

resolveCodeExecutionEnabled,

11+

} from "./src/code-execution-config.js";

412

import {

513

buildXaiCodeExecutionPayload,

614

requestXaiCodeExecution,

715

resolveXaiCodeExecutionMaxTurns,

816

resolveXaiCodeExecutionModel,

917

} from "./src/code-execution-shared.js";

10-

import {

11-

isXaiToolEnabled,

12-

resolveXaiToolApiKeyWithAuth,

13-

type XaiToolAuthContext,

14-

} from "./src/tool-auth-shared.js";

15-16-

type CodeExecutionConfig = {

17-

enabled?: boolean;

18-

model?: string;

19-

maxTurns?: number;

20-

timeoutSeconds?: number;

21-

};

22-23-

function readCodeExecutionConfigRecord(

24-

config?: CodeExecutionConfig,

25-

): Record<string, unknown> | undefined {

26-

return config && typeof config === "object" ? (config as Record<string, unknown>) : undefined;

27-

}

28-29-

function readPluginCodeExecutionConfig(cfg?: unknown): CodeExecutionConfig | undefined {

30-

if (!cfg || typeof cfg !== "object") {

31-

return undefined;

32-

}

33-

const entries = (cfg as Record<string, unknown>).plugins;

34-

const pluginEntries =

35-

entries && typeof entries === "object"

36-

? ((entries as Record<string, unknown>).entries as Record<string, unknown> | undefined)

37-

: undefined;

38-

if (!pluginEntries) {

39-

return undefined;

40-

}

41-

const xaiEntry = pluginEntries.xai;

42-

if (!xaiEntry || typeof xaiEntry !== "object") {

43-

return undefined;

44-

}

45-

const config = (xaiEntry as Record<string, unknown>).config;

46-

if (!config || typeof config !== "object") {

47-

return undefined;

48-

}

49-

const codeExecution = (config as Record<string, unknown>).codeExecution;

50-

if (!codeExecution || typeof codeExecution !== "object") {

51-

return undefined;

52-

}

53-

return codeExecution as CodeExecutionConfig;

54-

}

55-56-

function resolveCodeExecutionEnabled(params: {

57-

sourceConfig?: unknown;

58-

runtimeConfig?: unknown;

59-

config?: CodeExecutionConfig;

60-

auth?: XaiToolAuthContext;

61-

}): boolean {

62-

return isXaiToolEnabled({

63-

enabled: readCodeExecutionConfigRecord(params.config)?.enabled as boolean | undefined,

64-

runtimeConfig: params.runtimeConfig as never,

65-

sourceConfig: params.sourceConfig as never,

66-

auth: params.auth,

67-

});

68-

}

18+

import { resolveXaiToolApiKeyWithAuth, type XaiToolAuthContext } from "./src/tool-auth-shared.js";

69197020

export function createCodeExecutionTool(options?: {

7121

config?: unknown;

@@ -87,30 +37,15 @@ export function createCodeExecutionTool(options?: {

8737

return null;

8838

}

893990-

return {

91-

label: "Code Execution",

92-

name: "code_execution",

93-

description:

94-

"Run sandboxed Python analysis with xAI. Use for calculations, tabulation, summaries, and chart-style analysis without local machine access.",

95-

parameters: Type.Object({

96-

task: Type.String({

97-

description:

98-

"The full analysis task for xAI's remote Python sandbox. Include any data to analyze directly in the task.",

99-

}),

100-

}),

101-

execute: async (_toolCallId: string, args: Record<string, unknown>) => {

40+

return createCodeExecutionToolDefinition(

41+

async (_toolCallId: string, args: Record<string, unknown>) => {

10242

const apiKey = await resolveXaiToolApiKeyWithAuth({

10343

runtimeConfig: (runtimeConfig ?? undefined) as never,

10444

sourceConfig: options?.config as never,

10545

auth: options?.auth,

10646

});

10747

if (!apiKey) {

108-

return jsonResult({

109-

error: "missing_xai_api_key",

110-

message:

111-

"code_execution needs xAI credentials. Run `openclaw onboard --auth-choice xai-oauth` to sign in with Grok, run `openclaw onboard --auth-choice xai-api-key`, set `XAI_API_KEY` in the Gateway environment, or configure `plugins.entries.xai.config.webSearch.apiKey`.",

112-

docs: "https://docs.openclaw.ai/tools/code-execution",

113-

});

48+

return jsonResult(buildMissingCodeExecutionApiKeyPayload());

11449

}

1155011651

const task = readStringParam(args, "task", { required: true });

@@ -142,5 +77,5 @@ export function createCodeExecutionTool(options?: {

14277

}),

14378

);

14479

},

145-

};

80+

);

14681

}