mirror of
https://github.com/clawdbot/clawdbot.git
synced 2026-03-17 17:33:45 +01:00
refactor: expose lazy runtime helper to plugins
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
type ChannelMessageActionAdapter,
|
||||
type ChannelMessageActionName,
|
||||
} from "openclaw/plugin-sdk/bluebubbles";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import { resolveBlueBubblesAccount } from "./accounts.js";
|
||||
import { getCachedBlueBubblesPrivateApiStatus, isMacOS26OrHigher } from "./probe.js";
|
||||
import { normalizeSecretInputString } from "./secret-input.js";
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
buildAccountScopedDmSecurityPolicy,
|
||||
collectOpenGroupPolicyRestrictSendersWarnings,
|
||||
} from "openclaw/plugin-sdk/channel-policy";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import {
|
||||
listBlueBubblesAccountIds,
|
||||
type ResolvedBlueBubblesAccount,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
} from "openclaw/plugin-sdk/feishu";
|
||||
import type { ChannelMessageActionName } from "openclaw/plugin-sdk/feishu";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import {
|
||||
resolveFeishuAccount,
|
||||
resolveFeishuCredentials,
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/googlechat";
|
||||
import { GoogleChatConfigSchema } from "openclaw/plugin-sdk/googlechat";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import { buildPassiveProbedChannelStatusSummary } from "../../shared/channel-status-summary.js";
|
||||
import {
|
||||
listGoogleChatAccountIds,
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
buildOpenGroupPolicyWarning,
|
||||
collectAllowlistProviderGroupPolicyWarnings,
|
||||
} from "openclaw/plugin-sdk/channel-policy";
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import {
|
||||
buildChannelConfigSchema,
|
||||
buildProbeChannelStatusSummary,
|
||||
@@ -15,7 +16,6 @@ import {
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
type ChannelPlugin,
|
||||
} from "openclaw/plugin-sdk/matrix";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { buildTrafficStatusSummary } from "../../shared/channel-status-summary.js";
|
||||
import { matrixMessageActions } from "./actions.js";
|
||||
import { MatrixConfigSchema } from "./config-schema.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
|
||||
import { collectAllowlistProviderRestrictSendersWarnings } from "openclaw/plugin-sdk/channel-policy";
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import type {
|
||||
ChannelMessageActionName,
|
||||
ChannelPlugin,
|
||||
@@ -14,7 +15,6 @@ import {
|
||||
MSTeamsConfigSchema,
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
} from "openclaw/plugin-sdk/msteams";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { resolveMSTeamsGroupToolPolicy } from "./policy.js";
|
||||
import type { ProbeMSTeamsResult } from "./probe.js";
|
||||
import {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import type {
|
||||
ChannelMessageActionAdapter,
|
||||
ChannelMessageActionName,
|
||||
OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/zalo";
|
||||
import { extractToolSend, jsonResult, readStringParam } from "openclaw/plugin-sdk/zalo";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import { listEnabledZaloAccounts } from "./accounts.js";
|
||||
|
||||
type ZaloActionsRuntime = typeof import("./actions.runtime.js").zaloActionsRuntime;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
"irc",
|
||||
"llm-task",
|
||||
"lobster",
|
||||
"lazy-runtime",
|
||||
"matrix",
|
||||
"mattermost",
|
||||
"memory-core",
|
||||
|
||||
5
src/plugin-sdk/lazy-runtime.ts
Normal file
5
src/plugin-sdk/lazy-runtime.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export {
|
||||
createLazyRuntimeMethod,
|
||||
createLazyRuntimeMethodBinder,
|
||||
createLazyRuntimeSurface,
|
||||
} from "../shared/lazy-runtime.js";
|
||||
@@ -20,7 +20,7 @@ type LoginQwenPortalOAuth =
|
||||
type GithubCopilotLoginCommand =
|
||||
(typeof import("openclaw/plugin-sdk/provider-auth"))["githubCopilotLoginCommand"];
|
||||
type CreateVpsAwareHandlers =
|
||||
(typeof import("../../commands/oauth-flow.js"))["createVpsAwareOAuthHandlers"];
|
||||
(typeof import("../provider-oauth-flow.js"))["createVpsAwareOAuthHandlers"];
|
||||
|
||||
const loginOpenAICodexOAuthMock = vi.hoisted(() => vi.fn<LoginOpenAICodexOAuth>());
|
||||
const loginQwenPortalOAuthMock = vi.hoisted(() => vi.fn<LoginQwenPortalOAuth>());
|
||||
|
||||
@@ -9,121 +9,71 @@ import {
|
||||
setThreadBindingMaxAgeBySessionKey,
|
||||
unbindThreadBindingsBySessionKey,
|
||||
} from "../../../extensions/discord/src/monitor/thread-bindings.js";
|
||||
import { createLazyRuntimeMethod, createLazyRuntimeSurface } from "../../shared/lazy-runtime.js";
|
||||
import {
|
||||
createLazyRuntimeMethodBinder,
|
||||
createLazyRuntimeSurface,
|
||||
} from "../../shared/lazy-runtime.js";
|
||||
import { createDiscordTypingLease } from "./runtime-discord-typing.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
type RuntimeDiscordOps = typeof import("./runtime-discord-ops.runtime.js").runtimeDiscordOps;
|
||||
|
||||
const loadRuntimeDiscordOps = createLazyRuntimeSurface(
|
||||
() => import("./runtime-discord-ops.runtime.js"),
|
||||
({ runtimeDiscordOps }) => runtimeDiscordOps,
|
||||
);
|
||||
|
||||
const auditChannelPermissionsLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["auditChannelPermissions"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["auditChannelPermissions"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.auditChannelPermissions);
|
||||
const bindDiscordRuntimeMethod = createLazyRuntimeMethodBinder(loadRuntimeDiscordOps);
|
||||
|
||||
const listDirectoryGroupsLiveLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.listDirectoryGroupsLive);
|
||||
|
||||
const listDirectoryPeersLiveLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["listDirectoryPeersLive"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["listDirectoryPeersLive"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.listDirectoryPeersLive);
|
||||
|
||||
const probeDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["probeDiscord"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["probeDiscord"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.probeDiscord);
|
||||
|
||||
const resolveChannelAllowlistLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["resolveChannelAllowlist"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["resolveChannelAllowlist"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.resolveChannelAllowlist);
|
||||
|
||||
const resolveUserAllowlistLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["resolveUserAllowlist"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["resolveUserAllowlist"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.resolveUserAllowlist);
|
||||
|
||||
const sendComponentMessageLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["sendComponentMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["sendComponentMessage"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.sendComponentMessage);
|
||||
|
||||
const sendMessageDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["sendMessageDiscord"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["sendMessageDiscord"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.sendMessageDiscord);
|
||||
|
||||
const sendPollDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["sendPollDiscord"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["sendPollDiscord"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.sendPollDiscord);
|
||||
|
||||
const monitorDiscordProviderLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["monitorDiscordProvider"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["monitorDiscordProvider"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.monitorDiscordProvider);
|
||||
|
||||
const sendTypingDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["typing"]["pulse"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["typing"]["pulse"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.typing.pulse);
|
||||
|
||||
const editMessageDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.editMessage);
|
||||
|
||||
const deleteMessageDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"]>
|
||||
>(
|
||||
loadRuntimeDiscordOps,
|
||||
const auditChannelPermissionsLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.auditChannelPermissions,
|
||||
);
|
||||
const listDirectoryGroupsLiveLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.listDirectoryGroupsLive,
|
||||
);
|
||||
const listDirectoryPeersLiveLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.listDirectoryPeersLive,
|
||||
);
|
||||
const probeDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.probeDiscord,
|
||||
);
|
||||
const resolveChannelAllowlistLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.resolveChannelAllowlist,
|
||||
);
|
||||
const resolveUserAllowlistLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.resolveUserAllowlist,
|
||||
);
|
||||
const sendComponentMessageLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.sendComponentMessage,
|
||||
);
|
||||
const sendMessageDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.sendMessageDiscord,
|
||||
);
|
||||
const sendPollDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.sendPollDiscord,
|
||||
);
|
||||
const monitorDiscordProviderLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.monitorDiscordProvider,
|
||||
);
|
||||
const sendTypingDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.typing.pulse,
|
||||
);
|
||||
const editMessageDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.editMessage,
|
||||
);
|
||||
const deleteMessageDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.deleteMessage,
|
||||
);
|
||||
|
||||
const pinMessageDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.pinMessage);
|
||||
|
||||
const unpinMessageDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.unpinMessage);
|
||||
|
||||
const createThreadDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["createThread"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["createThread"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.createThread);
|
||||
|
||||
const editChannelDiscordLazy = createLazyRuntimeMethod<
|
||||
RuntimeDiscordOps,
|
||||
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"]>,
|
||||
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"]>
|
||||
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.editChannel);
|
||||
const pinMessageDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.pinMessage,
|
||||
);
|
||||
const unpinMessageDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.unpinMessage,
|
||||
);
|
||||
const createThreadDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.createThread,
|
||||
);
|
||||
const editChannelDiscordLazy = bindDiscordRuntimeMethod(
|
||||
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.editChannel,
|
||||
);
|
||||
|
||||
export function createRuntimeDiscord(): PluginRuntimeChannel["discord"] {
|
||||
return {
|
||||
|
||||
@@ -1,60 +1,38 @@
|
||||
import { createLazyRuntimeMethod, createLazyRuntimeSurface } from "../../shared/lazy-runtime.js";
|
||||
import {
|
||||
createLazyRuntimeMethodBinder,
|
||||
createLazyRuntimeSurface,
|
||||
} from "../../shared/lazy-runtime.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
type RuntimeSlackOps = typeof import("./runtime-slack-ops.runtime.js").runtimeSlackOps;
|
||||
|
||||
const loadRuntimeSlackOps = createLazyRuntimeSurface(
|
||||
() => import("./runtime-slack-ops.runtime.js"),
|
||||
({ runtimeSlackOps }) => runtimeSlackOps,
|
||||
);
|
||||
|
||||
const listDirectoryGroupsLiveLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.listDirectoryGroupsLive);
|
||||
const bindSlackRuntimeMethod = createLazyRuntimeMethodBinder(loadRuntimeSlackOps);
|
||||
|
||||
const listDirectoryPeersLiveLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["listDirectoryPeersLive"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["listDirectoryPeersLive"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.listDirectoryPeersLive);
|
||||
|
||||
const probeSlackLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["probeSlack"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["probeSlack"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.probeSlack);
|
||||
|
||||
const resolveChannelAllowlistLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["resolveChannelAllowlist"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["resolveChannelAllowlist"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.resolveChannelAllowlist);
|
||||
|
||||
const resolveUserAllowlistLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["resolveUserAllowlist"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["resolveUserAllowlist"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.resolveUserAllowlist);
|
||||
|
||||
const sendMessageSlackLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["sendMessageSlack"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["sendMessageSlack"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.sendMessageSlack);
|
||||
|
||||
const monitorSlackProviderLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["monitorSlackProvider"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["monitorSlackProvider"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.monitorSlackProvider);
|
||||
|
||||
const handleSlackActionLazy = createLazyRuntimeMethod<
|
||||
RuntimeSlackOps,
|
||||
Parameters<PluginRuntimeChannel["slack"]["handleSlackAction"]>,
|
||||
ReturnType<PluginRuntimeChannel["slack"]["handleSlackAction"]>
|
||||
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.handleSlackAction);
|
||||
const listDirectoryGroupsLiveLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.listDirectoryGroupsLive,
|
||||
);
|
||||
const listDirectoryPeersLiveLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.listDirectoryPeersLive,
|
||||
);
|
||||
const probeSlackLazy = bindSlackRuntimeMethod((runtimeSlackOps) => runtimeSlackOps.probeSlack);
|
||||
const resolveChannelAllowlistLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.resolveChannelAllowlist,
|
||||
);
|
||||
const resolveUserAllowlistLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.resolveUserAllowlist,
|
||||
);
|
||||
const sendMessageSlackLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.sendMessageSlack,
|
||||
);
|
||||
const monitorSlackProviderLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.monitorSlackProvider,
|
||||
);
|
||||
const handleSlackActionLazy = bindSlackRuntimeMethod(
|
||||
(runtimeSlackOps) => runtimeSlackOps.handleSlackAction,
|
||||
);
|
||||
|
||||
export function createRuntimeSlack(): PluginRuntimeChannel["slack"] {
|
||||
return {
|
||||
|
||||
@@ -5,104 +5,54 @@ import {
|
||||
setTelegramThreadBindingMaxAgeBySessionKey,
|
||||
} from "../../../extensions/telegram/src/thread-bindings.js";
|
||||
import { resolveTelegramToken } from "../../../extensions/telegram/src/token.js";
|
||||
import { createLazyRuntimeMethod, createLazyRuntimeSurface } from "../../shared/lazy-runtime.js";
|
||||
import {
|
||||
createLazyRuntimeMethodBinder,
|
||||
createLazyRuntimeSurface,
|
||||
} from "../../shared/lazy-runtime.js";
|
||||
import { createTelegramTypingLease } from "./runtime-telegram-typing.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
type RuntimeTelegramOps = typeof import("./runtime-telegram-ops.runtime.js").runtimeTelegramOps;
|
||||
|
||||
const loadRuntimeTelegramOps = createLazyRuntimeSurface(
|
||||
() => import("./runtime-telegram-ops.runtime.js"),
|
||||
({ runtimeTelegramOps }) => runtimeTelegramOps,
|
||||
);
|
||||
|
||||
const auditGroupMembershipLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["auditGroupMembership"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["auditGroupMembership"]>
|
||||
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.auditGroupMembership);
|
||||
const bindTelegramRuntimeMethod = createLazyRuntimeMethodBinder(loadRuntimeTelegramOps);
|
||||
|
||||
const probeTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["probeTelegram"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["probeTelegram"]>
|
||||
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.probeTelegram);
|
||||
|
||||
const sendMessageTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["sendMessageTelegram"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["sendMessageTelegram"]>
|
||||
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.sendMessageTelegram);
|
||||
|
||||
const sendPollTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["sendPollTelegram"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["sendPollTelegram"]>
|
||||
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.sendPollTelegram);
|
||||
|
||||
const monitorTelegramProviderLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["monitorTelegramProvider"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["monitorTelegramProvider"]>
|
||||
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.monitorTelegramProvider);
|
||||
|
||||
const sendTypingTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["typing"]["pulse"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["typing"]["pulse"]>
|
||||
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.typing.pulse);
|
||||
|
||||
const editMessageTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"]>
|
||||
>(
|
||||
loadRuntimeTelegramOps,
|
||||
const auditGroupMembershipLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.auditGroupMembership,
|
||||
);
|
||||
const probeTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.probeTelegram,
|
||||
);
|
||||
const sendMessageTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.sendMessageTelegram,
|
||||
);
|
||||
const sendPollTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.sendPollTelegram,
|
||||
);
|
||||
const monitorTelegramProviderLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.monitorTelegramProvider,
|
||||
);
|
||||
const sendTypingTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.typing.pulse,
|
||||
);
|
||||
const editMessageTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.editMessage,
|
||||
);
|
||||
|
||||
const editMessageReplyMarkupTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"]>
|
||||
>(
|
||||
loadRuntimeTelegramOps,
|
||||
const editMessageReplyMarkupTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.editReplyMarkup,
|
||||
);
|
||||
|
||||
const deleteMessageTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"]>
|
||||
>(
|
||||
loadRuntimeTelegramOps,
|
||||
const deleteMessageTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.deleteMessage,
|
||||
);
|
||||
|
||||
const renameForumTopicTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"]>
|
||||
>(
|
||||
loadRuntimeTelegramOps,
|
||||
const renameForumTopicTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.renameTopic,
|
||||
);
|
||||
|
||||
const pinMessageTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"]>
|
||||
>(
|
||||
loadRuntimeTelegramOps,
|
||||
const pinMessageTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.pinMessage,
|
||||
);
|
||||
|
||||
const unpinMessageTelegramLazy = createLazyRuntimeMethod<
|
||||
RuntimeTelegramOps,
|
||||
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"]>,
|
||||
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"]>
|
||||
>(
|
||||
loadRuntimeTelegramOps,
|
||||
const unpinMessageTelegramLazy = bindTelegramRuntimeMethod(
|
||||
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.unpinMessage,
|
||||
);
|
||||
|
||||
|
||||
@@ -6,15 +6,13 @@ import {
|
||||
readWebSelfId,
|
||||
webAuthExists,
|
||||
} from "../../../extensions/whatsapp/src/auth-store.js";
|
||||
import { createLazyRuntimeMethod, createLazyRuntimeSurface } from "../../shared/lazy-runtime.js";
|
||||
import {
|
||||
createLazyRuntimeMethodBinder,
|
||||
createLazyRuntimeSurface,
|
||||
} from "../../shared/lazy-runtime.js";
|
||||
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 loadWebOutbound = createLazyRuntimeSurface(
|
||||
() => import("./runtime-whatsapp-outbound.runtime.js"),
|
||||
({ runtimeWhatsAppOutbound }) => runtimeWhatsAppOutbound,
|
||||
@@ -25,23 +23,18 @@ const loadWebLogin = createLazyRuntimeSurface(
|
||||
({ runtimeWhatsAppLogin }) => runtimeWhatsAppLogin,
|
||||
);
|
||||
|
||||
const sendMessageWhatsAppLazy = createLazyRuntimeMethod<
|
||||
RuntimeWhatsAppOutbound,
|
||||
Parameters<PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"]>,
|
||||
ReturnType<PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"]>
|
||||
>(loadWebOutbound, (runtimeWhatsAppOutbound) => runtimeWhatsAppOutbound.sendMessageWhatsApp);
|
||||
const bindWhatsAppOutboundMethod = createLazyRuntimeMethodBinder(loadWebOutbound);
|
||||
const bindWhatsAppLoginMethod = createLazyRuntimeMethodBinder(loadWebLogin);
|
||||
|
||||
const sendPollWhatsAppLazy = createLazyRuntimeMethod<
|
||||
RuntimeWhatsAppOutbound,
|
||||
Parameters<PluginRuntime["channel"]["whatsapp"]["sendPollWhatsApp"]>,
|
||||
ReturnType<PluginRuntime["channel"]["whatsapp"]["sendPollWhatsApp"]>
|
||||
>(loadWebOutbound, (runtimeWhatsAppOutbound) => runtimeWhatsAppOutbound.sendPollWhatsApp);
|
||||
|
||||
const loginWebLazy = createLazyRuntimeMethod<
|
||||
RuntimeWhatsAppLogin,
|
||||
Parameters<PluginRuntime["channel"]["whatsapp"]["loginWeb"]>,
|
||||
ReturnType<PluginRuntime["channel"]["whatsapp"]["loginWeb"]>
|
||||
>(loadWebLogin, (runtimeWhatsAppLogin) => runtimeWhatsAppLogin.loginWeb);
|
||||
const sendMessageWhatsAppLazy = bindWhatsAppOutboundMethod(
|
||||
(runtimeWhatsAppOutbound) => runtimeWhatsAppOutbound.sendMessageWhatsApp,
|
||||
);
|
||||
const sendPollWhatsAppLazy = bindWhatsAppOutboundMethod(
|
||||
(runtimeWhatsAppOutbound) => runtimeWhatsAppOutbound.sendPollWhatsApp,
|
||||
);
|
||||
const loginWebLazy = bindWhatsAppLoginMethod(
|
||||
(runtimeWhatsAppLogin) => runtimeWhatsAppLogin.loginWeb,
|
||||
);
|
||||
|
||||
const startWebLoginWithQrLazy: PluginRuntime["channel"]["whatsapp"]["startWebLoginWithQr"] = async (
|
||||
...args
|
||||
|
||||
@@ -19,3 +19,11 @@ export function createLazyRuntimeMethod<TSurface, TArgs extends unknown[], TResu
|
||||
};
|
||||
return invoke;
|
||||
}
|
||||
|
||||
export function createLazyRuntimeMethodBinder<TSurface>(load: () => Promise<TSurface>) {
|
||||
return function <TArgs extends unknown[], TResult>(
|
||||
select: (surface: TSurface) => (...args: TArgs) => TResult,
|
||||
): (...args: TArgs) => Promise<Awaited<TResult>> {
|
||||
return createLazyRuntimeMethod(load, select);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user