From 98fb58e3189d5ed5491863e166759d9927603647 Mon Sep 17 00:00:00 2001 From: Cheese Date: Wed, 28 Jan 2026 11:34:52 +0800 Subject: [PATCH] fix: adapt tidb tool to moltbot tools --- ...tidb.test.ts => moltbot-tools.tidb.test.ts} | 18 +++++++++--------- src/agents/tools/tidb-tool.ts | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) rename src/agents/{clawdbot-tools.tidb.test.ts => moltbot-tools.tidb.test.ts} (64%) diff --git a/src/agents/clawdbot-tools.tidb.test.ts b/src/agents/moltbot-tools.tidb.test.ts similarity index 64% rename from src/agents/clawdbot-tools.tidb.test.ts rename to src/agents/moltbot-tools.tidb.test.ts index 156b6870e..8ec7eeefe 100644 --- a/src/agents/clawdbot-tools.tidb.test.ts +++ b/src/agents/moltbot-tools.tidb.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from "vitest"; -import type { ClawdbotConfig } from "../config/config.js"; -import { createClawdbotTools } from "./clawdbot-tools.js"; +import type { MoltbotConfig } from "../config/config.js"; +import { createMoltbotTools } from "./moltbot-tools.js"; -describe("createClawdbotTools (tidb)", () => { +describe("createMoltbotTools (tidb)", () => { it("omits tidb tool when disabled", () => { - const cfg: ClawdbotConfig = { + const cfg: MoltbotConfig = { tools: { tidb: { enabled: false, @@ -13,12 +13,12 @@ describe("createClawdbotTools (tidb)", () => { }, }, }; - const tools = createClawdbotTools({ config: cfg }); + const tools = createMoltbotTools({ config: cfg }); expect(tools.some((tool) => tool.name === "tidb")).toBe(false); }); it("adds tidb tool when enabled + configured", () => { - const cfg: ClawdbotConfig = { + const cfg: MoltbotConfig = { tools: { tidb: { enabled: true, @@ -26,19 +26,19 @@ describe("createClawdbotTools (tidb)", () => { }, }, }; - const tools = createClawdbotTools({ config: cfg }); + const tools = createMoltbotTools({ config: cfg }); expect(tools.some((tool) => tool.name === "tidb")).toBe(true); }); it("adds tidb tool when enabled (even if url is missing)", () => { - const cfg: ClawdbotConfig = { + const cfg: MoltbotConfig = { tools: { tidb: { enabled: true, }, }, }; - const tools = createClawdbotTools({ config: cfg }); + const tools = createMoltbotTools({ config: cfg }); expect(tools.some((tool) => tool.name === "tidb")).toBe(true); }); }); diff --git a/src/agents/tools/tidb-tool.ts b/src/agents/tools/tidb-tool.ts index 742e2df8b..5cfa91e9e 100644 --- a/src/agents/tools/tidb-tool.ts +++ b/src/agents/tools/tidb-tool.ts @@ -2,7 +2,7 @@ import { spawn } from "node:child_process"; import { Type } from "@sinclair/typebox"; -import type { ClawdbotConfig } from "../../config/config.js"; +import type { MoltbotConfig } from "../../config/config.js"; import { sanitizeBinaryOutput } from "../shell-utils.js"; import { optionalStringEnum } from "../schema/typebox.js"; import type { AnyAgentTool } from "./common.js"; @@ -197,9 +197,9 @@ function parseTsvToRows(stdout: string): { return { columns, rows }; } -type TiDbToolConfig = NonNullable["tidb"]; +type TiDbToolConfig = NonNullable["tidb"]; -function resolveTiDbToolConfig(cfg?: ClawdbotConfig): TiDbToolConfig | undefined { +function resolveTiDbToolConfig(cfg?: MoltbotConfig): TiDbToolConfig | undefined { const tidb = cfg?.tools?.tidb; if (!tidb || typeof tidb !== "object") return undefined; return tidb as TiDbToolConfig; @@ -255,7 +255,7 @@ function resolveMaxOutputChars(cfg?: TiDbToolConfig): number { return 60_000; } -export function createTiDbTool(options: { config?: ClawdbotConfig }): AnyAgentTool | null { +export function createTiDbTool(options: { config?: MoltbotConfig }): AnyAgentTool | null { const cfg = options.config; if (!cfg) return null;