perf(telegram): narrow native command import surface

This commit is contained in:
Vincent Koc
2026-03-31 21:43:16 +09:00
parent b19e28a85e
commit 7710579a82
5 changed files with 43 additions and 5 deletions

View File

@@ -0,0 +1,4 @@
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
import { deliverReplies } from "./bot/delivery.js";
export { createChannelReplyPipeline, deliverReplies };

View File

@@ -1,10 +1,9 @@
import type { Bot, Context } from "grammy";
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
import {
resolveCommandAuthorization,
resolveCommandAuthorizedFromAuthorizers,
resolveNativeCommandSessionTargets,
} from "openclaw/plugin-sdk/command-auth";
} from "openclaw/plugin-sdk/command-auth-native";
import {
buildCommandTextFromArgs,
findCommandByNativeName,
@@ -13,7 +12,7 @@ import {
parseCommandArgs,
resolveCommandArgMenu,
type CommandArgs,
} from "openclaw/plugin-sdk/command-auth";
} from "openclaw/plugin-sdk/command-auth-native";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import type { ChannelGroupPolicy } from "openclaw/plugin-sdk/config-runtime";
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/config-runtime";
@@ -59,8 +58,7 @@ import {
syncTelegramMenuCommands as syncTelegramMenuCommandsRuntime,
} from "./bot-native-command-menu.js";
import { TelegramUpdateKeyContext } from "./bot-updates.js";
import { TelegramBotOptions } from "./bot.js";
import { deliverReplies } from "./bot/delivery.js";
import type { TelegramBotOptions } from "./bot.js";
import {
buildTelegramRoutingTarget,
buildTelegramThreadParams,
@@ -102,6 +100,16 @@ type TelegramCommandAuthResult = {
commandAuthorized: boolean;
};
let telegramNativeCommandDeliveryRuntimePromise:
| Promise<typeof import("./bot-native-commands.delivery.runtime.js")>
| undefined;
async function loadTelegramNativeCommandDeliveryRuntime() {
telegramNativeCommandDeliveryRuntimePromise ??=
import("./bot-native-commands.delivery.runtime.js");
return await telegramNativeCommandDeliveryRuntimePromise;
}
export type RegisterTelegramHandlerParams = {
cfg: OpenClawConfig;
accountId: string;
@@ -812,6 +820,8 @@ export const registerTelegramNativeCommands = ({
skippedNonSilent: 0,
};
const { createChannelReplyPipeline, deliverReplies } =
await loadTelegramNativeCommandDeliveryRuntime();
const { onModelSelected, ...replyPipeline } = createChannelReplyPipeline({
cfg: executionCfg,
agentId: route.agentId,
@@ -936,6 +946,7 @@ export const registerTelegramNativeCommands = ({
});
const from = isGroup ? buildTelegramGroupFrom(chatId, threadSpec.id) : `telegram:${chatId}`;
const to = `telegram:${chatId}`;
const { deliverReplies } = await loadTelegramNativeCommandDeliveryRuntime();
const result = await executePluginCommand({
command: match.command,

View File

@@ -313,6 +313,10 @@
"types": "./dist/plugin-sdk/command-auth.d.ts",
"default": "./dist/plugin-sdk/command-auth.js"
},
"./plugin-sdk/command-auth-native": {
"types": "./dist/plugin-sdk/command-auth-native.d.ts",
"default": "./dist/plugin-sdk/command-auth-native.js"
},
"./plugin-sdk/collection-runtime": {
"types": "./dist/plugin-sdk/collection-runtime.d.ts",
"default": "./dist/plugin-sdk/collection-runtime.js"

View File

@@ -68,6 +68,7 @@
"byteplus",
"chutes",
"command-auth",
"command-auth-native",
"collection-runtime",
"compat",
"direct-dm",

View File

@@ -0,0 +1,18 @@
export {
buildCommandTextFromArgs,
findCommandByNativeName,
listNativeCommandSpecs,
listNativeCommandSpecsForConfig,
parseCommandArgs,
resolveCommandArgMenu,
} from "../auto-reply/commands-registry.js";
export type { CommandArgs } from "../auto-reply/commands-registry.js";
export {
resolveCommandAuthorizedFromAuthorizers,
resolveControlCommandGate,
} from "../channels/command-gating.js";
export { resolveNativeCommandSessionTargets } from "../channels/native-command-session-targets.js";
export {
resolveCommandAuthorization,
type CommandAuthorization,
} from "../auto-reply/command-auth.js";