From ae4fdaea82073dd4596a76e5a11cc6a62e0aaa47 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 10 Apr 2026 09:58:59 +0100 Subject: [PATCH] fix(telegram): split monitor runtime types --- extensions/telegram/src/monitor.ts | 19 ++----------------- extensions/telegram/src/monitor.types.ts | 22 ++++++++++++++++++++++ extensions/telegram/src/runtime.types.ts | 17 ++++++++++------- 3 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 extensions/telegram/src/monitor.types.ts diff --git a/extensions/telegram/src/monitor.ts b/extensions/telegram/src/monitor.ts index 59b5db11fca..7b1427ac9cb 100644 --- a/extensions/telegram/src/monitor.ts +++ b/extensions/telegram/src/monitor.ts @@ -1,6 +1,5 @@ import type { RunOptions } from "@grammyjs/runner"; import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plugin-sdk/approval-handler-adapter-runtime"; -import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core"; import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context"; import { resolveAgentMaxConcurrent } from "openclaw/plugin-sdk/config-runtime"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; @@ -13,28 +12,14 @@ import { resolveTelegramAccount } from "./accounts.js"; import { resolveTelegramAllowedUpdates } from "./allowed-updates.js"; import { isTelegramExecApprovalHandlerConfigured } from "./exec-approvals.js"; import { resolveTelegramTransport } from "./fetch.js"; +import type { MonitorTelegramOpts } from "./monitor.types.js"; import { isRecoverableTelegramNetworkError, isTelegramPollingNetworkError, } from "./network-errors.js"; import { makeProxyFetch } from "./proxy.js"; -export type MonitorTelegramOpts = { - token?: string; - accountId?: string; - config?: OpenClawConfig; - runtime?: RuntimeEnv; - channelRuntime?: PluginRuntime["channel"]; - abortSignal?: AbortSignal; - useWebhook?: boolean; - webhookPath?: string; - webhookPort?: number; - webhookSecret?: string; - webhookHost?: string; - proxyFetch?: typeof fetch; - webhookUrl?: string; - webhookCertPath?: string; -}; +export type { MonitorTelegramOpts } from "./monitor.types.js"; export function createTelegramRunnerOptions(cfg: OpenClawConfig): RunOptions { return { diff --git a/extensions/telegram/src/monitor.types.ts b/extensions/telegram/src/monitor.types.ts new file mode 100644 index 00000000000..83ce17358ad --- /dev/null +++ b/extensions/telegram/src/monitor.types.ts @@ -0,0 +1,22 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core"; +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env"; + +export type MonitorTelegramOpts = { + token?: string; + accountId?: string; + config?: OpenClawConfig; + runtime?: RuntimeEnv; + channelRuntime?: PluginRuntime["channel"]; + abortSignal?: AbortSignal; + useWebhook?: boolean; + webhookPath?: string; + webhookPort?: number; + webhookSecret?: string; + webhookHost?: string; + proxyFetch?: typeof fetch; + webhookUrl?: string; + webhookCertPath?: string; +}; + +export type TelegramMonitorFn = (opts?: MonitorTelegramOpts) => Promise; diff --git a/extensions/telegram/src/runtime.types.ts b/extensions/telegram/src/runtime.types.ts index 8ec16237054..81d3394bc79 100644 --- a/extensions/telegram/src/runtime.types.ts +++ b/extensions/telegram/src/runtime.types.ts @@ -1,12 +1,13 @@ import type { ChannelMessageActionAdapter } from "openclaw/plugin-sdk/channel-contract"; -import type { PluginRuntime } from "openclaw/plugin-sdk/runtime-store"; +import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core"; +import type { TelegramMonitorFn } from "./monitor.types.js"; export type TelegramProbeFn = typeof import("./probe.js").probeTelegram; export type TelegramAuditCollectFn = typeof import("./audit.js").collectTelegramUnmentionedGroupIds; export type TelegramAuditMembershipFn = typeof import("./audit.js").auditTelegramGroupMembership; -export type TelegramMonitorFn = typeof import("./monitor.js").monitorTelegramProvider; export type TelegramSendFn = typeof import("./send.js").sendMessageTelegram; export type TelegramResolveTokenFn = typeof import("./token.js").resolveTelegramToken; +type BasePluginRuntimeChannel = PluginRuntime extends { channel: infer T } ? T : never; export type TelegramChannelRuntime = { probeTelegram?: TelegramProbeFn; @@ -18,8 +19,10 @@ export type TelegramChannelRuntime = { messageActions?: ChannelMessageActionAdapter; }; -export type TelegramRuntime = PluginRuntime & { - channel: PluginRuntime["channel"] & { - telegram?: TelegramChannelRuntime; - }; -}; +export interface TelegramRuntimeChannel extends BasePluginRuntimeChannel { + telegram?: TelegramChannelRuntime; +} + +export interface TelegramRuntime extends PluginRuntime { + channel: TelegramRuntimeChannel; +}