diff --git a/extensions/qqbot/channel-entry-api.ts b/extensions/qqbot/channel-entry-api.ts new file mode 100644 index 000000000000..6eb00d00579e --- /dev/null +++ b/extensions/qqbot/channel-entry-api.ts @@ -0,0 +1,2 @@ +// Narrow bridge entrypoint for qqbot registerFull composition. +export { registerQQBotFull } from "./src/bridge/channel-entry.js"; diff --git a/extensions/qqbot/index.ts b/extensions/qqbot/index.ts index c642149da3d1..d59a7c14a1c9 100644 --- a/extensions/qqbot/index.ts +++ b/extensions/qqbot/index.ts @@ -6,8 +6,19 @@ import { } from "openclaw/plugin-sdk/channel-entry-contract"; function registerQQBotFull(api: OpenClawPluginApi): void { + if (api.registrationMode === "tool-discovery") { + const registerTools = loadBundledEntryExportSync<(api: OpenClawPluginApi) => void>( + import.meta.url, + { + specifier: "./tools-api.js", + exportName: "registerQQBotTools", + }, + ); + registerTools(api); + return; + } const register = loadBundledEntryExportSync<(api: OpenClawPluginApi) => void>(import.meta.url, { - specifier: "./api.js", + specifier: "./channel-entry-api.js", exportName: "registerQQBotFull", }); register(api); diff --git a/extensions/qqbot/src/bridge/tools/channel.ts b/extensions/qqbot/src/bridge/tools/channel.ts index a3630acc9686..efa83af6003d 100644 --- a/extensions/qqbot/src/bridge/tools/channel.ts +++ b/extensions/qqbot/src/bridge/tools/channel.ts @@ -1,6 +1,5 @@ // Qqbot plugin module implements channel behavior. import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core"; -import { getAccessToken } from "../../engine/messaging/sender.js"; import { ChannelApiSchema, executeChannelApi } from "../../engine/tools/channel-api.js"; import type { ChannelApiParams } from "../../engine/tools/channel-api.js"; import { listQQBotAccountIds, resolveQQBotAccount } from "../config.js"; @@ -50,6 +49,7 @@ export function registerChannelTool(api: OpenClawPluginApi): void { "See the qqbot-channel skill for full endpoint details.", parameters: ChannelApiSchema, async execute(_toolCallId, params) { + const { getAccessToken } = await import("../../engine/messaging/sender.js"); const accessToken = await getAccessToken(account.appId, account.clientSecret); return executeChannelApi(params as ChannelApiParams, { accessToken }); }, diff --git a/extensions/qqbot/tools-api.ts b/extensions/qqbot/tools-api.ts new file mode 100644 index 000000000000..8ae1c0d61901 --- /dev/null +++ b/extensions/qqbot/tools-api.ts @@ -0,0 +1,2 @@ +// Narrow tool-discovery entrypoint for qqbot tools. +export { registerQQBotTools } from "./src/bridge/tools/index.js"; diff --git a/test/plugin-npm-runtime-build.test.ts b/test/plugin-npm-runtime-build.test.ts index eaf01fb0c5cb..2277fc49b8f4 100644 --- a/test/plugin-npm-runtime-build.test.ts +++ b/test/plugin-npm-runtime-build.test.ts @@ -58,12 +58,14 @@ describe("plugin npm runtime build planning", () => { const qqbotRuntimePlan = expectPluginNpmRuntimeBuildPlan(qqbotPlan); expect(qqbotRuntimePlan.entry).toEqual({ api: path.join(repoRoot, "extensions", "qqbot", "api.ts"), + "channel-entry-api": path.join(repoRoot, "extensions", "qqbot", "channel-entry-api.ts"), "channel-plugin-api": path.join(repoRoot, "extensions", "qqbot", "channel-plugin-api.ts"), index: path.join(repoRoot, "extensions", "qqbot", "index.ts"), "runtime-api": path.join(repoRoot, "extensions", "qqbot", "runtime-api.ts"), "secret-contract-api": path.join(repoRoot, "extensions", "qqbot", "secret-contract-api.ts"), "setup-entry": path.join(repoRoot, "extensions", "qqbot", "setup-entry.ts"), "setup-plugin-api": path.join(repoRoot, "extensions", "qqbot", "setup-plugin-api.ts"), + "tools-api": path.join(repoRoot, "extensions", "qqbot", "tools-api.ts"), }); expect(qqbotRuntimePlan.runtimeExtensions).toEqual(["./dist/index.js"]); expect(qqbotRuntimePlan.runtimeSetupEntry).toBe("./dist/setup-entry.js");