fix(telegram): split monitor runtime types

This commit is contained in:
Vincent Koc
2026-04-10 09:58:59 +01:00
parent ad8207c9d5
commit ae4fdaea82
3 changed files with 34 additions and 24 deletions

View File

@@ -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<unknown> {
return {

View File

@@ -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<void>;

View File

@@ -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;
}