import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { hasQiaoqiaoToolEnabledForAnyAccount, withQiaoqiaoToolClient } from "../tools-common/tool-exec.js"; import { runToolWithExecutionLog } from "../tools-common/tool-execution-log.js"; import { errorResult, json } from "../tools-common/qiaoqiao-api.js"; import { registeredTool, skippedTool, type QiaoqiaoToolRegistrationResult, } from "../tools-common/tool-registration-log.js"; import { runDashboardAction } from "./actions.js"; import { QiaoqiaoDashboardSchema, type QiaoqiaoDashboardParams } from "./schemas.js"; export function registerQiaoqiaoDashboardTools(api: OpenClawPluginApi): QiaoqiaoToolRegistrationResult { if (!api.config) { return skippedTool(api, "qiaoqiao_dashboard", "no config available"); } if (!hasQiaoqiaoToolEnabledForAnyAccount(api.config, "dashboard")) { return skippedTool(api, "qiaoqiao_dashboard", "dashboard tool disabled or no enabled/configured account"); } api.registerTool( { name: "qiaoqiao_dashboard", label: "Qiaoqiao Dashboard", description: "Get Qiaoqiao dashboard overview or comment statistics for the current agent account.", parameters: QiaoqiaoDashboardSchema, async execute(_toolCallId, params) { return runToolWithExecutionLog({ api, toolName: "qiaoqiao_dashboard", params, run: async () => { try { return await withQiaoqiaoToolClient({ api, toolName: "qiaoqiao_dashboard", requiredTool: "dashboard", run: async ({ account }) => json(await runDashboardAction(account, (params ?? {}) as QiaoqiaoDashboardParams)), }); } catch (err) { return errorResult(err); } }, }); }, }, { name: "qiaoqiao_dashboard" }, ); return registeredTool(api, "qiaoqiao_dashboard"); }