mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-24 07:01:49 +00:00
perf(telegram): narrow native command import surface
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
|
||||
import { deliverReplies } from "./bot/delivery.js";
|
||||
|
||||
export { createChannelReplyPipeline, deliverReplies };
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
"byteplus",
|
||||
"chutes",
|
||||
"command-auth",
|
||||
"command-auth-native",
|
||||
"collection-runtime",
|
||||
"compat",
|
||||
"direct-dm",
|
||||
|
||||
18
src/plugin-sdk/command-auth-native.ts
Normal file
18
src/plugin-sdk/command-auth-native.ts
Normal 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";
|
||||
Reference in New Issue
Block a user