diff --git a/extensions/bluebubbles/src/actions.runtime.ts b/extensions/bluebubbles/src/actions.runtime.ts index 53285c19f17..00d0bc00efd 100644 --- a/extensions/bluebubbles/src/actions.runtime.ts +++ b/extensions/bluebubbles/src/actions.runtime.ts @@ -1,13 +1,101 @@ -export { sendBlueBubblesAttachment } from "./attachments.js"; -export { - addBlueBubblesParticipant, - editBlueBubblesMessage, - leaveBlueBubblesChat, - removeBlueBubblesParticipant, - renameBlueBubblesChat, - setGroupIconBlueBubbles, - unsendBlueBubblesMessage, +import { sendBlueBubblesAttachment as sendBlueBubblesAttachmentImpl } from "./attachments.js"; +import { + addBlueBubblesParticipant as addBlueBubblesParticipantImpl, + editBlueBubblesMessage as editBlueBubblesMessageImpl, + leaveBlueBubblesChat as leaveBlueBubblesChatImpl, + removeBlueBubblesParticipant as removeBlueBubblesParticipantImpl, + renameBlueBubblesChat as renameBlueBubblesChatImpl, + setGroupIconBlueBubbles as setGroupIconBlueBubblesImpl, + unsendBlueBubblesMessage as unsendBlueBubblesMessageImpl, } from "./chat.js"; -export { resolveBlueBubblesMessageId } from "./monitor.js"; -export { sendBlueBubblesReaction } from "./reactions.js"; -export { resolveChatGuidForTarget, sendMessageBlueBubbles } from "./send.js"; +import { resolveBlueBubblesMessageId as resolveBlueBubblesMessageIdImpl } from "./monitor.js"; +import { sendBlueBubblesReaction as sendBlueBubblesReactionImpl } from "./reactions.js"; +import { + resolveChatGuidForTarget as resolveChatGuidForTargetImpl, + sendMessageBlueBubbles as sendMessageBlueBubblesImpl, +} from "./send.js"; + +type SendBlueBubblesAttachment = typeof import("./attachments.js").sendBlueBubblesAttachment; +type AddBlueBubblesParticipant = typeof import("./chat.js").addBlueBubblesParticipant; +type EditBlueBubblesMessage = typeof import("./chat.js").editBlueBubblesMessage; +type LeaveBlueBubblesChat = typeof import("./chat.js").leaveBlueBubblesChat; +type RemoveBlueBubblesParticipant = typeof import("./chat.js").removeBlueBubblesParticipant; +type RenameBlueBubblesChat = typeof import("./chat.js").renameBlueBubblesChat; +type SetGroupIconBlueBubbles = typeof import("./chat.js").setGroupIconBlueBubbles; +type UnsendBlueBubblesMessage = typeof import("./chat.js").unsendBlueBubblesMessage; +type ResolveBlueBubblesMessageId = typeof import("./monitor.js").resolveBlueBubblesMessageId; +type SendBlueBubblesReaction = typeof import("./reactions.js").sendBlueBubblesReaction; +type ResolveChatGuidForTarget = typeof import("./send.js").resolveChatGuidForTarget; +type SendMessageBlueBubbles = typeof import("./send.js").sendMessageBlueBubbles; + +export function sendBlueBubblesAttachment( + ...args: Parameters +): ReturnType { + return sendBlueBubblesAttachmentImpl(...args); +} + +export function addBlueBubblesParticipant( + ...args: Parameters +): ReturnType { + return addBlueBubblesParticipantImpl(...args); +} + +export function editBlueBubblesMessage( + ...args: Parameters +): ReturnType { + return editBlueBubblesMessageImpl(...args); +} + +export function leaveBlueBubblesChat( + ...args: Parameters +): ReturnType { + return leaveBlueBubblesChatImpl(...args); +} + +export function removeBlueBubblesParticipant( + ...args: Parameters +): ReturnType { + return removeBlueBubblesParticipantImpl(...args); +} + +export function renameBlueBubblesChat( + ...args: Parameters +): ReturnType { + return renameBlueBubblesChatImpl(...args); +} + +export function setGroupIconBlueBubbles( + ...args: Parameters +): ReturnType { + return setGroupIconBlueBubblesImpl(...args); +} + +export function unsendBlueBubblesMessage( + ...args: Parameters +): ReturnType { + return unsendBlueBubblesMessageImpl(...args); +} + +export function resolveBlueBubblesMessageId( + ...args: Parameters +): ReturnType { + return resolveBlueBubblesMessageIdImpl(...args); +} + +export function sendBlueBubblesReaction( + ...args: Parameters +): ReturnType { + return sendBlueBubblesReactionImpl(...args); +} + +export function resolveChatGuidForTarget( + ...args: Parameters +): ReturnType { + return resolveChatGuidForTargetImpl(...args); +} + +export function sendMessageBlueBubbles( + ...args: Parameters +): ReturnType { + return sendMessageBlueBubblesImpl(...args); +} diff --git a/extensions/bluebubbles/src/channel.runtime.ts b/extensions/bluebubbles/src/channel.runtime.ts index 32bf567dcf5..d318943d3f2 100644 --- a/extensions/bluebubbles/src/channel.runtime.ts +++ b/extensions/bluebubbles/src/channel.runtime.ts @@ -1,6 +1,57 @@ -export { sendBlueBubblesMedia } from "./media-send.js"; -export { resolveBlueBubblesMessageId } from "./monitor.js"; -export { monitorBlueBubblesProvider, resolveWebhookPathFromConfig } from "./monitor.js"; -export { type BlueBubblesProbe, probeBlueBubbles } from "./probe.js"; -export { sendMessageBlueBubbles } from "./send.js"; -export { blueBubblesSetupWizard } from "./setup-surface.js"; +import { sendBlueBubblesMedia as sendBlueBubblesMediaImpl } from "./media-send.js"; +import { + monitorBlueBubblesProvider as monitorBlueBubblesProviderImpl, + resolveBlueBubblesMessageId as resolveBlueBubblesMessageIdImpl, + resolveWebhookPathFromConfig as resolveWebhookPathFromConfigImpl, +} from "./monitor.js"; +import { probeBlueBubbles as probeBlueBubblesImpl } from "./probe.js"; +import { sendMessageBlueBubbles as sendMessageBlueBubblesImpl } from "./send.js"; +import { blueBubblesSetupWizard as blueBubblesSetupWizardImpl } from "./setup-surface.js"; + +export type { BlueBubblesProbe } from "./probe.js"; + +type SendBlueBubblesMedia = typeof import("./media-send.js").sendBlueBubblesMedia; +type ResolveBlueBubblesMessageId = typeof import("./monitor.js").resolveBlueBubblesMessageId; +type MonitorBlueBubblesProvider = typeof import("./monitor.js").monitorBlueBubblesProvider; +type ResolveWebhookPathFromConfig = typeof import("./monitor.js").resolveWebhookPathFromConfig; +type ProbeBlueBubbles = typeof import("./probe.js").probeBlueBubbles; +type SendMessageBlueBubbles = typeof import("./send.js").sendMessageBlueBubbles; +type BlueBubblesSetupWizard = typeof import("./setup-surface.js").blueBubblesSetupWizard; + +export function sendBlueBubblesMedia( + ...args: Parameters +): ReturnType { + return sendBlueBubblesMediaImpl(...args); +} + +export function resolveBlueBubblesMessageId( + ...args: Parameters +): ReturnType { + return resolveBlueBubblesMessageIdImpl(...args); +} + +export function monitorBlueBubblesProvider( + ...args: Parameters +): ReturnType { + return monitorBlueBubblesProviderImpl(...args); +} + +export function resolveWebhookPathFromConfig( + ...args: Parameters +): ReturnType { + return resolveWebhookPathFromConfigImpl(...args); +} + +export function probeBlueBubbles( + ...args: Parameters +): ReturnType { + return probeBlueBubblesImpl(...args); +} + +export function sendMessageBlueBubbles( + ...args: Parameters +): ReturnType { + return sendMessageBlueBubblesImpl(...args); +} + +export const blueBubblesSetupWizard: BlueBubblesSetupWizard = { ...blueBubblesSetupWizardImpl }; diff --git a/extensions/discord/src/channel.runtime.ts b/extensions/discord/src/channel.runtime.ts index bc22b64706a..d4da518fdc1 100644 --- a/extensions/discord/src/channel.runtime.ts +++ b/extensions/discord/src/channel.runtime.ts @@ -1 +1,5 @@ -export { discordSetupWizard } from "./setup-surface.js"; +import { discordSetupWizard as discordSetupWizardImpl } from "./setup-surface.js"; + +type DiscordSetupWizard = typeof import("./setup-surface.js").discordSetupWizard; + +export const discordSetupWizard: DiscordSetupWizard = { ...discordSetupWizardImpl }; diff --git a/extensions/discord/src/setup-surface.ts b/extensions/discord/src/setup-surface.ts index 5432302ff4b..78e1c1da804 100644 --- a/extensions/discord/src/setup-surface.ts +++ b/extensions/discord/src/setup-surface.ts @@ -100,15 +100,9 @@ async function resolveDiscordGroupAllowlist(params: { }); } +<<<<<<< HEAD export const discordSetupWizard: ChannelSetupWizard = createDiscordSetupWizardBase({ promptAllowFrom: promptDiscordAllowFrom, - resolveGroupAllowlist: async ({ cfg, accountId, credentialValues, entries }) => - await resolveDiscordGroupAllowlist({ - cfg, - accountId, - credentialValues, - entries, - }), resolveAllowFromEntries: async ({ cfg, accountId, credentialValues, entries }) => await resolveDiscordAllowFromEntries({ token: @@ -116,4 +110,11 @@ export const discordSetupWizard: ChannelSetupWizard = createDiscordSetupWizardBa (typeof credentialValues.token === "string" ? credentialValues.token : ""), entries, }), + resolveGroupAllowlist: async ({ cfg, accountId, credentialValues, entries }) => + await resolveDiscordGroupAllowlist({ + cfg, + accountId, + credentialValues, + entries, + }), }); diff --git a/extensions/discord/src/voice/manager.runtime.ts b/extensions/discord/src/voice/manager.runtime.ts index 77574b166e5..1619d63a27c 100644 --- a/extensions/discord/src/voice/manager.runtime.ts +++ b/extensions/discord/src/voice/manager.runtime.ts @@ -1 +1,8 @@ -export { DiscordVoiceManager, DiscordVoiceReadyListener } from "./manager.js"; +import { + DiscordVoiceManager as DiscordVoiceManagerImpl, + DiscordVoiceReadyListener as DiscordVoiceReadyListenerImpl, +} from "./manager.js"; + +export class DiscordVoiceManager extends DiscordVoiceManagerImpl {} + +export class DiscordVoiceReadyListener extends DiscordVoiceReadyListenerImpl {} diff --git a/extensions/feishu/src/channel.runtime.ts b/extensions/feishu/src/channel.runtime.ts index 0e4d9fc7583..c8a742942ea 100644 --- a/extensions/feishu/src/channel.runtime.ts +++ b/extensions/feishu/src/channel.runtime.ts @@ -1,7 +1,129 @@ -export { listFeishuDirectoryGroupsLive, listFeishuDirectoryPeersLive } from "./directory.js"; -export { feishuOutbound } from "./outbound.js"; -export { createPinFeishu, listPinsFeishu, removePinFeishu } from "./pins.js"; -export { probeFeishu } from "./probe.js"; -export { addReactionFeishu, listReactionsFeishu, removeReactionFeishu } from "./reactions.js"; -export { getChatInfo, getChatMembers, getFeishuMemberInfo } from "./chat.js"; -export { editMessageFeishu, getMessageFeishu, sendCardFeishu, sendMessageFeishu } from "./send.js"; +import { + getChatInfo as getChatInfoImpl, + getChatMembers as getChatMembersImpl, + getFeishuMemberInfo as getFeishuMemberInfoImpl, +} from "./chat.js"; +import { + listFeishuDirectoryGroupsLive as listFeishuDirectoryGroupsLiveImpl, + listFeishuDirectoryPeersLive as listFeishuDirectoryPeersLiveImpl, +} from "./directory.js"; +import { feishuOutbound as feishuOutboundImpl } from "./outbound.js"; +import { + createPinFeishu as createPinFeishuImpl, + listPinsFeishu as listPinsFeishuImpl, + removePinFeishu as removePinFeishuImpl, +} from "./pins.js"; +import { probeFeishu as probeFeishuImpl } from "./probe.js"; +import { + addReactionFeishu as addReactionFeishuImpl, + listReactionsFeishu as listReactionsFeishuImpl, + removeReactionFeishu as removeReactionFeishuImpl, +} from "./reactions.js"; +import { + editMessageFeishu as editMessageFeishuImpl, + getMessageFeishu as getMessageFeishuImpl, + sendCardFeishu as sendCardFeishuImpl, + sendMessageFeishu as sendMessageFeishuImpl, +} from "./send.js"; + +type ListFeishuDirectoryGroupsLive = typeof import("./directory.js").listFeishuDirectoryGroupsLive; +type ListFeishuDirectoryPeersLive = typeof import("./directory.js").listFeishuDirectoryPeersLive; +type FeishuOutbound = typeof import("./outbound.js").feishuOutbound; +type CreatePinFeishu = typeof import("./pins.js").createPinFeishu; +type ListPinsFeishu = typeof import("./pins.js").listPinsFeishu; +type RemovePinFeishu = typeof import("./pins.js").removePinFeishu; +type ProbeFeishu = typeof import("./probe.js").probeFeishu; +type AddReactionFeishu = typeof import("./reactions.js").addReactionFeishu; +type ListReactionsFeishu = typeof import("./reactions.js").listReactionsFeishu; +type RemoveReactionFeishu = typeof import("./reactions.js").removeReactionFeishu; +type GetChatInfo = typeof import("./chat.js").getChatInfo; +type GetChatMembers = typeof import("./chat.js").getChatMembers; +type GetFeishuMemberInfo = typeof import("./chat.js").getFeishuMemberInfo; +type EditMessageFeishu = typeof import("./send.js").editMessageFeishu; +type GetMessageFeishu = typeof import("./send.js").getMessageFeishu; +type SendCardFeishu = typeof import("./send.js").sendCardFeishu; +type SendMessageFeishu = typeof import("./send.js").sendMessageFeishu; + +export function listFeishuDirectoryGroupsLive( + ...args: Parameters +): ReturnType { + return listFeishuDirectoryGroupsLiveImpl(...args); +} + +export function listFeishuDirectoryPeersLive( + ...args: Parameters +): ReturnType { + return listFeishuDirectoryPeersLiveImpl(...args); +} + +export const feishuOutbound: FeishuOutbound = { ...feishuOutboundImpl }; + +export function createPinFeishu(...args: Parameters): ReturnType { + return createPinFeishuImpl(...args); +} + +export function listPinsFeishu(...args: Parameters): ReturnType { + return listPinsFeishuImpl(...args); +} + +export function removePinFeishu(...args: Parameters): ReturnType { + return removePinFeishuImpl(...args); +} + +export function probeFeishu(...args: Parameters): ReturnType { + return probeFeishuImpl(...args); +} + +export function addReactionFeishu( + ...args: Parameters +): ReturnType { + return addReactionFeishuImpl(...args); +} + +export function listReactionsFeishu( + ...args: Parameters +): ReturnType { + return listReactionsFeishuImpl(...args); +} + +export function removeReactionFeishu( + ...args: Parameters +): ReturnType { + return removeReactionFeishuImpl(...args); +} + +export function getChatInfo(...args: Parameters): ReturnType { + return getChatInfoImpl(...args); +} + +export function getChatMembers(...args: Parameters): ReturnType { + return getChatMembersImpl(...args); +} + +export function getFeishuMemberInfo( + ...args: Parameters +): ReturnType { + return getFeishuMemberInfoImpl(...args); +} + +export function editMessageFeishu( + ...args: Parameters +): ReturnType { + return editMessageFeishuImpl(...args); +} + +export function getMessageFeishu( + ...args: Parameters +): ReturnType { + return getMessageFeishuImpl(...args); +} + +export function sendCardFeishu(...args: Parameters): ReturnType { + return sendCardFeishuImpl(...args); +} + +export function sendMessageFeishu( + ...args: Parameters +): ReturnType { + return sendMessageFeishuImpl(...args); +} diff --git a/extensions/googlechat/src/channel.runtime.ts b/extensions/googlechat/src/channel.runtime.ts index fdf060f9fd4..1e41376c8f5 100644 --- a/extensions/googlechat/src/channel.runtime.ts +++ b/extensions/googlechat/src/channel.runtime.ts @@ -1,2 +1,43 @@ -export { probeGoogleChat, sendGoogleChatMessage, uploadGoogleChatAttachment } from "./api.js"; -export { resolveGoogleChatWebhookPath, startGoogleChatMonitor } from "./monitor.js"; +import { + probeGoogleChat as probeGoogleChatImpl, + sendGoogleChatMessage as sendGoogleChatMessageImpl, + uploadGoogleChatAttachment as uploadGoogleChatAttachmentImpl, +} from "./api.js"; +import { + resolveGoogleChatWebhookPath as resolveGoogleChatWebhookPathImpl, + startGoogleChatMonitor as startGoogleChatMonitorImpl, +} from "./monitor.js"; + +type ProbeGoogleChat = typeof import("./api.js").probeGoogleChat; +type SendGoogleChatMessage = typeof import("./api.js").sendGoogleChatMessage; +type UploadGoogleChatAttachment = typeof import("./api.js").uploadGoogleChatAttachment; +type ResolveGoogleChatWebhookPath = typeof import("./monitor.js").resolveGoogleChatWebhookPath; +type StartGoogleChatMonitor = typeof import("./monitor.js").startGoogleChatMonitor; + +export function probeGoogleChat(...args: Parameters): ReturnType { + return probeGoogleChatImpl(...args); +} + +export function sendGoogleChatMessage( + ...args: Parameters +): ReturnType { + return sendGoogleChatMessageImpl(...args); +} + +export function uploadGoogleChatAttachment( + ...args: Parameters +): ReturnType { + return uploadGoogleChatAttachmentImpl(...args); +} + +export function resolveGoogleChatWebhookPath( + ...args: Parameters +): ReturnType { + return resolveGoogleChatWebhookPathImpl(...args); +} + +export function startGoogleChatMonitor( + ...args: Parameters +): ReturnType { + return startGoogleChatMonitorImpl(...args); +} diff --git a/extensions/matrix/src/channel.runtime.ts b/extensions/matrix/src/channel.runtime.ts index bcce71da2d1..df56d07ff2c 100644 --- a/extensions/matrix/src/channel.runtime.ts +++ b/extensions/matrix/src/channel.runtime.ts @@ -1,6 +1,55 @@ -export { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js"; -export { resolveMatrixAuth } from "./matrix/client.js"; -export { probeMatrix } from "./matrix/probe.js"; -export { sendMessageMatrix } from "./matrix/send.js"; -export { resolveMatrixTargets } from "./resolve-targets.js"; -export { matrixOutbound } from "./outbound.js"; +import { + listMatrixDirectoryGroupsLive as listMatrixDirectoryGroupsLiveImpl, + listMatrixDirectoryPeersLive as listMatrixDirectoryPeersLiveImpl, +} from "./directory-live.js"; +import { resolveMatrixAuth as resolveMatrixAuthImpl } from "./matrix/client.js"; +import { probeMatrix as probeMatrixImpl } from "./matrix/probe.js"; +import { sendMessageMatrix as sendMessageMatrixImpl } from "./matrix/send.js"; +import { matrixOutbound as matrixOutboundImpl } from "./outbound.js"; +import { resolveMatrixTargets as resolveMatrixTargetsImpl } from "./resolve-targets.js"; + +type ListMatrixDirectoryGroupsLive = + typeof import("./directory-live.js").listMatrixDirectoryGroupsLive; +type ListMatrixDirectoryPeersLive = + typeof import("./directory-live.js").listMatrixDirectoryPeersLive; +type ResolveMatrixAuth = typeof import("./matrix/client.js").resolveMatrixAuth; +type ProbeMatrix = typeof import("./matrix/probe.js").probeMatrix; +type SendMessageMatrix = typeof import("./matrix/send.js").sendMessageMatrix; +type ResolveMatrixTargets = typeof import("./resolve-targets.js").resolveMatrixTargets; +type MatrixOutbound = typeof import("./outbound.js").matrixOutbound; + +export function listMatrixDirectoryGroupsLive( + ...args: Parameters +): ReturnType { + return listMatrixDirectoryGroupsLiveImpl(...args); +} + +export function listMatrixDirectoryPeersLive( + ...args: Parameters +): ReturnType { + return listMatrixDirectoryPeersLiveImpl(...args); +} + +export function resolveMatrixAuth( + ...args: Parameters +): ReturnType { + return resolveMatrixAuthImpl(...args); +} + +export function probeMatrix(...args: Parameters): ReturnType { + return probeMatrixImpl(...args); +} + +export function sendMessageMatrix( + ...args: Parameters +): ReturnType { + return sendMessageMatrixImpl(...args); +} + +export function resolveMatrixTargets( + ...args: Parameters +): ReturnType { + return resolveMatrixTargetsImpl(...args); +} + +export const matrixOutbound: MatrixOutbound = { ...matrixOutboundImpl }; diff --git a/extensions/msteams/src/channel.runtime.ts b/extensions/msteams/src/channel.runtime.ts index 45a0147f46b..c55d0fc626a 100644 --- a/extensions/msteams/src/channel.runtime.ts +++ b/extensions/msteams/src/channel.runtime.ts @@ -1,4 +1,49 @@ -export { listMSTeamsDirectoryGroupsLive, listMSTeamsDirectoryPeersLive } from "./directory-live.js"; -export { msteamsOutbound } from "./outbound.js"; -export { probeMSTeams } from "./probe.js"; -export { sendAdaptiveCardMSTeams, sendMessageMSTeams } from "./send.js"; +import { + listMSTeamsDirectoryGroupsLive as listMSTeamsDirectoryGroupsLiveImpl, + listMSTeamsDirectoryPeersLive as listMSTeamsDirectoryPeersLiveImpl, +} from "./directory-live.js"; +import { msteamsOutbound as msteamsOutboundImpl } from "./outbound.js"; +import { probeMSTeams as probeMSTeamsImpl } from "./probe.js"; +import { + sendAdaptiveCardMSTeams as sendAdaptiveCardMSTeamsImpl, + sendMessageMSTeams as sendMessageMSTeamsImpl, +} from "./send.js"; + +type ListMSTeamsDirectoryGroupsLive = + typeof import("./directory-live.js").listMSTeamsDirectoryGroupsLive; +type ListMSTeamsDirectoryPeersLive = + typeof import("./directory-live.js").listMSTeamsDirectoryPeersLive; +type MSTeamsOutbound = typeof import("./outbound.js").msteamsOutbound; +type ProbeMSTeams = typeof import("./probe.js").probeMSTeams; +type SendAdaptiveCardMSTeams = typeof import("./send.js").sendAdaptiveCardMSTeams; +type SendMessageMSTeams = typeof import("./send.js").sendMessageMSTeams; + +export function listMSTeamsDirectoryGroupsLive( + ...args: Parameters +): ReturnType { + return listMSTeamsDirectoryGroupsLiveImpl(...args); +} + +export function listMSTeamsDirectoryPeersLive( + ...args: Parameters +): ReturnType { + return listMSTeamsDirectoryPeersLiveImpl(...args); +} + +export const msteamsOutbound: MSTeamsOutbound = { ...msteamsOutboundImpl }; + +export function probeMSTeams(...args: Parameters): ReturnType { + return probeMSTeamsImpl(...args); +} + +export function sendAdaptiveCardMSTeams( + ...args: Parameters +): ReturnType { + return sendAdaptiveCardMSTeamsImpl(...args); +} + +export function sendMessageMSTeams( + ...args: Parameters +): ReturnType { + return sendMessageMSTeamsImpl(...args); +} diff --git a/extensions/signal/src/channel.runtime.ts b/extensions/signal/src/channel.runtime.ts index 0403246478f..de908d212b7 100644 --- a/extensions/signal/src/channel.runtime.ts +++ b/extensions/signal/src/channel.runtime.ts @@ -1 +1,5 @@ -export { signalSetupWizard } from "./setup-surface.js"; +import { signalSetupWizard as signalSetupWizardImpl } from "./setup-surface.js"; + +type SignalSetupWizard = typeof import("./setup-surface.js").signalSetupWizard; + +export const signalSetupWizard: SignalSetupWizard = { ...signalSetupWizardImpl }; diff --git a/extensions/slack/src/channel.runtime.ts b/extensions/slack/src/channel.runtime.ts index eefcc2c6215..6dfe5bed8fe 100644 --- a/extensions/slack/src/channel.runtime.ts +++ b/extensions/slack/src/channel.runtime.ts @@ -1 +1,5 @@ -export { slackSetupWizard } from "./setup-surface.js"; +import { slackSetupWizard as slackSetupWizardImpl } from "./setup-surface.js"; + +type SlackSetupWizard = typeof import("./setup-surface.js").slackSetupWizard; + +export const slackSetupWizard: SlackSetupWizard = { ...slackSetupWizardImpl }; diff --git a/extensions/slack/src/channel.ts b/extensions/slack/src/channel.ts index 2149f22ec60..bafc5fc8c91 100644 --- a/extensions/slack/src/channel.ts +++ b/extensions/slack/src/channel.ts @@ -25,6 +25,7 @@ import { type ChannelPlugin, type OpenClawConfig, } from "openclaw/plugin-sdk/slack"; +import type { SlackActionContext } from "../../../src/agents/tools/slack-actions.js"; import { createSlackActions } from "../../../src/channels/plugins/slack.actions.js"; import { buildPassiveProbedChannelStatusSummary } from "../../shared/channel-status-summary.js"; import { @@ -489,9 +490,7 @@ export const slackPlugin: ChannelPlugin = { await getSlackRuntime().channel.slack.handleSlackAction( action, cfg as OpenClawConfig, - toolContext as Parameters< - ReturnType["channel"]["slack"]["handleSlackAction"] - >[2], + toolContext as SlackActionContext | undefined, ), }), setup: slackSetupAdapter, diff --git a/extensions/whatsapp/src/channel.runtime.ts b/extensions/whatsapp/src/channel.runtime.ts index dbe5965a25d..de2203db2ad 100644 --- a/extensions/whatsapp/src/channel.runtime.ts +++ b/extensions/whatsapp/src/channel.runtime.ts @@ -1,18 +1,73 @@ -export { getActiveWebListener } from "./active-listener.js"; -export { - getWebAuthAgeMs, - logWebSelfId, - logoutWeb, - readWebSelfId, - webAuthExists, -} from "./auth-store.js"; -export { loginWeb } from "./login.js"; -export { startWebLoginWithQr, waitForWebLogin } from "./login-qr.js"; -export { whatsappSetupWizard } from "./setup-surface.js"; import { monitorWebChannel as monitorWebChannelImpl } from "openclaw/plugin-sdk/whatsapp"; +import { getActiveWebListener as getActiveWebListenerImpl } from "./active-listener.js"; +import { + getWebAuthAgeMs as getWebAuthAgeMsImpl, + logWebSelfId as logWebSelfIdImpl, + logoutWeb as logoutWebImpl, + readWebSelfId as readWebSelfIdImpl, + webAuthExists as webAuthExistsImpl, +} from "./auth-store.js"; +import { + startWebLoginWithQr as startWebLoginWithQrImpl, + waitForWebLogin as waitForWebLoginImpl, +} from "./login-qr.js"; +import { loginWeb as loginWebImpl } from "./login.js"; +import { whatsappSetupWizard as whatsappSetupWizardImpl } from "./setup-surface.js"; +type GetActiveWebListener = typeof import("./active-listener.js").getActiveWebListener; +type GetWebAuthAgeMs = typeof import("./auth-store.js").getWebAuthAgeMs; +type LogWebSelfId = typeof import("./auth-store.js").logWebSelfId; +type LogoutWeb = typeof import("./auth-store.js").logoutWeb; +type ReadWebSelfId = typeof import("./auth-store.js").readWebSelfId; +type WebAuthExists = typeof import("./auth-store.js").webAuthExists; +type LoginWeb = typeof import("./login.js").loginWeb; +type StartWebLoginWithQr = typeof import("./login-qr.js").startWebLoginWithQr; +type WaitForWebLogin = typeof import("./login-qr.js").waitForWebLogin; +type WhatsAppSetupWizard = typeof import("./setup-surface.js").whatsappSetupWizard; type MonitorWebChannel = typeof import("openclaw/plugin-sdk/whatsapp").monitorWebChannel; +export function getActiveWebListener( + ...args: Parameters +): ReturnType { + return getActiveWebListenerImpl(...args); +} + +export function getWebAuthAgeMs(...args: Parameters): ReturnType { + return getWebAuthAgeMsImpl(...args); +} + +export function logWebSelfId(...args: Parameters): ReturnType { + return logWebSelfIdImpl(...args); +} + +export function logoutWeb(...args: Parameters): ReturnType { + return logoutWebImpl(...args); +} + +export function readWebSelfId(...args: Parameters): ReturnType { + return readWebSelfIdImpl(...args); +} + +export function webAuthExists(...args: Parameters): ReturnType { + return webAuthExistsImpl(...args); +} + +export function loginWeb(...args: Parameters): ReturnType { + return loginWebImpl(...args); +} + +export function startWebLoginWithQr( + ...args: Parameters +): ReturnType { + return startWebLoginWithQrImpl(...args); +} + +export function waitForWebLogin(...args: Parameters): ReturnType { + return waitForWebLoginImpl(...args); +} + +export const whatsappSetupWizard: WhatsAppSetupWizard = { ...whatsappSetupWizardImpl }; + export async function monitorWebChannel( ...args: Parameters ): ReturnType { diff --git a/extensions/zalo/src/actions.runtime.ts b/extensions/zalo/src/actions.runtime.ts index a9616ce64a5..d463edc5b24 100644 --- a/extensions/zalo/src/actions.runtime.ts +++ b/extensions/zalo/src/actions.runtime.ts @@ -1 +1,7 @@ -export { sendMessageZalo } from "./send.js"; +import { sendMessageZalo as sendMessageZaloImpl } from "./send.js"; + +type SendMessageZalo = typeof import("./send.js").sendMessageZalo; + +export function sendMessageZalo(...args: Parameters): ReturnType { + return sendMessageZaloImpl(...args); +} diff --git a/src/cli/deps.test.ts b/src/cli/deps.test.ts index 8dbc8539cff..dff1a082296 100644 --- a/src/cli/deps.test.ts +++ b/src/cli/deps.test.ts @@ -21,32 +21,32 @@ const sendFns = vi.hoisted(() => ({ vi.mock("./send-runtime/whatsapp.js", () => { moduleLoads.whatsapp(); - return { sendMessageWhatsApp: sendFns.whatsapp }; + return { runtimeSend: { sendMessage: sendFns.whatsapp } }; }); vi.mock("./send-runtime/telegram.js", () => { moduleLoads.telegram(); - return { sendMessageTelegram: sendFns.telegram }; + return { runtimeSend: { sendMessage: sendFns.telegram } }; }); vi.mock("./send-runtime/discord.js", () => { moduleLoads.discord(); - return { sendMessageDiscord: sendFns.discord }; + return { runtimeSend: { sendMessage: sendFns.discord } }; }); vi.mock("./send-runtime/slack.js", () => { moduleLoads.slack(); - return { sendMessageSlack: sendFns.slack }; + return { runtimeSend: { sendMessage: sendFns.slack } }; }); vi.mock("./send-runtime/signal.js", () => { moduleLoads.signal(); - return { sendMessageSignal: sendFns.signal }; + return { runtimeSend: { sendMessage: sendFns.signal } }; }); vi.mock("./send-runtime/imessage.js", () => { moduleLoads.imessage(); - return { sendMessageIMessage: sendFns.imessage }; + return { runtimeSend: { sendMessage: sendFns.imessage } }; }); describe("createDefaultDeps", () => { diff --git a/src/cli/deps.ts b/src/cli/deps.ts index 908da8cd265..9996c155288 100644 --- a/src/cli/deps.ts +++ b/src/cli/deps.ts @@ -6,9 +6,15 @@ import { createOutboundSendDepsFromCliSource } from "./outbound-send-mapping.js" * Values are proxy functions that dynamically import the real module on first use. */ export type CliDeps = { [channelId: string]: unknown }; +type RuntimeSend = { + sendMessage: (...args: unknown[]) => Promise; +}; +type RuntimeSendModule = { + runtimeSend: RuntimeSend; +}; // Per-channel module caches for lazy loading. -const senderCache = new Map>>(); +const senderCache = new Map>(); /** * Create a lazy-loading send function proxy for a channel. @@ -16,18 +22,16 @@ const senderCache = new Map>>(); */ function createLazySender( channelId: string, - loader: () => Promise>, - exportName: string, + loader: () => Promise, ): (...args: unknown[]) => Promise { return async (...args: unknown[]) => { let cached = senderCache.get(channelId); if (!cached) { - cached = loader(); + cached = loader().then(({ runtimeSend }) => runtimeSend); senderCache.set(channelId, cached); } - const mod = await cached; - const fn = mod[exportName] as (...a: unknown[]) => Promise; - return await fn(...args); + const runtimeSend = await cached; + return await runtimeSend.sendMessage(...args); }; } @@ -35,33 +39,27 @@ export function createDefaultDeps(): CliDeps { return { whatsapp: createLazySender( "whatsapp", - () => import("./send-runtime/whatsapp.js") as Promise>, - "sendMessageWhatsApp", + () => import("./send-runtime/whatsapp.js") as Promise, ), telegram: createLazySender( "telegram", - () => import("./send-runtime/telegram.js") as Promise>, - "sendMessageTelegram", + () => import("./send-runtime/telegram.js") as Promise, ), discord: createLazySender( "discord", - () => import("./send-runtime/discord.js") as Promise>, - "sendMessageDiscord", + () => import("./send-runtime/discord.js") as Promise, ), slack: createLazySender( "slack", - () => import("./send-runtime/slack.js") as Promise>, - "sendMessageSlack", + () => import("./send-runtime/slack.js") as Promise, ), signal: createLazySender( "signal", - () => import("./send-runtime/signal.js") as Promise>, - "sendMessageSignal", + () => import("./send-runtime/signal.js") as Promise, ), imessage: createLazySender( "imessage", - () => import("./send-runtime/imessage.js") as Promise>, - "sendMessageIMessage", + () => import("./send-runtime/imessage.js") as Promise, ), }; } diff --git a/src/cli/send-runtime/discord.ts b/src/cli/send-runtime/discord.ts index 13e8293085b..768653752b6 100644 --- a/src/cli/send-runtime/discord.ts +++ b/src/cli/send-runtime/discord.ts @@ -1,9 +1,9 @@ import { sendMessageDiscord as sendMessageDiscordImpl } from "../../plugin-sdk/discord.js"; -type SendMessageDiscord = typeof import("../../plugin-sdk/discord.js").sendMessageDiscord; +type RuntimeSend = { + sendMessage: typeof import("../../plugin-sdk/discord.js").sendMessageDiscord; +}; -export async function sendMessageDiscord( - ...args: Parameters -): ReturnType { - return await sendMessageDiscordImpl(...args); -} +export const runtimeSend = { + sendMessage: sendMessageDiscordImpl, +} satisfies RuntimeSend; diff --git a/src/cli/send-runtime/imessage.ts b/src/cli/send-runtime/imessage.ts index eb5263a8b53..cdc91c0be74 100644 --- a/src/cli/send-runtime/imessage.ts +++ b/src/cli/send-runtime/imessage.ts @@ -1,9 +1,9 @@ import { sendMessageIMessage as sendMessageIMessageImpl } from "../../plugin-sdk/imessage.js"; -type SendMessageIMessage = typeof import("../../plugin-sdk/imessage.js").sendMessageIMessage; +type RuntimeSend = { + sendMessage: typeof import("../../plugin-sdk/imessage.js").sendMessageIMessage; +}; -export async function sendMessageIMessage( - ...args: Parameters -): ReturnType { - return await sendMessageIMessageImpl(...args); -} +export const runtimeSend = { + sendMessage: sendMessageIMessageImpl, +} satisfies RuntimeSend; diff --git a/src/cli/send-runtime/signal.ts b/src/cli/send-runtime/signal.ts index a1e72eb1200..151f13cc351 100644 --- a/src/cli/send-runtime/signal.ts +++ b/src/cli/send-runtime/signal.ts @@ -1,9 +1,9 @@ import { sendMessageSignal as sendMessageSignalImpl } from "../../plugin-sdk/signal.js"; -type SendMessageSignal = typeof import("../../plugin-sdk/signal.js").sendMessageSignal; +type RuntimeSend = { + sendMessage: typeof import("../../plugin-sdk/signal.js").sendMessageSignal; +}; -export async function sendMessageSignal( - ...args: Parameters -): ReturnType { - return await sendMessageSignalImpl(...args); -} +export const runtimeSend = { + sendMessage: sendMessageSignalImpl, +} satisfies RuntimeSend; diff --git a/src/cli/send-runtime/slack.ts b/src/cli/send-runtime/slack.ts index 3bef60a98c2..354186cd128 100644 --- a/src/cli/send-runtime/slack.ts +++ b/src/cli/send-runtime/slack.ts @@ -1,9 +1,9 @@ import { sendMessageSlack as sendMessageSlackImpl } from "../../plugin-sdk/slack.js"; -type SendMessageSlack = typeof import("../../plugin-sdk/slack.js").sendMessageSlack; +type RuntimeSend = { + sendMessage: typeof import("../../plugin-sdk/slack.js").sendMessageSlack; +}; -export async function sendMessageSlack( - ...args: Parameters -): ReturnType { - return await sendMessageSlackImpl(...args); -} +export const runtimeSend = { + sendMessage: sendMessageSlackImpl, +} satisfies RuntimeSend; diff --git a/src/cli/send-runtime/telegram.ts b/src/cli/send-runtime/telegram.ts index 3c384baa853..09d5e3e9b19 100644 --- a/src/cli/send-runtime/telegram.ts +++ b/src/cli/send-runtime/telegram.ts @@ -1,9 +1,9 @@ import { sendMessageTelegram as sendMessageTelegramImpl } from "../../plugin-sdk/telegram.js"; -type SendMessageTelegram = typeof import("../../plugin-sdk/telegram.js").sendMessageTelegram; +type RuntimeSend = { + sendMessage: typeof import("../../plugin-sdk/telegram.js").sendMessageTelegram; +}; -export async function sendMessageTelegram( - ...args: Parameters -): ReturnType { - return await sendMessageTelegramImpl(...args); -} +export const runtimeSend = { + sendMessage: sendMessageTelegramImpl, +} satisfies RuntimeSend; diff --git a/src/cli/send-runtime/whatsapp.ts b/src/cli/send-runtime/whatsapp.ts index f8b33db58c1..49f0e50baa6 100644 --- a/src/cli/send-runtime/whatsapp.ts +++ b/src/cli/send-runtime/whatsapp.ts @@ -1,9 +1,9 @@ import { sendMessageWhatsApp as sendMessageWhatsAppImpl } from "../../plugin-sdk/whatsapp.js"; -type SendMessageWhatsApp = typeof import("../../plugin-sdk/whatsapp.js").sendMessageWhatsApp; +type RuntimeSend = { + sendMessage: typeof import("../../plugin-sdk/whatsapp.js").sendMessageWhatsApp; +}; -export async function sendMessageWhatsApp( - ...args: Parameters -): ReturnType { - return await sendMessageWhatsAppImpl(...args); -} +export const runtimeSend = { + sendMessage: sendMessageWhatsAppImpl, +} satisfies RuntimeSend; diff --git a/src/commands/status.scan.deps.runtime.ts b/src/commands/status.scan.deps.runtime.ts index b9838d2176f..ce318085541 100644 --- a/src/commands/status.scan.deps.runtime.ts +++ b/src/commands/status.scan.deps.runtime.ts @@ -1,2 +1,34 @@ -export { getTailnetHostname } from "../infra/tailscale.js"; -export { getMemorySearchManager } from "../memory/index.js"; +import type { OpenClawConfig } from "../config/config.js"; +import { getTailnetHostname } from "../infra/tailscale.js"; +import { getMemorySearchManager as getMemorySearchManagerImpl } from "../memory/index.js"; +import type { MemoryProviderStatus } from "../memory/types.js"; + +export { getTailnetHostname }; + +type StatusMemoryManager = { + probeVectorAvailability(): Promise; + status(): MemoryProviderStatus; + close?(): Promise; +}; + +export async function getMemorySearchManager(params: { + cfg: OpenClawConfig; + agentId: string; + purpose: "status"; +}): Promise<{ manager: StatusMemoryManager | null }> { + const { manager } = await getMemorySearchManagerImpl(params); + if (!manager) { + return { manager: null }; + } + return { + manager: { + async probeVectorAvailability() { + await manager.probeVectorAvailability(); + }, + status() { + return manager.status(); + }, + close: manager.close ? async () => await manager.close?.() : undefined, + }, + }; +} diff --git a/src/config/schema.shared.test.ts b/src/config/schema.shared.test.ts index 48820fbf029..d566bfd55f5 100644 --- a/src/config/schema.shared.test.ts +++ b/src/config/schema.shared.test.ts @@ -21,7 +21,7 @@ describe("schema.shared", () => { it("treats branch schemas as having children", () => { expect( schemaHasChildren({ - oneOf: [{ type: "string" }, { properties: { token: { type: "string" } } }], + oneOf: [{}, { properties: { token: {} } }], }), ).toBe(true); }); diff --git a/src/plugins/contracts/auth-choice.contract.test.ts b/src/plugins/contracts/auth-choice.contract.test.ts index 33e9be99479..ac2069b0d75 100644 --- a/src/plugins/contracts/auth-choice.contract.test.ts +++ b/src/plugins/contracts/auth-choice.contract.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { clearRuntimeAuthProfileStoreSnapshots } from "../../agents/auth-profiles/store.js"; import { createAuthTestLifecycle, createExitThrowingRuntime, @@ -7,7 +6,8 @@ import { readAuthProfilesForAgent, requireOpenClawAgentDir, setupAuthTestEnv, -} from "../../commands/test-wizard-helpers.js"; +} from "../../../test/helpers/auth-wizard.js"; +import { clearRuntimeAuthProfileStoreSnapshots } from "../../agents/auth-profiles/store.js"; import { applyAuthChoiceLoadedPluginProvider } from "../../plugins/provider-auth-choice.js"; import { buildProviderPluginMethodChoice } from "../provider-wizard.js"; import { requireProviderContractProvider, uniqueProviderContractProviders } from "./registry.js"; @@ -27,7 +27,6 @@ const resolveProviderPluginChoiceMock = vi.hoisted(() => vi.fn vi.fn(async () => {}), ); -const resolvePreferredProviderPluginProvidersMock = vi.hoisted(() => vi.fn()); vi.mock("../../../extensions/qwen-portal-auth/oauth.js", () => ({ loginQwenPortalOAuth: loginQwenPortalOAuthMock, @@ -43,15 +42,6 @@ vi.mock("../../plugins/provider-auth-choice.runtime.js", () => ({ runProviderModelSelectedHook: runProviderModelSelectedHookMock, })); -vi.mock("../../plugins/providers.js", async () => { - const actual = await vi.importActual("../../plugins/providers.js"); - return { - ...actual, - resolvePluginProviders: (...args: unknown[]) => - resolvePreferredProviderPluginProvidersMock(...args), - }; -}); - const { resolvePreferredProviderForAuthChoice } = await import("../../plugins/provider-auth-choice-preference.js"); @@ -84,8 +74,24 @@ describe("provider auth-choice contract", () => { } beforeEach(() => { - resolvePreferredProviderPluginProvidersMock.mockReset(); - resolvePreferredProviderPluginProvidersMock.mockReturnValue(uniqueProviderContractProviders); + resolvePluginProvidersMock.mockReset(); + resolvePluginProvidersMock.mockReturnValue(uniqueProviderContractProviders); + resolveProviderPluginChoiceMock.mockReset(); + resolveProviderPluginChoiceMock.mockImplementation(({ providers, choice }) => { + const provider = providers.find((entry) => + entry.auth.some( + (method) => buildProviderPluginMethodChoice(entry.id, method.id) === choice, + ), + ); + if (!provider) { + return null; + } + const method = + provider.auth.find( + (entry) => buildProviderPluginMethodChoice(provider.id, entry.id) === choice, + ) ?? null; + return method ? { provider, method } : null; + }); }); afterEach(async () => { @@ -117,18 +123,18 @@ describe("provider auth-choice contract", () => { }); for (const scenario of pluginFallbackScenarios) { - resolvePreferredProviderPluginProvidersMock.mockClear(); + resolvePluginProvidersMock.mockClear(); await expect( resolvePreferredProviderForAuthChoice({ choice: scenario.authChoice }), ).resolves.toBe(scenario.expectedProvider); - expect(resolvePreferredProviderPluginProvidersMock).toHaveBeenCalled(); + expect(resolvePluginProvidersMock).toHaveBeenCalled(); } - resolvePreferredProviderPluginProvidersMock.mockClear(); + resolvePluginProvidersMock.mockClear(); await expect(resolvePreferredProviderForAuthChoice({ choice: "unknown" })).resolves.toBe( undefined, ); - expect(resolvePreferredProviderPluginProvidersMock).toHaveBeenCalled(); + expect(resolvePluginProvidersMock).toHaveBeenCalled(); }); it("applies qwen portal auth choices through the shared plugin-provider path", async () => { diff --git a/src/plugins/contracts/runtime.contract.test.ts b/src/plugins/contracts/runtime.contract.test.ts index 87acf1f8a13..15adc59e130 100644 --- a/src/plugins/contracts/runtime.contract.test.ts +++ b/src/plugins/contracts/runtime.contract.test.ts @@ -518,7 +518,7 @@ describe("provider runtime contract", () => { }); it("falls back to legacy pi auth tokens for usage auth", async () => { - const provider = requireProvider("zai"); + const provider = requireProviderContractProvider("zai"); const home = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-zai-contract-")); await fs.mkdir(path.join(home, ".pi", "agent"), { recursive: true }); await fs.writeFile( diff --git a/src/plugins/runtime/runtime-discord-ops.runtime.ts b/src/plugins/runtime/runtime-discord-ops.runtime.ts index 6a9d9429713..182e9c75d41 100644 --- a/src/plugins/runtime/runtime-discord-ops.runtime.ts +++ b/src/plugins/runtime/runtime-discord-ops.runtime.ts @@ -19,132 +19,48 @@ import { sendTypingDiscord as sendTypingDiscordImpl, unpinMessageDiscord as unpinMessageDiscordImpl, } from "../../../extensions/discord/src/send.js"; +import type { PluginRuntimeChannel } from "./types-channel.js"; -type AuditDiscordChannelPermissions = - typeof import("../../../extensions/discord/src/audit.js").auditDiscordChannelPermissions; -type ListDiscordDirectoryGroupsLive = - typeof import("../../../extensions/discord/src/directory-live.js").listDiscordDirectoryGroupsLive; -type ListDiscordDirectoryPeersLive = - typeof import("../../../extensions/discord/src/directory-live.js").listDiscordDirectoryPeersLive; -type MonitorDiscordProvider = - typeof import("../../../extensions/discord/src/monitor.js").monitorDiscordProvider; -type ProbeDiscord = typeof import("../../../extensions/discord/src/probe.js").probeDiscord; -type ResolveDiscordChannelAllowlist = - typeof import("../../../extensions/discord/src/resolve-channels.js").resolveDiscordChannelAllowlist; -type ResolveDiscordUserAllowlist = - typeof import("../../../extensions/discord/src/resolve-users.js").resolveDiscordUserAllowlist; -type CreateThreadDiscord = - typeof import("../../../extensions/discord/src/send.js").createThreadDiscord; -type DeleteMessageDiscord = - typeof import("../../../extensions/discord/src/send.js").deleteMessageDiscord; -type EditChannelDiscord = - typeof import("../../../extensions/discord/src/send.js").editChannelDiscord; -type EditMessageDiscord = - typeof import("../../../extensions/discord/src/send.js").editMessageDiscord; -type PinMessageDiscord = typeof import("../../../extensions/discord/src/send.js").pinMessageDiscord; -type SendDiscordComponentMessage = - typeof import("../../../extensions/discord/src/send.js").sendDiscordComponentMessage; -type SendMessageDiscord = - typeof import("../../../extensions/discord/src/send.js").sendMessageDiscord; -type SendPollDiscord = typeof import("../../../extensions/discord/src/send.js").sendPollDiscord; -type SendTypingDiscord = typeof import("../../../extensions/discord/src/send.js").sendTypingDiscord; -type UnpinMessageDiscord = - typeof import("../../../extensions/discord/src/send.js").unpinMessageDiscord; +type RuntimeDiscordOps = Pick< + PluginRuntimeChannel["discord"], + | "auditChannelPermissions" + | "listDirectoryGroupsLive" + | "listDirectoryPeersLive" + | "probeDiscord" + | "resolveChannelAllowlist" + | "resolveUserAllowlist" + | "sendComponentMessage" + | "sendMessageDiscord" + | "sendPollDiscord" + | "monitorDiscordProvider" +> & { + typing: Pick; + conversationActions: Pick< + PluginRuntimeChannel["discord"]["conversationActions"], + "editMessage" | "deleteMessage" | "pinMessage" | "unpinMessage" | "createThread" | "editChannel" + >; +}; -export function auditDiscordChannelPermissions( - ...args: Parameters -): ReturnType { - return auditDiscordChannelPermissionsImpl(...args); -} - -export function listDiscordDirectoryGroupsLive( - ...args: Parameters -): ReturnType { - return listDiscordDirectoryGroupsLiveImpl(...args); -} - -export function listDiscordDirectoryPeersLive( - ...args: Parameters -): ReturnType { - return listDiscordDirectoryPeersLiveImpl(...args); -} - -export function monitorDiscordProvider( - ...args: Parameters -): ReturnType { - return monitorDiscordProviderImpl(...args); -} - -export function probeDiscord(...args: Parameters): ReturnType { - return probeDiscordImpl(...args); -} - -export function resolveDiscordChannelAllowlist( - ...args: Parameters -): ReturnType { - return resolveDiscordChannelAllowlistImpl(...args); -} - -export function resolveDiscordUserAllowlist( - ...args: Parameters -): ReturnType { - return resolveDiscordUserAllowlistImpl(...args); -} - -export function createThreadDiscord( - ...args: Parameters -): ReturnType { - return createThreadDiscordImpl(...args); -} - -export function deleteMessageDiscord( - ...args: Parameters -): ReturnType { - return deleteMessageDiscordImpl(...args); -} - -export function editChannelDiscord( - ...args: Parameters -): ReturnType { - return editChannelDiscordImpl(...args); -} - -export function editMessageDiscord( - ...args: Parameters -): ReturnType { - return editMessageDiscordImpl(...args); -} - -export function pinMessageDiscord( - ...args: Parameters -): ReturnType { - return pinMessageDiscordImpl(...args); -} - -export function sendDiscordComponentMessage( - ...args: Parameters -): ReturnType { - return sendDiscordComponentMessageImpl(...args); -} - -export function sendMessageDiscord( - ...args: Parameters -): ReturnType { - return sendMessageDiscordImpl(...args); -} - -export function sendPollDiscord(...args: Parameters): ReturnType { - return sendPollDiscordImpl(...args); -} - -export function sendTypingDiscord( - ...args: Parameters -): ReturnType { - return sendTypingDiscordImpl(...args); -} - -export function unpinMessageDiscord( - ...args: Parameters -): ReturnType { - return unpinMessageDiscordImpl(...args); -} +export const runtimeDiscordOps = { + auditChannelPermissions: auditDiscordChannelPermissionsImpl, + listDirectoryGroupsLive: listDiscordDirectoryGroupsLiveImpl, + listDirectoryPeersLive: listDiscordDirectoryPeersLiveImpl, + probeDiscord: probeDiscordImpl, + resolveChannelAllowlist: resolveDiscordChannelAllowlistImpl, + resolveUserAllowlist: resolveDiscordUserAllowlistImpl, + sendComponentMessage: sendDiscordComponentMessageImpl, + sendMessageDiscord: sendMessageDiscordImpl, + sendPollDiscord: sendPollDiscordImpl, + monitorDiscordProvider: monitorDiscordProviderImpl, + typing: { + pulse: sendTypingDiscordImpl, + }, + conversationActions: { + editMessage: editMessageDiscordImpl, + deleteMessage: deleteMessageDiscordImpl, + pinMessage: pinMessageDiscordImpl, + unpinMessage: unpinMessageDiscordImpl, + createThread: createThreadDiscordImpl, + editChannel: editChannelDiscordImpl, + }, +} satisfies RuntimeDiscordOps; diff --git a/src/plugins/runtime/runtime-discord.ts b/src/plugins/runtime/runtime-discord.ts index ae302ad0e5f..033c1631828 100644 --- a/src/plugins/runtime/runtime-discord.ts +++ b/src/plugins/runtime/runtime-discord.ts @@ -12,116 +12,119 @@ import { import { createDiscordTypingLease } from "./runtime-discord-typing.js"; import type { PluginRuntimeChannel } from "./types-channel.js"; -let runtimeDiscordOpsPromise: Promise | null = - null; +type RuntimeDiscordOps = typeof import("./runtime-discord-ops.runtime.js").runtimeDiscordOps; + +let runtimeDiscordOpsPromise: Promise | null = null; function loadRuntimeDiscordOps() { - runtimeDiscordOpsPromise ??= import("./runtime-discord-ops.runtime.js"); + runtimeDiscordOpsPromise ??= import("./runtime-discord-ops.runtime.js").then( + ({ runtimeDiscordOps }) => runtimeDiscordOps, + ); return runtimeDiscordOpsPromise; } const auditChannelPermissionsLazy: PluginRuntimeChannel["discord"]["auditChannelPermissions"] = async (...args) => { - const { auditDiscordChannelPermissions } = await loadRuntimeDiscordOps(); - return auditDiscordChannelPermissions(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.auditChannelPermissions(...args); }; const listDirectoryGroupsLiveLazy: PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"] = async (...args) => { - const { listDiscordDirectoryGroupsLive } = await loadRuntimeDiscordOps(); - return listDiscordDirectoryGroupsLive(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.listDirectoryGroupsLive(...args); }; const listDirectoryPeersLiveLazy: PluginRuntimeChannel["discord"]["listDirectoryPeersLive"] = async (...args) => { - const { listDiscordDirectoryPeersLive } = await loadRuntimeDiscordOps(); - return listDiscordDirectoryPeersLive(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.listDirectoryPeersLive(...args); }; const probeDiscordLazy: PluginRuntimeChannel["discord"]["probeDiscord"] = async (...args) => { - const { probeDiscord } = await loadRuntimeDiscordOps(); - return probeDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.probeDiscord(...args); }; const resolveChannelAllowlistLazy: PluginRuntimeChannel["discord"]["resolveChannelAllowlist"] = async (...args) => { - const { resolveDiscordChannelAllowlist } = await loadRuntimeDiscordOps(); - return resolveDiscordChannelAllowlist(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.resolveChannelAllowlist(...args); }; const resolveUserAllowlistLazy: PluginRuntimeChannel["discord"]["resolveUserAllowlist"] = async ( ...args ) => { - const { resolveDiscordUserAllowlist } = await loadRuntimeDiscordOps(); - return resolveDiscordUserAllowlist(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.resolveUserAllowlist(...args); }; const sendComponentMessageLazy: PluginRuntimeChannel["discord"]["sendComponentMessage"] = async ( ...args ) => { - const { sendDiscordComponentMessage } = await loadRuntimeDiscordOps(); - return sendDiscordComponentMessage(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.sendComponentMessage(...args); }; const sendMessageDiscordLazy: PluginRuntimeChannel["discord"]["sendMessageDiscord"] = async ( ...args ) => { - const { sendMessageDiscord } = await loadRuntimeDiscordOps(); - return sendMessageDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.sendMessageDiscord(...args); }; const sendPollDiscordLazy: PluginRuntimeChannel["discord"]["sendPollDiscord"] = async (...args) => { - const { sendPollDiscord } = await loadRuntimeDiscordOps(); - return sendPollDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.sendPollDiscord(...args); }; const monitorDiscordProviderLazy: PluginRuntimeChannel["discord"]["monitorDiscordProvider"] = async (...args) => { - const { monitorDiscordProvider } = await loadRuntimeDiscordOps(); - return monitorDiscordProvider(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.monitorDiscordProvider(...args); }; const sendTypingDiscordLazy: PluginRuntimeChannel["discord"]["typing"]["pulse"] = async ( ...args ) => { - const { sendTypingDiscord } = await loadRuntimeDiscordOps(); - return sendTypingDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.typing.pulse(...args); }; const editMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"] = async (...args) => { - const { editMessageDiscord } = await loadRuntimeDiscordOps(); - return editMessageDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.conversationActions.editMessage(...args); }; const deleteMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"] = async (...args) => { - const { deleteMessageDiscord } = await loadRuntimeDiscordOps(); - return deleteMessageDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.conversationActions.deleteMessage(...args); }; const pinMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"] = async (...args) => { - const { pinMessageDiscord } = await loadRuntimeDiscordOps(); - return pinMessageDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.conversationActions.pinMessage(...args); }; const unpinMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"] = async (...args) => { - const { unpinMessageDiscord } = await loadRuntimeDiscordOps(); - return unpinMessageDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.conversationActions.unpinMessage(...args); }; const createThreadDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["createThread"] = async (...args) => { - const { createThreadDiscord } = await loadRuntimeDiscordOps(); - return createThreadDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.conversationActions.createThread(...args); }; const editChannelDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"] = async (...args) => { - const { editChannelDiscord } = await loadRuntimeDiscordOps(); - return editChannelDiscord(...args); + const runtimeDiscordOps = await loadRuntimeDiscordOps(); + return runtimeDiscordOps.conversationActions.editChannel(...args); }; export function createRuntimeDiscord(): PluginRuntimeChannel["discord"] { diff --git a/src/plugins/runtime/runtime-slack-ops.runtime.ts b/src/plugins/runtime/runtime-slack-ops.runtime.ts index b01568bc491..4f4dc1aeda7 100644 --- a/src/plugins/runtime/runtime-slack-ops.runtime.ts +++ b/src/plugins/runtime/runtime-slack-ops.runtime.ts @@ -8,63 +8,27 @@ import { resolveSlackChannelAllowlist as resolveSlackChannelAllowlistImpl } from import { resolveSlackUserAllowlist as resolveSlackUserAllowlistImpl } from "../../../extensions/slack/src/resolve-users.js"; import { sendMessageSlack as sendMessageSlackImpl } from "../../../extensions/slack/src/send.js"; import { handleSlackAction as handleSlackActionImpl } from "../../agents/tools/slack-actions.js"; +import type { PluginRuntimeChannel } from "./types-channel.js"; -type ListSlackDirectoryGroupsLive = - typeof import("../../../extensions/slack/src/directory-live.js").listSlackDirectoryGroupsLive; -type ListSlackDirectoryPeersLive = - typeof import("../../../extensions/slack/src/directory-live.js").listSlackDirectoryPeersLive; -type MonitorSlackProvider = - typeof import("../../../extensions/slack/src/index.js").monitorSlackProvider; -type ProbeSlack = typeof import("../../../extensions/slack/src/probe.js").probeSlack; -type ResolveSlackChannelAllowlist = - typeof import("../../../extensions/slack/src/resolve-channels.js").resolveSlackChannelAllowlist; -type ResolveSlackUserAllowlist = - typeof import("../../../extensions/slack/src/resolve-users.js").resolveSlackUserAllowlist; -type SendMessageSlack = typeof import("../../../extensions/slack/src/send.js").sendMessageSlack; -type HandleSlackAction = typeof import("../../agents/tools/slack-actions.js").handleSlackAction; +type RuntimeSlackOps = Pick< + PluginRuntimeChannel["slack"], + | "listDirectoryGroupsLive" + | "listDirectoryPeersLive" + | "probeSlack" + | "resolveChannelAllowlist" + | "resolveUserAllowlist" + | "sendMessageSlack" + | "monitorSlackProvider" + | "handleSlackAction" +>; -export function listSlackDirectoryGroupsLive( - ...args: Parameters -): ReturnType { - return listSlackDirectoryGroupsLiveImpl(...args); -} - -export function listSlackDirectoryPeersLive( - ...args: Parameters -): ReturnType { - return listSlackDirectoryPeersLiveImpl(...args); -} - -export function monitorSlackProvider( - ...args: Parameters -): ReturnType { - return monitorSlackProviderImpl(...args); -} - -export function probeSlack(...args: Parameters): ReturnType { - return probeSlackImpl(...args); -} - -export function resolveSlackChannelAllowlist( - ...args: Parameters -): ReturnType { - return resolveSlackChannelAllowlistImpl(...args); -} - -export function resolveSlackUserAllowlist( - ...args: Parameters -): ReturnType { - return resolveSlackUserAllowlistImpl(...args); -} - -export function sendMessageSlack( - ...args: Parameters -): ReturnType { - return sendMessageSlackImpl(...args); -} - -export function handleSlackAction( - ...args: Parameters -): ReturnType { - return handleSlackActionImpl(...args); -} +export const runtimeSlackOps = { + listDirectoryGroupsLive: listSlackDirectoryGroupsLiveImpl, + listDirectoryPeersLive: listSlackDirectoryPeersLiveImpl, + probeSlack: probeSlackImpl, + resolveChannelAllowlist: resolveSlackChannelAllowlistImpl, + resolveUserAllowlist: resolveSlackUserAllowlistImpl, + sendMessageSlack: sendMessageSlackImpl, + monitorSlackProvider: monitorSlackProviderImpl, + handleSlackAction: handleSlackActionImpl, +} satisfies RuntimeSlackOps; diff --git a/src/plugins/runtime/runtime-slack.ts b/src/plugins/runtime/runtime-slack.ts index 9579aed4c1b..23d34a7e5f4 100644 --- a/src/plugins/runtime/runtime-slack.ts +++ b/src/plugins/runtime/runtime-slack.ts @@ -1,60 +1,64 @@ import type { PluginRuntimeChannel } from "./types-channel.js"; -let runtimeSlackOpsPromise: Promise | null = null; +type RuntimeSlackOps = typeof import("./runtime-slack-ops.runtime.js").runtimeSlackOps; + +let runtimeSlackOpsPromise: Promise | null = null; function loadRuntimeSlackOps() { - runtimeSlackOpsPromise ??= import("./runtime-slack-ops.runtime.js"); + runtimeSlackOpsPromise ??= import("./runtime-slack-ops.runtime.js").then( + ({ runtimeSlackOps }) => runtimeSlackOps, + ); return runtimeSlackOpsPromise; } const listDirectoryGroupsLiveLazy: PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"] = async (...args) => { - const { listSlackDirectoryGroupsLive } = await loadRuntimeSlackOps(); - return listSlackDirectoryGroupsLive(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.listDirectoryGroupsLive(...args); }; const listDirectoryPeersLiveLazy: PluginRuntimeChannel["slack"]["listDirectoryPeersLive"] = async ( ...args ) => { - const { listSlackDirectoryPeersLive } = await loadRuntimeSlackOps(); - return listSlackDirectoryPeersLive(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.listDirectoryPeersLive(...args); }; const probeSlackLazy: PluginRuntimeChannel["slack"]["probeSlack"] = async (...args) => { - const { probeSlack } = await loadRuntimeSlackOps(); - return probeSlack(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.probeSlack(...args); }; const resolveChannelAllowlistLazy: PluginRuntimeChannel["slack"]["resolveChannelAllowlist"] = async (...args) => { - const { resolveSlackChannelAllowlist } = await loadRuntimeSlackOps(); - return resolveSlackChannelAllowlist(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.resolveChannelAllowlist(...args); }; const resolveUserAllowlistLazy: PluginRuntimeChannel["slack"]["resolveUserAllowlist"] = async ( ...args ) => { - const { resolveSlackUserAllowlist } = await loadRuntimeSlackOps(); - return resolveSlackUserAllowlist(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.resolveUserAllowlist(...args); }; const sendMessageSlackLazy: PluginRuntimeChannel["slack"]["sendMessageSlack"] = async (...args) => { - const { sendMessageSlack } = await loadRuntimeSlackOps(); - return sendMessageSlack(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.sendMessageSlack(...args); }; const monitorSlackProviderLazy: PluginRuntimeChannel["slack"]["monitorSlackProvider"] = async ( ...args ) => { - const { monitorSlackProvider } = await loadRuntimeSlackOps(); - return monitorSlackProvider(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.monitorSlackProvider(...args); }; const handleSlackActionLazy: PluginRuntimeChannel["slack"]["handleSlackAction"] = async ( ...args ) => { - const { handleSlackAction } = await loadRuntimeSlackOps(); - return handleSlackAction(...args); + const runtimeSlackOps = await loadRuntimeSlackOps(); + return runtimeSlackOps.handleSlackAction(...args); }; export function createRuntimeSlack(): PluginRuntimeChannel["slack"] { diff --git a/src/plugins/runtime/runtime-telegram-ops.runtime.ts b/src/plugins/runtime/runtime-telegram-ops.runtime.ts index cc99abfb1c4..b8b915e6065 100644 --- a/src/plugins/runtime/runtime-telegram-ops.runtime.ts +++ b/src/plugins/runtime/runtime-telegram-ops.runtime.ts @@ -1,7 +1,4 @@ -import { - auditTelegramGroupMembership as auditTelegramGroupMembershipImpl, - collectTelegramUnmentionedGroupIds as collectTelegramUnmentionedGroupIdsImpl, -} from "../../../extensions/telegram/src/audit.js"; +import { auditTelegramGroupMembership as auditTelegramGroupMembershipImpl } from "../../../extensions/telegram/src/audit.js"; import { monitorTelegramProvider as monitorTelegramProviderImpl } from "../../../extensions/telegram/src/monitor.js"; import { probeTelegram as probeTelegramImpl } from "../../../extensions/telegram/src/probe.js"; import { @@ -15,113 +12,43 @@ import { sendTypingTelegram as sendTypingTelegramImpl, unpinMessageTelegram as unpinMessageTelegramImpl, } from "../../../extensions/telegram/src/send.js"; -import { resolveTelegramToken as resolveTelegramTokenImpl } from "../../../extensions/telegram/src/token.js"; +import type { PluginRuntimeChannel } from "./types-channel.js"; -type AuditTelegramGroupMembership = - typeof import("../../../extensions/telegram/src/audit.js").auditTelegramGroupMembership; -type CollectTelegramUnmentionedGroupIds = - typeof import("../../../extensions/telegram/src/audit.js").collectTelegramUnmentionedGroupIds; -type MonitorTelegramProvider = - typeof import("../../../extensions/telegram/src/monitor.js").monitorTelegramProvider; -type ProbeTelegram = typeof import("../../../extensions/telegram/src/probe.js").probeTelegram; -type DeleteMessageTelegram = - typeof import("../../../extensions/telegram/src/send.js").deleteMessageTelegram; -type EditMessageReplyMarkupTelegram = - typeof import("../../../extensions/telegram/src/send.js").editMessageReplyMarkupTelegram; -type EditMessageTelegram = - typeof import("../../../extensions/telegram/src/send.js").editMessageTelegram; -type PinMessageTelegram = - typeof import("../../../extensions/telegram/src/send.js").pinMessageTelegram; -type RenameForumTopicTelegram = - typeof import("../../../extensions/telegram/src/send.js").renameForumTopicTelegram; -type SendMessageTelegram = - typeof import("../../../extensions/telegram/src/send.js").sendMessageTelegram; -type SendPollTelegram = typeof import("../../../extensions/telegram/src/send.js").sendPollTelegram; -type SendTypingTelegram = - typeof import("../../../extensions/telegram/src/send.js").sendTypingTelegram; -type UnpinMessageTelegram = - typeof import("../../../extensions/telegram/src/send.js").unpinMessageTelegram; -type ResolveTelegramToken = - typeof import("../../../extensions/telegram/src/token.js").resolveTelegramToken; +type RuntimeTelegramOps = Pick< + PluginRuntimeChannel["telegram"], + | "auditGroupMembership" + | "probeTelegram" + | "sendMessageTelegram" + | "sendPollTelegram" + | "monitorTelegramProvider" +> & { + typing: Pick; + conversationActions: Pick< + PluginRuntimeChannel["telegram"]["conversationActions"], + | "editMessage" + | "editReplyMarkup" + | "deleteMessage" + | "renameTopic" + | "pinMessage" + | "unpinMessage" + >; +}; -export function auditTelegramGroupMembership( - ...args: Parameters -): ReturnType { - return auditTelegramGroupMembershipImpl(...args); -} - -export function collectTelegramUnmentionedGroupIds( - ...args: Parameters -): ReturnType { - return collectTelegramUnmentionedGroupIdsImpl(...args); -} - -export function monitorTelegramProvider( - ...args: Parameters -): ReturnType { - return monitorTelegramProviderImpl(...args); -} - -export function probeTelegram(...args: Parameters): ReturnType { - return probeTelegramImpl(...args); -} - -export function deleteMessageTelegram( - ...args: Parameters -): ReturnType { - return deleteMessageTelegramImpl(...args); -} - -export function editMessageReplyMarkupTelegram( - ...args: Parameters -): ReturnType { - return editMessageReplyMarkupTelegramImpl(...args); -} - -export function editMessageTelegram( - ...args: Parameters -): ReturnType { - return editMessageTelegramImpl(...args); -} - -export function pinMessageTelegram( - ...args: Parameters -): ReturnType { - return pinMessageTelegramImpl(...args); -} - -export function renameForumTopicTelegram( - ...args: Parameters -): ReturnType { - return renameForumTopicTelegramImpl(...args); -} - -export function sendMessageTelegram( - ...args: Parameters -): ReturnType { - return sendMessageTelegramImpl(...args); -} - -export function sendPollTelegram( - ...args: Parameters -): ReturnType { - return sendPollTelegramImpl(...args); -} - -export function sendTypingTelegram( - ...args: Parameters -): ReturnType { - return sendTypingTelegramImpl(...args); -} - -export function unpinMessageTelegram( - ...args: Parameters -): ReturnType { - return unpinMessageTelegramImpl(...args); -} - -export function resolveTelegramToken( - ...args: Parameters -): ReturnType { - return resolveTelegramTokenImpl(...args); -} +export const runtimeTelegramOps = { + auditGroupMembership: auditTelegramGroupMembershipImpl, + probeTelegram: probeTelegramImpl, + sendMessageTelegram: sendMessageTelegramImpl, + sendPollTelegram: sendPollTelegramImpl, + monitorTelegramProvider: monitorTelegramProviderImpl, + typing: { + pulse: sendTypingTelegramImpl, + }, + conversationActions: { + editMessage: editMessageTelegramImpl, + editReplyMarkup: editMessageReplyMarkupTelegramImpl, + deleteMessage: deleteMessageTelegramImpl, + renameTopic: renameForumTopicTelegramImpl, + pinMessage: pinMessageTelegramImpl, + unpinMessage: unpinMessageTelegramImpl, + }, +} satisfies RuntimeTelegramOps; diff --git a/src/plugins/runtime/runtime-telegram.ts b/src/plugins/runtime/runtime-telegram.ts index 22061a7e00d..d0d71d08c4e 100644 --- a/src/plugins/runtime/runtime-telegram.ts +++ b/src/plugins/runtime/runtime-telegram.ts @@ -8,87 +8,90 @@ import { resolveTelegramToken } from "../../../extensions/telegram/src/token.js" import { createTelegramTypingLease } from "./runtime-telegram-typing.js"; import type { PluginRuntimeChannel } from "./types-channel.js"; -let runtimeTelegramOpsPromise: Promise | null = - null; +type RuntimeTelegramOps = typeof import("./runtime-telegram-ops.runtime.js").runtimeTelegramOps; + +let runtimeTelegramOpsPromise: Promise | null = null; function loadRuntimeTelegramOps() { - runtimeTelegramOpsPromise ??= import("./runtime-telegram-ops.runtime.js"); + runtimeTelegramOpsPromise ??= import("./runtime-telegram-ops.runtime.js").then( + ({ runtimeTelegramOps }) => runtimeTelegramOps, + ); return runtimeTelegramOpsPromise; } const auditGroupMembershipLazy: PluginRuntimeChannel["telegram"]["auditGroupMembership"] = async ( ...args ) => { - const { auditTelegramGroupMembership } = await loadRuntimeTelegramOps(); - return auditTelegramGroupMembership(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.auditGroupMembership(...args); }; const probeTelegramLazy: PluginRuntimeChannel["telegram"]["probeTelegram"] = async (...args) => { - const { probeTelegram } = await loadRuntimeTelegramOps(); - return probeTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.probeTelegram(...args); }; const sendMessageTelegramLazy: PluginRuntimeChannel["telegram"]["sendMessageTelegram"] = async ( ...args ) => { - const { sendMessageTelegram } = await loadRuntimeTelegramOps(); - return sendMessageTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.sendMessageTelegram(...args); }; const sendPollTelegramLazy: PluginRuntimeChannel["telegram"]["sendPollTelegram"] = async ( ...args ) => { - const { sendPollTelegram } = await loadRuntimeTelegramOps(); - return sendPollTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.sendPollTelegram(...args); }; const monitorTelegramProviderLazy: PluginRuntimeChannel["telegram"]["monitorTelegramProvider"] = async (...args) => { - const { monitorTelegramProvider } = await loadRuntimeTelegramOps(); - return monitorTelegramProvider(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.monitorTelegramProvider(...args); }; const sendTypingTelegramLazy: PluginRuntimeChannel["telegram"]["typing"]["pulse"] = async ( ...args ) => { - const { sendTypingTelegram } = await loadRuntimeTelegramOps(); - return sendTypingTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.typing.pulse(...args); }; const editMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"] = async (...args) => { - const { editMessageTelegram } = await loadRuntimeTelegramOps(); - return editMessageTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.conversationActions.editMessage(...args); }; const editMessageReplyMarkupTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"] = async (...args) => { - const { editMessageReplyMarkupTelegram } = await loadRuntimeTelegramOps(); - return editMessageReplyMarkupTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.conversationActions.editReplyMarkup(...args); }; const deleteMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"] = async (...args) => { - const { deleteMessageTelegram } = await loadRuntimeTelegramOps(); - return deleteMessageTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.conversationActions.deleteMessage(...args); }; const renameForumTopicTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"] = async (...args) => { - const { renameForumTopicTelegram } = await loadRuntimeTelegramOps(); - return renameForumTopicTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.conversationActions.renameTopic(...args); }; const pinMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"] = async (...args) => { - const { pinMessageTelegram } = await loadRuntimeTelegramOps(); - return pinMessageTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.conversationActions.pinMessage(...args); }; const unpinMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"] = async (...args) => { - const { unpinMessageTelegram } = await loadRuntimeTelegramOps(); - return unpinMessageTelegram(...args); + const runtimeTelegramOps = await loadRuntimeTelegramOps(); + return runtimeTelegramOps.conversationActions.unpinMessage(...args); }; export function createRuntimeTelegram(): PluginRuntimeChannel["telegram"] { diff --git a/src/plugins/runtime/runtime-whatsapp-login.runtime.ts b/src/plugins/runtime/runtime-whatsapp-login.runtime.ts index 4d44c7c87f6..2760db7311d 100644 --- a/src/plugins/runtime/runtime-whatsapp-login.runtime.ts +++ b/src/plugins/runtime/runtime-whatsapp-login.runtime.ts @@ -1,7 +1,8 @@ import { loginWeb as loginWebImpl } from "../../../extensions/whatsapp/src/login.js"; +import type { PluginRuntime } from "./types.js"; -type LoginWeb = typeof import("../../../extensions/whatsapp/src/login.js").loginWeb; +type RuntimeWhatsAppLogin = Pick; -export function loginWeb(...args: Parameters): ReturnType { - return loginWebImpl(...args); -} +export const runtimeWhatsAppLogin = { + loginWeb: loginWebImpl, +} satisfies RuntimeWhatsAppLogin; diff --git a/src/plugins/runtime/runtime-whatsapp-outbound.runtime.ts b/src/plugins/runtime/runtime-whatsapp-outbound.runtime.ts index 023e9e93e23..71aa83ce9ac 100644 --- a/src/plugins/runtime/runtime-whatsapp-outbound.runtime.ts +++ b/src/plugins/runtime/runtime-whatsapp-outbound.runtime.ts @@ -2,19 +2,14 @@ import { sendMessageWhatsApp as sendMessageWhatsAppImpl, sendPollWhatsApp as sendPollWhatsAppImpl, } from "../../../extensions/whatsapp/src/send.js"; +import type { PluginRuntime } from "./types.js"; -type SendMessageWhatsApp = - typeof import("../../../extensions/whatsapp/src/send.js").sendMessageWhatsApp; -type SendPollWhatsApp = typeof import("../../../extensions/whatsapp/src/send.js").sendPollWhatsApp; +type RuntimeWhatsAppOutbound = Pick< + PluginRuntime["channel"]["whatsapp"], + "sendMessageWhatsApp" | "sendPollWhatsApp" +>; -export function sendMessageWhatsApp( - ...args: Parameters -): ReturnType { - return sendMessageWhatsAppImpl(...args); -} - -export function sendPollWhatsApp( - ...args: Parameters -): ReturnType { - return sendPollWhatsAppImpl(...args); -} +export const runtimeWhatsAppOutbound = { + sendMessageWhatsApp: sendMessageWhatsAppImpl, + sendPollWhatsApp: sendPollWhatsAppImpl, +} satisfies RuntimeWhatsAppOutbound; diff --git a/src/plugins/runtime/runtime-whatsapp.ts b/src/plugins/runtime/runtime-whatsapp.ts index 21a92aefe09..10f8e9e6a94 100644 --- a/src/plugins/runtime/runtime-whatsapp.ts +++ b/src/plugins/runtime/runtime-whatsapp.ts @@ -9,23 +9,28 @@ import { import { createRuntimeWhatsAppLoginTool } from "./runtime-whatsapp-login-tool.js"; import type { PluginRuntime } from "./types.js"; +type RuntimeWhatsAppOutbound = + typeof import("./runtime-whatsapp-outbound.runtime.js").runtimeWhatsAppOutbound; +type RuntimeWhatsAppLogin = + typeof import("./runtime-whatsapp-login.runtime.js").runtimeWhatsAppLogin; + const sendMessageWhatsAppLazy: PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"] = async ( ...args ) => { - const { sendMessageWhatsApp } = await loadWebOutbound(); - return sendMessageWhatsApp(...args); + const runtimeWhatsAppOutbound = await loadWebOutbound(); + return runtimeWhatsAppOutbound.sendMessageWhatsApp(...args); }; const sendPollWhatsAppLazy: PluginRuntime["channel"]["whatsapp"]["sendPollWhatsApp"] = async ( ...args ) => { - const { sendPollWhatsApp } = await loadWebOutbound(); - return sendPollWhatsApp(...args); + const runtimeWhatsAppOutbound = await loadWebOutbound(); + return runtimeWhatsAppOutbound.sendPollWhatsApp(...args); }; const loginWebLazy: PluginRuntime["channel"]["whatsapp"]["loginWeb"] = async (...args) => { - const { loginWeb } = await loadWebLogin(); - return loginWeb(...args); + const runtimeWhatsAppLogin = await loadWebLogin(); + return runtimeWhatsAppLogin.loginWeb(...args); }; const startWebLoginWithQrLazy: PluginRuntime["channel"]["whatsapp"]["startWebLoginWithQr"] = async ( @@ -59,20 +64,23 @@ let webLoginQrPromise: Promise< typeof import("../../../extensions/whatsapp/src/login-qr.js") > | null = null; let webChannelPromise: Promise | null = null; -let webOutboundPromise: Promise | null = - null; -let webLoginPromise: Promise | null = null; +let webOutboundPromise: Promise | null = null; +let webLoginPromise: Promise | null = null; let whatsappActionsPromise: Promise< typeof import("../../agents/tools/whatsapp-actions.js") > | null = null; function loadWebOutbound() { - webOutboundPromise ??= import("./runtime-whatsapp-outbound.runtime.js"); + webOutboundPromise ??= import("./runtime-whatsapp-outbound.runtime.js").then( + ({ runtimeWhatsAppOutbound }) => runtimeWhatsAppOutbound, + ); return webOutboundPromise; } function loadWebLogin() { - webLoginPromise ??= import("./runtime-whatsapp-login.runtime.js"); + webLoginPromise ??= import("./runtime-whatsapp-login.runtime.js").then( + ({ runtimeWhatsAppLogin }) => runtimeWhatsAppLogin, + ); return webLoginPromise; }