refactor: consolidate lazy runtime surfaces

This commit is contained in:
Peter Steinberger
2026-03-17 00:58:46 -07:00
parent 449127b474
commit 9648e7fecb
47 changed files with 602 additions and 730 deletions

View File

@@ -15,87 +15,17 @@ import {
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<SendBlueBubblesAttachment>
): ReturnType<SendBlueBubblesAttachment> {
return sendBlueBubblesAttachmentImpl(...args);
}
export function addBlueBubblesParticipant(
...args: Parameters<AddBlueBubblesParticipant>
): ReturnType<AddBlueBubblesParticipant> {
return addBlueBubblesParticipantImpl(...args);
}
export function editBlueBubblesMessage(
...args: Parameters<EditBlueBubblesMessage>
): ReturnType<EditBlueBubblesMessage> {
return editBlueBubblesMessageImpl(...args);
}
export function leaveBlueBubblesChat(
...args: Parameters<LeaveBlueBubblesChat>
): ReturnType<LeaveBlueBubblesChat> {
return leaveBlueBubblesChatImpl(...args);
}
export function removeBlueBubblesParticipant(
...args: Parameters<RemoveBlueBubblesParticipant>
): ReturnType<RemoveBlueBubblesParticipant> {
return removeBlueBubblesParticipantImpl(...args);
}
export function renameBlueBubblesChat(
...args: Parameters<RenameBlueBubblesChat>
): ReturnType<RenameBlueBubblesChat> {
return renameBlueBubblesChatImpl(...args);
}
export function setGroupIconBlueBubbles(
...args: Parameters<SetGroupIconBlueBubbles>
): ReturnType<SetGroupIconBlueBubbles> {
return setGroupIconBlueBubblesImpl(...args);
}
export function unsendBlueBubblesMessage(
...args: Parameters<UnsendBlueBubblesMessage>
): ReturnType<UnsendBlueBubblesMessage> {
return unsendBlueBubblesMessageImpl(...args);
}
export function resolveBlueBubblesMessageId(
...args: Parameters<ResolveBlueBubblesMessageId>
): ReturnType<ResolveBlueBubblesMessageId> {
return resolveBlueBubblesMessageIdImpl(...args);
}
export function sendBlueBubblesReaction(
...args: Parameters<SendBlueBubblesReaction>
): ReturnType<SendBlueBubblesReaction> {
return sendBlueBubblesReactionImpl(...args);
}
export function resolveChatGuidForTarget(
...args: Parameters<ResolveChatGuidForTarget>
): ReturnType<ResolveChatGuidForTarget> {
return resolveChatGuidForTargetImpl(...args);
}
export function sendMessageBlueBubbles(
...args: Parameters<SendMessageBlueBubbles>
): ReturnType<SendMessageBlueBubbles> {
return sendMessageBlueBubblesImpl(...args);
}
export const blueBubblesActionsRuntime = {
sendBlueBubblesAttachment: sendBlueBubblesAttachmentImpl,
addBlueBubblesParticipant: addBlueBubblesParticipantImpl,
editBlueBubblesMessage: editBlueBubblesMessageImpl,
leaveBlueBubblesChat: leaveBlueBubblesChatImpl,
removeBlueBubblesParticipant: removeBlueBubblesParticipantImpl,
renameBlueBubblesChat: renameBlueBubblesChatImpl,
setGroupIconBlueBubbles: setGroupIconBlueBubblesImpl,
unsendBlueBubblesMessage: unsendBlueBubblesMessageImpl,
resolveBlueBubblesMessageId: resolveBlueBubblesMessageIdImpl,
sendBlueBubblesReaction: sendBlueBubblesReactionImpl,
resolveChatGuidForTarget: resolveChatGuidForTargetImpl,
sendMessageBlueBubbles: sendMessageBlueBubblesImpl,
};

View File

@@ -11,18 +11,19 @@ import {
type ChannelMessageActionAdapter,
type ChannelMessageActionName,
} from "openclaw/plugin-sdk/bluebubbles";
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
import { resolveBlueBubblesAccount } from "./accounts.js";
import { getCachedBlueBubblesPrivateApiStatus, isMacOS26OrHigher } from "./probe.js";
import { normalizeSecretInputString } from "./secret-input.js";
import { normalizeBlueBubblesHandle, parseBlueBubblesTarget } from "./targets.js";
import type { BlueBubblesSendTarget } from "./types.js";
let actionsRuntimePromise: Promise<typeof import("./actions.runtime.js")> | null = null;
type BlueBubblesActionsRuntime = typeof import("./actions.runtime.js").blueBubblesActionsRuntime;
function loadBlueBubblesActionsRuntime() {
actionsRuntimePromise ??= import("./actions.runtime.js");
return actionsRuntimePromise;
}
const loadBlueBubblesActionsRuntime = createLazyRuntimeSurface(
() => import("./actions.runtime.js"),
({ blueBubblesActionsRuntime }) => blueBubblesActionsRuntime,
);
const providerId = "bluebubbles";

View File

@@ -6,52 +6,14 @@ import {
} 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<SendBlueBubblesMedia>
): ReturnType<SendBlueBubblesMedia> {
return sendBlueBubblesMediaImpl(...args);
}
export function resolveBlueBubblesMessageId(
...args: Parameters<ResolveBlueBubblesMessageId>
): ReturnType<ResolveBlueBubblesMessageId> {
return resolveBlueBubblesMessageIdImpl(...args);
}
export function monitorBlueBubblesProvider(
...args: Parameters<MonitorBlueBubblesProvider>
): ReturnType<MonitorBlueBubblesProvider> {
return monitorBlueBubblesProviderImpl(...args);
}
export function resolveWebhookPathFromConfig(
...args: Parameters<ResolveWebhookPathFromConfig>
): ReturnType<ResolveWebhookPathFromConfig> {
return resolveWebhookPathFromConfigImpl(...args);
}
export function probeBlueBubbles(
...args: Parameters<ProbeBlueBubbles>
): ReturnType<ProbeBlueBubbles> {
return probeBlueBubblesImpl(...args);
}
export function sendMessageBlueBubbles(
...args: Parameters<SendMessageBlueBubbles>
): ReturnType<SendMessageBlueBubbles> {
return sendMessageBlueBubblesImpl(...args);
}
export const blueBubblesSetupWizard: BlueBubblesSetupWizard = { ...blueBubblesSetupWizardImpl };
export const blueBubblesChannelRuntime = {
sendBlueBubblesMedia: sendBlueBubblesMediaImpl,
resolveBlueBubblesMessageId: resolveBlueBubblesMessageIdImpl,
monitorBlueBubblesProvider: monitorBlueBubblesProviderImpl,
resolveWebhookPathFromConfig: resolveWebhookPathFromConfigImpl,
probeBlueBubbles: probeBlueBubblesImpl,
sendMessageBlueBubbles: sendMessageBlueBubblesImpl,
};

View File

@@ -18,6 +18,7 @@ import {
buildAccountScopedDmSecurityPolicy,
collectOpenGroupPolicyRestrictSendersWarnings,
} from "openclaw/plugin-sdk/channel-policy";
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
import {
listBlueBubblesAccountIds,
type ResolvedBlueBubblesAccount,
@@ -37,12 +38,12 @@ import {
parseBlueBubblesTarget,
} from "./targets.js";
let blueBubblesChannelRuntimePromise: Promise<typeof import("./channel.runtime.js")> | null = null;
type BlueBubblesChannelRuntime = typeof import("./channel.runtime.js").blueBubblesChannelRuntime;
function loadBlueBubblesChannelRuntime() {
blueBubblesChannelRuntimePromise ??= import("./channel.runtime.js");
return blueBubblesChannelRuntimePromise;
}
const loadBlueBubblesChannelRuntime = createLazyRuntimeSurface(
() => import("./channel.runtime.js"),
({ blueBubblesChannelRuntime }) => blueBubblesChannelRuntime,
);
const meta = {
id: "bluebubbles",

View File

@@ -26,104 +26,22 @@ import {
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<ListFeishuDirectoryGroupsLive>
): ReturnType<ListFeishuDirectoryGroupsLive> {
return listFeishuDirectoryGroupsLiveImpl(...args);
}
export function listFeishuDirectoryPeersLive(
...args: Parameters<ListFeishuDirectoryPeersLive>
): ReturnType<ListFeishuDirectoryPeersLive> {
return listFeishuDirectoryPeersLiveImpl(...args);
}
export const feishuOutbound: FeishuOutbound = { ...feishuOutboundImpl };
export function createPinFeishu(...args: Parameters<CreatePinFeishu>): ReturnType<CreatePinFeishu> {
return createPinFeishuImpl(...args);
}
export function listPinsFeishu(...args: Parameters<ListPinsFeishu>): ReturnType<ListPinsFeishu> {
return listPinsFeishuImpl(...args);
}
export function removePinFeishu(...args: Parameters<RemovePinFeishu>): ReturnType<RemovePinFeishu> {
return removePinFeishuImpl(...args);
}
export function probeFeishu(...args: Parameters<ProbeFeishu>): ReturnType<ProbeFeishu> {
return probeFeishuImpl(...args);
}
export function addReactionFeishu(
...args: Parameters<AddReactionFeishu>
): ReturnType<AddReactionFeishu> {
return addReactionFeishuImpl(...args);
}
export function listReactionsFeishu(
...args: Parameters<ListReactionsFeishu>
): ReturnType<ListReactionsFeishu> {
return listReactionsFeishuImpl(...args);
}
export function removeReactionFeishu(
...args: Parameters<RemoveReactionFeishu>
): ReturnType<RemoveReactionFeishu> {
return removeReactionFeishuImpl(...args);
}
export function getChatInfo(...args: Parameters<GetChatInfo>): ReturnType<GetChatInfo> {
return getChatInfoImpl(...args);
}
export function getChatMembers(...args: Parameters<GetChatMembers>): ReturnType<GetChatMembers> {
return getChatMembersImpl(...args);
}
export function getFeishuMemberInfo(
...args: Parameters<GetFeishuMemberInfo>
): ReturnType<GetFeishuMemberInfo> {
return getFeishuMemberInfoImpl(...args);
}
export function editMessageFeishu(
...args: Parameters<EditMessageFeishu>
): ReturnType<EditMessageFeishu> {
return editMessageFeishuImpl(...args);
}
export function getMessageFeishu(
...args: Parameters<GetMessageFeishu>
): ReturnType<GetMessageFeishu> {
return getMessageFeishuImpl(...args);
}
export function sendCardFeishu(...args: Parameters<SendCardFeishu>): ReturnType<SendCardFeishu> {
return sendCardFeishuImpl(...args);
}
export function sendMessageFeishu(
...args: Parameters<SendMessageFeishu>
): ReturnType<SendMessageFeishu> {
return sendMessageFeishuImpl(...args);
}
export const feishuChannelRuntime = {
listFeishuDirectoryGroupsLive: listFeishuDirectoryGroupsLiveImpl,
listFeishuDirectoryPeersLive: listFeishuDirectoryPeersLiveImpl,
feishuOutbound: { ...feishuOutboundImpl },
createPinFeishu: createPinFeishuImpl,
listPinsFeishu: listPinsFeishuImpl,
removePinFeishu: removePinFeishuImpl,
probeFeishu: probeFeishuImpl,
addReactionFeishu: addReactionFeishuImpl,
listReactionsFeishu: listReactionsFeishuImpl,
removeReactionFeishu: removeReactionFeishuImpl,
getChatInfo: getChatInfoImpl,
getChatMembers: getChatMembersImpl,
getFeishuMemberInfo: getFeishuMemberInfoImpl,
editMessageFeishu: editMessageFeishuImpl,
getMessageFeishu: getMessageFeishuImpl,
sendCardFeishu: sendCardFeishuImpl,
sendMessageFeishu: sendMessageFeishuImpl,
};

View File

@@ -28,22 +28,28 @@ vi.mock("./client.js", () => ({
}));
vi.mock("./channel.runtime.js", () => ({
addReactionFeishu: addReactionFeishuMock,
createPinFeishu: createPinFeishuMock,
editMessageFeishu: editMessageFeishuMock,
getChatInfo: getChatInfoMock,
getChatMembers: getChatMembersMock,
getFeishuMemberInfo: getFeishuMemberInfoMock,
getMessageFeishu: getMessageFeishuMock,
listFeishuDirectoryGroupsLive: listFeishuDirectoryGroupsLiveMock,
listFeishuDirectoryPeersLive: listFeishuDirectoryPeersLiveMock,
listPinsFeishu: listPinsFeishuMock,
listReactionsFeishu: listReactionsFeishuMock,
probeFeishu: probeFeishuMock,
removePinFeishu: removePinFeishuMock,
removeReactionFeishu: removeReactionFeishuMock,
sendCardFeishu: sendCardFeishuMock,
sendMessageFeishu: sendMessageFeishuMock,
feishuChannelRuntime: {
addReactionFeishu: addReactionFeishuMock,
createPinFeishu: createPinFeishuMock,
editMessageFeishu: editMessageFeishuMock,
getChatInfo: getChatInfoMock,
getChatMembers: getChatMembersMock,
getFeishuMemberInfo: getFeishuMemberInfoMock,
getMessageFeishu: getMessageFeishuMock,
listFeishuDirectoryGroupsLive: listFeishuDirectoryGroupsLiveMock,
listFeishuDirectoryPeersLive: listFeishuDirectoryPeersLiveMock,
listPinsFeishu: listPinsFeishuMock,
listReactionsFeishu: listReactionsFeishuMock,
probeFeishu: probeFeishuMock,
removePinFeishu: removePinFeishuMock,
removeReactionFeishu: removeReactionFeishuMock,
sendCardFeishu: sendCardFeishuMock,
sendMessageFeishu: sendMessageFeishuMock,
feishuOutbound: {
sendText: vi.fn(),
sendMedia: vi.fn(),
},
},
}));
import { feishuPlugin } from "./channel.js";

View File

@@ -12,6 +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 {
resolveFeishuAccount,
resolveFeishuCredentials,
@@ -41,9 +42,12 @@ const meta: ChannelMeta = {
order: 70,
};
async function loadFeishuChannelRuntime() {
return await import("./channel.runtime.js");
}
type FeishuChannelRuntime = typeof import("./channel.runtime.js").feishuChannelRuntime;
const loadFeishuChannelRuntime = createLazyRuntimeSurface(
() => import("./channel.runtime.js"),
({ feishuChannelRuntime }) => feishuChannelRuntime,
);
function setFeishuNamedAccountEnabled(
cfg: ClawdbotConfig,

View File

@@ -8,36 +8,10 @@ import {
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<ProbeGoogleChat>): ReturnType<ProbeGoogleChat> {
return probeGoogleChatImpl(...args);
}
export function sendGoogleChatMessage(
...args: Parameters<SendGoogleChatMessage>
): ReturnType<SendGoogleChatMessage> {
return sendGoogleChatMessageImpl(...args);
}
export function uploadGoogleChatAttachment(
...args: Parameters<UploadGoogleChatAttachment>
): ReturnType<UploadGoogleChatAttachment> {
return uploadGoogleChatAttachmentImpl(...args);
}
export function resolveGoogleChatWebhookPath(
...args: Parameters<ResolveGoogleChatWebhookPath>
): ReturnType<ResolveGoogleChatWebhookPath> {
return resolveGoogleChatWebhookPathImpl(...args);
}
export function startGoogleChatMonitor(
...args: Parameters<StartGoogleChatMonitor>
): ReturnType<StartGoogleChatMonitor> {
return startGoogleChatMonitorImpl(...args);
}
export const googleChatChannelRuntime = {
probeGoogleChat: probeGoogleChatImpl,
sendGoogleChatMessage: sendGoogleChatMessageImpl,
uploadGoogleChatAttachment: uploadGoogleChatAttachmentImpl,
resolveGoogleChatWebhookPath: resolveGoogleChatWebhookPathImpl,
startGoogleChatMonitor: startGoogleChatMonitorImpl,
};

View File

@@ -27,6 +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 { buildPassiveProbedChannelStatusSummary } from "../../shared/channel-status-summary.js";
import {
listGoogleChatAccountIds,
@@ -47,9 +48,12 @@ import {
const meta = getChatChannelMeta("googlechat");
async function loadGoogleChatChannelRuntime() {
return await import("./channel.runtime.js");
}
type GoogleChatChannelRuntime = typeof import("./channel.runtime.js").googleChatChannelRuntime;
const loadGoogleChatChannelRuntime = createLazyRuntimeSurface(
() => import("./channel.runtime.js"),
({ googleChatChannelRuntime }) => googleChatChannelRuntime,
);
const formatAllowFromEntry = (entry: string) =>
entry

View File

@@ -7,49 +7,12 @@ 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<ListMatrixDirectoryGroupsLive>
): ReturnType<ListMatrixDirectoryGroupsLive> {
return listMatrixDirectoryGroupsLiveImpl(...args);
}
export function listMatrixDirectoryPeersLive(
...args: Parameters<ListMatrixDirectoryPeersLive>
): ReturnType<ListMatrixDirectoryPeersLive> {
return listMatrixDirectoryPeersLiveImpl(...args);
}
export function resolveMatrixAuth(
...args: Parameters<ResolveMatrixAuth>
): ReturnType<ResolveMatrixAuth> {
return resolveMatrixAuthImpl(...args);
}
export function probeMatrix(...args: Parameters<ProbeMatrix>): ReturnType<ProbeMatrix> {
return probeMatrixImpl(...args);
}
export function sendMessageMatrix(
...args: Parameters<SendMessageMatrix>
): ReturnType<SendMessageMatrix> {
return sendMessageMatrixImpl(...args);
}
export function resolveMatrixTargets(
...args: Parameters<ResolveMatrixTargets>
): ReturnType<ResolveMatrixTargets> {
return resolveMatrixTargetsImpl(...args);
}
export const matrixOutbound: MatrixOutbound = { ...matrixOutboundImpl };
export const matrixChannelRuntime = {
listMatrixDirectoryGroupsLive: listMatrixDirectoryGroupsLiveImpl,
listMatrixDirectoryPeersLive: listMatrixDirectoryPeersLiveImpl,
resolveMatrixAuth: resolveMatrixAuthImpl,
probeMatrix: probeMatrixImpl,
sendMessageMatrix: sendMessageMatrixImpl,
resolveMatrixTargets: resolveMatrixTargetsImpl,
matrixOutbound: { ...matrixOutboundImpl },
};

View File

@@ -15,6 +15,7 @@ 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";
@@ -38,9 +39,12 @@ import type { CoreConfig } from "./types.js";
// Mutex for serializing account startup (workaround for concurrent dynamic import race condition)
let matrixStartupLock: Promise<void> = Promise.resolve();
async function loadMatrixChannelRuntime() {
return await import("./channel.runtime.js");
}
type MatrixChannelRuntime = typeof import("./channel.runtime.js").matrixChannelRuntime;
const loadMatrixChannelRuntime = createLazyRuntimeSurface(
() => import("./channel.runtime.js"),
({ matrixChannelRuntime }) => matrixChannelRuntime,
);
const meta = {
id: "matrix",

View File

@@ -8,42 +8,11 @@ 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<ListMSTeamsDirectoryGroupsLive>
): ReturnType<ListMSTeamsDirectoryGroupsLive> {
return listMSTeamsDirectoryGroupsLiveImpl(...args);
}
export function listMSTeamsDirectoryPeersLive(
...args: Parameters<ListMSTeamsDirectoryPeersLive>
): ReturnType<ListMSTeamsDirectoryPeersLive> {
return listMSTeamsDirectoryPeersLiveImpl(...args);
}
export const msteamsOutbound: MSTeamsOutbound = { ...msteamsOutboundImpl };
export function probeMSTeams(...args: Parameters<ProbeMSTeams>): ReturnType<ProbeMSTeams> {
return probeMSTeamsImpl(...args);
}
export function sendAdaptiveCardMSTeams(
...args: Parameters<SendAdaptiveCardMSTeams>
): ReturnType<SendAdaptiveCardMSTeams> {
return sendAdaptiveCardMSTeamsImpl(...args);
}
export function sendMessageMSTeams(
...args: Parameters<SendMessageMSTeams>
): ReturnType<SendMessageMSTeams> {
return sendMessageMSTeamsImpl(...args);
}
export const msTeamsChannelRuntime = {
listMSTeamsDirectoryGroupsLive: listMSTeamsDirectoryGroupsLiveImpl,
listMSTeamsDirectoryPeersLive: listMSTeamsDirectoryPeersLiveImpl,
msteamsOutbound: { ...msteamsOutboundImpl },
probeMSTeams: probeMSTeamsImpl,
sendAdaptiveCardMSTeams: sendAdaptiveCardMSTeamsImpl,
sendMessageMSTeams: sendMessageMSTeamsImpl,
};

View File

@@ -14,6 +14,7 @@ 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 {
@@ -56,9 +57,12 @@ const TEAMS_GRAPH_PERMISSION_HINTS: Record<string, string> = {
"Files.Read.All": "files (OneDrive)",
};
async function loadMSTeamsChannelRuntime() {
return await import("./channel.runtime.js");
}
type MSTeamsChannelRuntime = typeof import("./channel.runtime.js").msTeamsChannelRuntime;
const loadMSTeamsChannelRuntime = createLazyRuntimeSurface(
() => import("./channel.runtime.js"),
({ msTeamsChannelRuntime }) => msTeamsChannelRuntime,
);
export const msteamsPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
id: "msteams",

View File

@@ -1,7 +1,5 @@
import { sendMessageZalo as sendMessageZaloImpl } from "./send.js";
type SendMessageZalo = typeof import("./send.js").sendMessageZalo;
export function sendMessageZalo(...args: Parameters<SendMessageZalo>): ReturnType<SendMessageZalo> {
return sendMessageZaloImpl(...args);
}
export const zaloActionsRuntime = {
sendMessageZalo: sendMessageZaloImpl,
};

View File

@@ -4,14 +4,15 @@ import type {
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";
let zaloActionsRuntimePromise: Promise<typeof import("./actions.runtime.js")> | null = null;
type ZaloActionsRuntime = typeof import("./actions.runtime.js").zaloActionsRuntime;
async function loadZaloActionsRuntime() {
zaloActionsRuntimePromise ??= import("./actions.runtime.js");
return zaloActionsRuntimePromise;
}
const loadZaloActionsRuntime = createLazyRuntimeSurface(
() => import("./actions.runtime.js"),
({ zaloActionsRuntime }) => zaloActionsRuntime,
);
const providerId = "zalo";

View File

@@ -1 +1,9 @@
export { ensureAuthProfileStore } from "./auth-profiles.js";
import { ensureAuthProfileStore as ensureAuthProfileStoreImpl } from "./auth-profiles.js";
type EnsureAuthProfileStore = typeof import("./auth-profiles.js").ensureAuthProfileStore;
export function ensureAuthProfileStore(
...args: Parameters<EnsureAuthProfileStore>
): ReturnType<EnsureAuthProfileStore> {
return ensureAuthProfileStoreImpl(...args);
}

View File

@@ -1 +1,9 @@
export { pruneStaleCommandPolls } from "./command-poll-backoff.js";
import { pruneStaleCommandPolls as pruneStaleCommandPollsImpl } from "./command-poll-backoff.js";
type PruneStaleCommandPolls = typeof import("./command-poll-backoff.js").pruneStaleCommandPolls;
export function pruneStaleCommandPolls(
...args: Parameters<PruneStaleCommandPolls>
): ReturnType<PruneStaleCommandPolls> {
return pruneStaleCommandPollsImpl(...args);
}

View File

@@ -1 +1,10 @@
export { shouldSuppressBuiltInModel } from "./model-suppression.js";
import { shouldSuppressBuiltInModel as shouldSuppressBuiltInModelImpl } from "./model-suppression.js";
type ShouldSuppressBuiltInModel =
typeof import("./model-suppression.js").shouldSuppressBuiltInModel;
export function shouldSuppressBuiltInModel(
...args: Parameters<ShouldSuppressBuiltInModel>
): ReturnType<ShouldSuppressBuiltInModel> {
return shouldSuppressBuiltInModelImpl(...args);
}

View File

@@ -1 +1,9 @@
export { compactEmbeddedPiSessionDirect } from "./compact.js";
import { compactEmbeddedPiSessionDirect as compactEmbeddedPiSessionDirectImpl } from "./compact.js";
type CompactEmbeddedPiSessionDirect = typeof import("./compact.js").compactEmbeddedPiSessionDirect;
export function compactEmbeddedPiSessionDirect(
...args: Parameters<CompactEmbeddedPiSessionDirect>
): ReturnType<CompactEmbeddedPiSessionDirect> {
return compactEmbeddedPiSessionDirectImpl(...args);
}

View File

@@ -1,7 +1,15 @@
export { getDiagnosticSessionState } from "../logging/diagnostic-session-state.js";
export { logToolLoopAction } from "../logging/diagnostic.js";
export {
import { getDiagnosticSessionState } from "../logging/diagnostic-session-state.js";
import { logToolLoopAction } from "../logging/diagnostic.js";
import {
detectToolCallLoop,
recordToolCall,
recordToolCallOutcome,
} from "./tool-loop-detection.js";
export const beforeToolCallRuntime = {
getDiagnosticSessionState,
logToolLoopAction,
detectToolCallLoop,
recordToolCall,
recordToolCallOutcome,
};

View File

@@ -2,6 +2,7 @@ import type { ToolLoopDetectionConfig } from "../config/types.tools.js";
import type { SessionState } from "../logging/diagnostic-session-state.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { getGlobalHookRunner } from "../plugins/hook-runner-global.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import { isPlainObject } from "../utils.js";
import { normalizeToolName } from "./tool-policy.js";
import type { AnyAgentTool } from "./tools/common.js";
@@ -23,14 +24,11 @@ const adjustedParamsByToolCallId = new Map<string, unknown>();
const MAX_TRACKED_ADJUSTED_PARAMS = 1024;
const LOOP_WARNING_BUCKET_SIZE = 10;
const MAX_LOOP_WARNING_KEYS = 256;
let beforeToolCallRuntimePromise: Promise<
typeof import("./pi-tools.before-tool-call.runtime.js")
> | null = null;
function loadBeforeToolCallRuntime() {
beforeToolCallRuntimePromise ??= import("./pi-tools.before-tool-call.runtime.js");
return beforeToolCallRuntimePromise;
}
const loadBeforeToolCallRuntime = createLazyRuntimeSurface(
() => import("./pi-tools.before-tool-call.runtime.js"),
({ beforeToolCallRuntime }) => beforeToolCallRuntime,
);
function buildAdjustedParamsKey(params: { runId?: string; toolCallId: string }): string {
if (params.runId && params.runId.trim()) {

View File

@@ -1 +1,9 @@
export { getActiveSkillEnvKeys } from "./env-overrides.js";
import { getActiveSkillEnvKeys as getActiveSkillEnvKeysImpl } from "./env-overrides.js";
type GetActiveSkillEnvKeys = typeof import("./env-overrides.js").getActiveSkillEnvKeys;
export function getActiveSkillEnvKeys(
...args: Parameters<GetActiveSkillEnvKeys>
): ReturnType<GetActiveSkillEnvKeys> {
return getActiveSkillEnvKeysImpl(...args);
}

View File

@@ -1 +1,8 @@
export { promptResolvedAllowFrom } from "./setup-wizard-helpers.js";
import type { promptResolvedAllowFrom as promptResolvedAllowFromType } from "./setup-wizard-helpers.js";
export async function promptResolvedAllowFrom(
...args: Parameters<typeof promptResolvedAllowFromType>
): ReturnType<typeof promptResolvedAllowFromType> {
const runtime = await import("./setup-wizard-helpers.js");
return runtime.promptResolvedAllowFrom(...args);
}

View File

@@ -1,4 +1,5 @@
import type { OutboundSendDeps } from "../infra/outbound/send-deps.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import { createOutboundSendDepsFromCliSource } from "./outbound-send-mapping.js";
/**
@@ -24,10 +25,11 @@ function createLazySender(
channelId: string,
loader: () => Promise<RuntimeSendModule>,
): (...args: unknown[]) => Promise<unknown> {
const loadRuntimeSend = createLazyRuntimeSurface(loader, ({ runtimeSend }) => runtimeSend);
return async (...args: unknown[]) => {
let cached = senderCache.get(channelId);
if (!cached) {
cached = loader().then(({ runtimeSend }) => runtimeSend);
cached = loadRuntimeSend();
senderCache.set(channelId, cached);
}
const runtimeSend = await cached;

View File

@@ -1,7 +1,15 @@
export {
import { runProviderPluginAuthMethod } from "../plugins/provider-auth-choice.js";
import {
resolveProviderModelPickerEntries,
resolveProviderPluginChoice,
runProviderModelSelectedHook,
} from "../plugins/provider-wizard.js";
export { resolvePluginProviders } from "../plugins/providers.js";
export { runProviderPluginAuthMethod } from "../plugins/provider-auth-choice.js";
import { resolvePluginProviders } from "../plugins/providers.js";
export const modelPickerRuntime = {
resolveProviderModelPickerEntries,
resolveProviderPluginChoice,
runProviderModelSelectedHook,
resolvePluginProviders,
runProviderPluginAuthMethod,
};

View File

@@ -40,11 +40,13 @@ const runProviderModelSelectedHook = vi.hoisted(() => vi.fn(async () => {}));
const resolvePluginProviders = vi.hoisted(() => vi.fn(() => []));
const runProviderPluginAuthMethod = vi.hoisted(() => vi.fn());
vi.mock("./model-picker.runtime.js", () => ({
resolveProviderModelPickerEntries,
resolveProviderPluginChoice,
runProviderModelSelectedHook,
resolvePluginProviders,
runProviderPluginAuthMethod,
modelPickerRuntime: {
resolveProviderModelPickerEntries,
resolveProviderPluginChoice,
runProviderModelSelectedHook,
resolvePluginProviders,
runProviderPluginAuthMethod,
},
}));
const OPENROUTER_CATALOG = [

View File

@@ -13,6 +13,7 @@ import type { OpenClawConfig } from "../config/config.js";
import { resolveAgentModelPrimaryValue } from "../config/model-input.js";
import { applyPrimaryModel } from "../plugins/provider-model-primary.js";
import type { ProviderPlugin } from "../plugins/types.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import type { WizardPrompter, WizardSelectOption } from "../wizard/prompts.js";
import { formatTokenK } from "./models/shared.js";
@@ -49,6 +50,11 @@ async function loadModelPickerRuntime() {
return import("./model-picker.runtime.js");
}
const loadResolvedModelPickerRuntime = createLazyRuntimeSurface(
loadModelPickerRuntime,
({ modelPickerRuntime }) => modelPickerRuntime,
);
function hasAuthForProvider(
provider: string,
cfg: OpenClawConfig,
@@ -284,7 +290,7 @@ export async function promptDefaultModel(
options.push({ value: MANUAL_VALUE, label: "Enter model manually" });
}
if (includeProviderPluginSetups && agentDir) {
const { resolveProviderModelPickerEntries } = await loadModelPickerRuntime();
const { resolveProviderModelPickerEntries } = await loadResolvedModelPickerRuntime();
options.push(
...resolveProviderModelPickerEntries({
config: cfg,
@@ -343,7 +349,7 @@ export async function promptDefaultModel(
if (selection.startsWith("provider-plugin:")) {
pluginResolution = selection;
} else if (!selection.includes("/")) {
const { resolvePluginProviders } = await loadModelPickerRuntime();
const { resolvePluginProviders } = await loadResolvedModelPickerRuntime();
pluginProviders = resolvePluginProviders({
config: cfg,
workspaceDir: params.workspaceDir,
@@ -368,7 +374,7 @@ export async function promptDefaultModel(
resolveProviderPluginChoice,
runProviderModelSelectedHook,
runProviderPluginAuthMethod,
} = await loadModelPickerRuntime();
} = await loadResolvedModelPickerRuntime();
if (pluginProviders.length === 0) {
pluginProviders = resolvePluginProviders({
config: cfg,
@@ -404,7 +410,7 @@ export async function promptDefaultModel(
return { model: applied.defaultModel, config: applied.config };
}
const model = String(selection);
const { runProviderModelSelectedHook } = await loadModelPickerRuntime();
const { runProviderModelSelectedHook } = await loadResolvedModelPickerRuntime();
await runProviderModelSelectedHook({
config: cfg,
model,

View File

@@ -1,5 +1,11 @@
export { resolveProviderPluginChoice } from "../../../plugins/provider-wizard.js";
export {
import { resolveProviderPluginChoice } from "../../../plugins/provider-wizard.js";
import {
resolveOwningPluginIdsForProvider,
resolvePluginProviders,
} from "../../../plugins/providers.js";
export const authChoicePluginProvidersRuntime = {
resolveOwningPluginIdsForProvider,
resolveProviderPluginChoice,
resolvePluginProviders,
};

View File

@@ -11,10 +11,11 @@ const resolveOwningPluginIdsForProvider = vi.hoisted(() => vi.fn(() => undefined
const resolveProviderPluginChoice = vi.hoisted(() => vi.fn());
const resolvePluginProviders = vi.hoisted(() => vi.fn(() => []));
vi.mock("./auth-choice.plugin-providers.runtime.js", () => ({
resolveOwningPluginIdsForProvider,
resolveProviderPluginChoice,
resolvePluginProviders,
PROVIDER_PLUGIN_CHOICE_PREFIX: "provider-plugin:",
authChoicePluginProvidersRuntime: {
resolveOwningPluginIdsForProvider,
resolveProviderPluginChoice,
resolvePluginProviders,
},
}));
beforeEach(() => {

View File

@@ -14,6 +14,7 @@ import type {
ProviderResolveNonInteractiveApiKeyParams,
} from "../../../plugins/types.js";
import type { RuntimeEnv } from "../../../runtime.js";
import { createLazyRuntimeSurface } from "../../../shared/lazy-runtime.js";
import type { OnboardOptions } from "../../onboard-types.js";
const PROVIDER_PLUGIN_CHOICE_PREFIX = "provider-plugin:";
@@ -22,6 +23,11 @@ async function loadPluginProviderRuntime() {
return import("./auth-choice.plugin-providers.runtime.js");
}
const loadAuthChoicePluginProvidersRuntime = createLazyRuntimeSurface(
loadPluginProviderRuntime,
({ authChoicePluginProvidersRuntime }) => authChoicePluginProvidersRuntime,
);
function buildIsolatedProviderResolutionConfig(
cfg: OpenClawConfig,
providerId: string | undefined,
@@ -81,7 +87,7 @@ export async function applyNonInteractivePluginProviderChoice(params: {
preferredProviderId,
);
const { resolveOwningPluginIdsForProvider, resolveProviderPluginChoice, resolvePluginProviders } =
await loadPluginProviderRuntime();
await loadAuthChoicePluginProvidersRuntime();
const owningPluginIds = preferredProviderId
? resolveOwningPluginIdsForProvider({
provider: preferredProviderId,

View File

@@ -1,2 +1,7 @@
export { collectChannelStatusIssues } from "../infra/channels-status-issues.js";
export { buildChannelsTable } from "./status-all/channels.js";
import { collectChannelStatusIssues } from "../infra/channels-status-issues.js";
import { buildChannelsTable } from "./status-all/channels.js";
export const statusScanRuntime = {
collectChannelStatusIssues,
buildChannelsTable,
};

View File

@@ -42,8 +42,10 @@ vi.mock("./status-all/channels.js", () => ({
}));
vi.mock("./status.scan.runtime.js", () => ({
buildChannelsTable: mocks.buildChannelsTable,
collectChannelStatusIssues: vi.fn(() => []),
statusScanRuntime: {
buildChannelsTable: mocks.buildChannelsTable,
collectChannelStatusIssues: vi.fn(() => []),
},
}));
vi.mock("./status.update.js", () => ({

View File

@@ -6,14 +6,13 @@ import { withProgress } from "../cli/progress.js";
import type { OpenClawConfig } from "../config/config.js";
import { readBestEffortConfig } from "../config/config.js";
import { callGateway } from "../gateway/call.js";
import type { collectChannelStatusIssues as collectChannelStatusIssuesFn } from "../infra/channels-status-issues.js";
import { resolveOsSummary } from "../infra/os-summary.js";
import { runExec } from "../process/exec.js";
import type { RuntimeEnv } from "../runtime.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import type { buildChannelsTable as buildChannelsTableFn } from "./status-all/channels.js";
import { getAgentLocalStatuses } from "./status.agent-local.js";
import type {
buildChannelsTable as buildChannelsTableFn,
collectChannelStatusIssues as collectChannelStatusIssuesFn,
} from "./status.scan.runtime.js";
import {
buildTailscaleHttpsUrl,
pickGatewaySelfPresence,
@@ -30,7 +29,6 @@ import { getUpdateCheckResult } from "./status.update.js";
type DeferredResult<T> = { ok: true; value: T } | { ok: false; error: unknown };
let pluginRegistryModulePromise: Promise<typeof import("../cli/plugin-registry.js")> | undefined;
let statusScanRuntimeModulePromise: Promise<typeof import("./status.scan.runtime.js")> | undefined;
let statusScanDepsRuntimeModulePromise:
| Promise<typeof import("./status.scan.deps.runtime.js")>
| undefined;
@@ -40,10 +38,10 @@ function loadPluginRegistryModule() {
return pluginRegistryModulePromise;
}
function loadStatusScanRuntimeModule() {
statusScanRuntimeModulePromise ??= import("./status.scan.runtime.js");
return statusScanRuntimeModulePromise;
}
const loadStatusScanRuntimeModule = createLazyRuntimeSurface(
() => import("./status.scan.runtime.js"),
({ statusScanRuntime }) => statusScanRuntime,
);
function loadStatusScanDepsRuntimeModule() {
statusScanDepsRuntimeModulePromise ??= import("./status.scan.deps.runtime.js");

View File

@@ -1,2 +1,8 @@
export { resolveContextTokensForModel } from "../agents/context.js";
export { classifySessionKey, resolveSessionModelRef } from "../gateway/session-utils.js";
import { resolveContextTokensForModel } from "../agents/context.js";
import { classifySessionKey, resolveSessionModelRef } from "../gateway/session-utils.js";
export const statusSummaryRuntime = {
resolveContextTokensForModel,
classifySessionKey,
resolveSessionModelRef,
};

View File

@@ -10,14 +10,12 @@ import { listGatewayAgentsBasic } from "../gateway/agent-list.js";
import { resolveHeartbeatSummaryForAgent } from "../infra/heartbeat-summary.js";
import { peekSystemEvents } from "../infra/system-events.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import { resolveRuntimeServiceVersion } from "../version.js";
import type { HeartbeatStatus, SessionStatus, StatusSummary } from "./status.types.js";
let channelSummaryModulePromise: Promise<typeof import("../infra/channel-summary.js")> | undefined;
let linkChannelModulePromise: Promise<typeof import("./status.link-channel.js")> | undefined;
let statusSummaryRuntimeModulePromise:
| Promise<typeof import("./status.summary.runtime.js")>
| undefined;
let configIoModulePromise: Promise<typeof import("../config/io.js")> | undefined;
function loadChannelSummaryModule() {
@@ -30,10 +28,10 @@ function loadLinkChannelModule() {
return linkChannelModulePromise;
}
function loadStatusSummaryRuntimeModule() {
statusSummaryRuntimeModulePromise ??= import("./status.summary.runtime.js");
return statusSummaryRuntimeModulePromise;
}
const loadStatusSummaryRuntimeModule = createLazyRuntimeSurface(
() => import("./status.summary.runtime.js"),
({ statusSummaryRuntime }) => statusSummaryRuntime,
);
function loadConfigIoModule() {
configIoModulePromise ??= import("../config/io.js");

View File

@@ -40,13 +40,13 @@ export type {
export type { OpenClawConfig } from "../config/config.js";
/** @deprecated Use OpenClawConfig instead */
export type { OpenClawConfig as ClawdbotConfig } from "../config/config.js";
export { registerContextEngine } from "../context-engine/index.js";
export * from "./image-generation.js";
export type { SecretInput, SecretRef } from "../config/types.secrets.js";
export type { RuntimeEnv } from "../runtime.js";
export type { HookEntry } from "../hooks/types.js";
export type { ReplyPayload } from "../auto-reply/types.js";
export type { WizardPrompter } from "../wizard/prompts.js";
export type { ContextEngineFactory } from "../context-engine/index.js";
export type { ContextEngineFactory } from "../context-engine/registry.js";
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { registerContextEngine } from "../context-engine/registry.js";

View File

@@ -6,7 +6,7 @@ import {
} from "./provider-auth-input.js";
import { applyPrimaryModel } from "./provider-model-primary.js";
export {
export const providerApiKeyAuthRuntime = {
applyAuthProfileConfig,
applyPrimaryModel,
buildApiKeyCredential,

View File

@@ -1,6 +1,7 @@
import { upsertAuthProfile } from "../agents/auth-profiles/profiles.js";
import type { OpenClawConfig } from "../config/config.js";
import type { SecretInput } from "../config/types.secrets.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import { normalizeOptionalSecretInput } from "../utils/normalize-secret-input.js";
import type {
ProviderAuthMethod,
@@ -29,14 +30,10 @@ type ProviderApiKeyAuthMethodOptions = {
applyConfig?: (cfg: OpenClawConfig) => OpenClawConfig;
};
let providerApiKeyAuthRuntimePromise:
| Promise<typeof import("./provider-api-key-auth.runtime.js")>
| undefined;
function loadProviderApiKeyAuthRuntime() {
providerApiKeyAuthRuntimePromise ??= import("./provider-api-key-auth.runtime.js");
return providerApiKeyAuthRuntimePromise;
}
const loadProviderApiKeyAuthRuntime = createLazyRuntimeSurface(
() => import("./provider-api-key-auth.runtime.js"),
({ providerApiKeyAuthRuntime }) => providerApiKeyAuthRuntime,
);
function resolveStringOption(opts: Record<string, unknown> | undefined, optionKey: string) {
return normalizeOptionalSecretInput(opts?.[optionKey]);

View File

@@ -9,123 +9,121 @@ import {
setThreadBindingMaxAgeBySessionKey,
unbindThreadBindingsBySessionKey,
} from "../../../extensions/discord/src/monitor/thread-bindings.js";
import { createLazyRuntimeMethod, 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;
let runtimeDiscordOpsPromise: Promise<RuntimeDiscordOps> | null = null;
const loadRuntimeDiscordOps = createLazyRuntimeSurface(
() => import("./runtime-discord-ops.runtime.js"),
({ runtimeDiscordOps }) => runtimeDiscordOps,
);
function loadRuntimeDiscordOps() {
runtimeDiscordOpsPromise ??= import("./runtime-discord-ops.runtime.js").then(
({ runtimeDiscordOps }) => runtimeDiscordOps,
);
return runtimeDiscordOpsPromise;
}
const auditChannelPermissionsLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["auditChannelPermissions"]>,
ReturnType<PluginRuntimeChannel["discord"]["auditChannelPermissions"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.auditChannelPermissions);
const auditChannelPermissionsLazy: PluginRuntimeChannel["discord"]["auditChannelPermissions"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.auditChannelPermissions(...args);
};
const listDirectoryGroupsLiveLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"]>,
ReturnType<PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.listDirectoryGroupsLive);
const listDirectoryGroupsLiveLazy: PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.listDirectoryGroupsLive(...args);
};
const listDirectoryPeersLiveLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["listDirectoryPeersLive"]>,
ReturnType<PluginRuntimeChannel["discord"]["listDirectoryPeersLive"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.listDirectoryPeersLive);
const listDirectoryPeersLiveLazy: PluginRuntimeChannel["discord"]["listDirectoryPeersLive"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.listDirectoryPeersLive(...args);
};
const probeDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["probeDiscord"]>,
ReturnType<PluginRuntimeChannel["discord"]["probeDiscord"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.probeDiscord);
const probeDiscordLazy: PluginRuntimeChannel["discord"]["probeDiscord"] = async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.probeDiscord(...args);
};
const resolveChannelAllowlistLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["resolveChannelAllowlist"]>,
ReturnType<PluginRuntimeChannel["discord"]["resolveChannelAllowlist"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.resolveChannelAllowlist);
const resolveChannelAllowlistLazy: PluginRuntimeChannel["discord"]["resolveChannelAllowlist"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.resolveChannelAllowlist(...args);
};
const resolveUserAllowlistLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["resolveUserAllowlist"]>,
ReturnType<PluginRuntimeChannel["discord"]["resolveUserAllowlist"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.resolveUserAllowlist);
const resolveUserAllowlistLazy: PluginRuntimeChannel["discord"]["resolveUserAllowlist"] = async (
...args
) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.resolveUserAllowlist(...args);
};
const sendComponentMessageLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["sendComponentMessage"]>,
ReturnType<PluginRuntimeChannel["discord"]["sendComponentMessage"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.sendComponentMessage);
const sendComponentMessageLazy: PluginRuntimeChannel["discord"]["sendComponentMessage"] = async (
...args
) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.sendComponentMessage(...args);
};
const sendMessageDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["sendMessageDiscord"]>,
ReturnType<PluginRuntimeChannel["discord"]["sendMessageDiscord"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.sendMessageDiscord);
const sendMessageDiscordLazy: PluginRuntimeChannel["discord"]["sendMessageDiscord"] = async (
...args
) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.sendMessageDiscord(...args);
};
const sendPollDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["sendPollDiscord"]>,
ReturnType<PluginRuntimeChannel["discord"]["sendPollDiscord"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.sendPollDiscord);
const sendPollDiscordLazy: PluginRuntimeChannel["discord"]["sendPollDiscord"] = async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.sendPollDiscord(...args);
};
const monitorDiscordProviderLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["monitorDiscordProvider"]>,
ReturnType<PluginRuntimeChannel["discord"]["monitorDiscordProvider"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.monitorDiscordProvider);
const monitorDiscordProviderLazy: PluginRuntimeChannel["discord"]["monitorDiscordProvider"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.monitorDiscordProvider(...args);
};
const sendTypingDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["typing"]["pulse"]>,
ReturnType<PluginRuntimeChannel["discord"]["typing"]["pulse"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.typing.pulse);
const sendTypingDiscordLazy: PluginRuntimeChannel["discord"]["typing"]["pulse"] = async (
...args
) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.typing.pulse(...args);
};
const editMessageDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"]>,
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.editMessage);
const editMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.conversationActions.editMessage(...args);
};
const deleteMessageDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"]>,
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"]>
>(
loadRuntimeDiscordOps,
(runtimeDiscordOps) => runtimeDiscordOps.conversationActions.deleteMessage,
);
const deleteMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.conversationActions.deleteMessage(...args);
};
const pinMessageDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"]>,
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.pinMessage);
const pinMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.conversationActions.pinMessage(...args);
};
const unpinMessageDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"]>,
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.unpinMessage);
const unpinMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.conversationActions.unpinMessage(...args);
};
const createThreadDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["createThread"]>,
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["createThread"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.createThread);
const createThreadDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["createThread"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.conversationActions.createThread(...args);
};
const editChannelDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"] =
async (...args) => {
const runtimeDiscordOps = await loadRuntimeDiscordOps();
return runtimeDiscordOps.conversationActions.editChannel(...args);
};
const editChannelDiscordLazy = createLazyRuntimeMethod<
RuntimeDiscordOps,
Parameters<PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"]>,
ReturnType<PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"]>
>(loadRuntimeDiscordOps, (runtimeDiscordOps) => runtimeDiscordOps.conversationActions.editChannel);
export function createRuntimeDiscord(): PluginRuntimeChannel["discord"] {
return {

View File

@@ -1,65 +1,60 @@
import { createLazyRuntimeMethod, createLazyRuntimeSurface } from "../../shared/lazy-runtime.js";
import type { PluginRuntimeChannel } from "./types-channel.js";
type RuntimeSlackOps = typeof import("./runtime-slack-ops.runtime.js").runtimeSlackOps;
let runtimeSlackOpsPromise: Promise<RuntimeSlackOps> | null = null;
const loadRuntimeSlackOps = createLazyRuntimeSurface(
() => import("./runtime-slack-ops.runtime.js"),
({ runtimeSlackOps }) => runtimeSlackOps,
);
function loadRuntimeSlackOps() {
runtimeSlackOpsPromise ??= import("./runtime-slack-ops.runtime.js").then(
({ runtimeSlackOps }) => runtimeSlackOps,
);
return runtimeSlackOpsPromise;
}
const listDirectoryGroupsLiveLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"]>,
ReturnType<PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.listDirectoryGroupsLive);
const listDirectoryGroupsLiveLazy: PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"] =
async (...args) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.listDirectoryGroupsLive(...args);
};
const listDirectoryPeersLiveLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["listDirectoryPeersLive"]>,
ReturnType<PluginRuntimeChannel["slack"]["listDirectoryPeersLive"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.listDirectoryPeersLive);
const listDirectoryPeersLiveLazy: PluginRuntimeChannel["slack"]["listDirectoryPeersLive"] = async (
...args
) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.listDirectoryPeersLive(...args);
};
const probeSlackLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["probeSlack"]>,
ReturnType<PluginRuntimeChannel["slack"]["probeSlack"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.probeSlack);
const probeSlackLazy: PluginRuntimeChannel["slack"]["probeSlack"] = async (...args) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.probeSlack(...args);
};
const resolveChannelAllowlistLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["resolveChannelAllowlist"]>,
ReturnType<PluginRuntimeChannel["slack"]["resolveChannelAllowlist"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.resolveChannelAllowlist);
const resolveChannelAllowlistLazy: PluginRuntimeChannel["slack"]["resolveChannelAllowlist"] =
async (...args) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.resolveChannelAllowlist(...args);
};
const resolveUserAllowlistLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["resolveUserAllowlist"]>,
ReturnType<PluginRuntimeChannel["slack"]["resolveUserAllowlist"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.resolveUserAllowlist);
const resolveUserAllowlistLazy: PluginRuntimeChannel["slack"]["resolveUserAllowlist"] = async (
...args
) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.resolveUserAllowlist(...args);
};
const sendMessageSlackLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["sendMessageSlack"]>,
ReturnType<PluginRuntimeChannel["slack"]["sendMessageSlack"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.sendMessageSlack);
const sendMessageSlackLazy: PluginRuntimeChannel["slack"]["sendMessageSlack"] = async (...args) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.sendMessageSlack(...args);
};
const monitorSlackProviderLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["monitorSlackProvider"]>,
ReturnType<PluginRuntimeChannel["slack"]["monitorSlackProvider"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.monitorSlackProvider);
const monitorSlackProviderLazy: PluginRuntimeChannel["slack"]["monitorSlackProvider"] = async (
...args
) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.monitorSlackProvider(...args);
};
const handleSlackActionLazy: PluginRuntimeChannel["slack"]["handleSlackAction"] = async (
...args
) => {
const runtimeSlackOps = await loadRuntimeSlackOps();
return runtimeSlackOps.handleSlackAction(...args);
};
const handleSlackActionLazy = createLazyRuntimeMethod<
RuntimeSlackOps,
Parameters<PluginRuntimeChannel["slack"]["handleSlackAction"]>,
ReturnType<PluginRuntimeChannel["slack"]["handleSlackAction"]>
>(loadRuntimeSlackOps, (runtimeSlackOps) => runtimeSlackOps.handleSlackAction);
export function createRuntimeSlack(): PluginRuntimeChannel["slack"] {
return {

View File

@@ -5,94 +5,106 @@ 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 { createTelegramTypingLease } from "./runtime-telegram-typing.js";
import type { PluginRuntimeChannel } from "./types-channel.js";
type RuntimeTelegramOps = typeof import("./runtime-telegram-ops.runtime.js").runtimeTelegramOps;
let runtimeTelegramOpsPromise: Promise<RuntimeTelegramOps> | null = null;
const loadRuntimeTelegramOps = createLazyRuntimeSurface(
() => import("./runtime-telegram-ops.runtime.js"),
({ runtimeTelegramOps }) => runtimeTelegramOps,
);
function loadRuntimeTelegramOps() {
runtimeTelegramOpsPromise ??= import("./runtime-telegram-ops.runtime.js").then(
({ runtimeTelegramOps }) => runtimeTelegramOps,
);
return runtimeTelegramOpsPromise;
}
const auditGroupMembershipLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["auditGroupMembership"]>,
ReturnType<PluginRuntimeChannel["telegram"]["auditGroupMembership"]>
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.auditGroupMembership);
const auditGroupMembershipLazy: PluginRuntimeChannel["telegram"]["auditGroupMembership"] = async (
...args
) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.auditGroupMembership(...args);
};
const probeTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["probeTelegram"]>,
ReturnType<PluginRuntimeChannel["telegram"]["probeTelegram"]>
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.probeTelegram);
const probeTelegramLazy: PluginRuntimeChannel["telegram"]["probeTelegram"] = async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.probeTelegram(...args);
};
const sendMessageTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["sendMessageTelegram"]>,
ReturnType<PluginRuntimeChannel["telegram"]["sendMessageTelegram"]>
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.sendMessageTelegram);
const sendMessageTelegramLazy: PluginRuntimeChannel["telegram"]["sendMessageTelegram"] = async (
...args
) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.sendMessageTelegram(...args);
};
const sendPollTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["sendPollTelegram"]>,
ReturnType<PluginRuntimeChannel["telegram"]["sendPollTelegram"]>
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.sendPollTelegram);
const sendPollTelegramLazy: PluginRuntimeChannel["telegram"]["sendPollTelegram"] = async (
...args
) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.sendPollTelegram(...args);
};
const monitorTelegramProviderLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["monitorTelegramProvider"]>,
ReturnType<PluginRuntimeChannel["telegram"]["monitorTelegramProvider"]>
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.monitorTelegramProvider);
const monitorTelegramProviderLazy: PluginRuntimeChannel["telegram"]["monitorTelegramProvider"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.monitorTelegramProvider(...args);
};
const sendTypingTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["typing"]["pulse"]>,
ReturnType<PluginRuntimeChannel["telegram"]["typing"]["pulse"]>
>(loadRuntimeTelegramOps, (runtimeTelegramOps) => runtimeTelegramOps.typing.pulse);
const sendTypingTelegramLazy: PluginRuntimeChannel["telegram"]["typing"]["pulse"] = async (
...args
) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.typing.pulse(...args);
};
const editMessageTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"]>,
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"]>
>(
loadRuntimeTelegramOps,
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.editMessage,
);
const editMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.conversationActions.editMessage(...args);
};
const editMessageReplyMarkupTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"]>,
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"]>
>(
loadRuntimeTelegramOps,
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.editReplyMarkup,
);
const editMessageReplyMarkupTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.conversationActions.editReplyMarkup(...args);
};
const deleteMessageTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"]>,
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"]>
>(
loadRuntimeTelegramOps,
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.deleteMessage,
);
const deleteMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.conversationActions.deleteMessage(...args);
};
const renameForumTopicTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"]>,
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"]>
>(
loadRuntimeTelegramOps,
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.renameTopic,
);
const renameForumTopicTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.conversationActions.renameTopic(...args);
};
const pinMessageTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"]>,
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"]>
>(
loadRuntimeTelegramOps,
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.pinMessage,
);
const pinMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.conversationActions.pinMessage(...args);
};
const unpinMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"] =
async (...args) => {
const runtimeTelegramOps = await loadRuntimeTelegramOps();
return runtimeTelegramOps.conversationActions.unpinMessage(...args);
};
const unpinMessageTelegramLazy = createLazyRuntimeMethod<
RuntimeTelegramOps,
Parameters<PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"]>,
ReturnType<PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"]>
>(
loadRuntimeTelegramOps,
(runtimeTelegramOps) => runtimeTelegramOps.conversationActions.unpinMessage,
);
export function createRuntimeTelegram(): PluginRuntimeChannel["telegram"] {
return {

View File

@@ -6,6 +6,7 @@ import {
readWebSelfId,
webAuthExists,
} from "../../../extensions/whatsapp/src/auth-store.js";
import { createLazyRuntimeMethod, createLazyRuntimeSurface } from "../../shared/lazy-runtime.js";
import { createRuntimeWhatsAppLoginTool } from "./runtime-whatsapp-login-tool.js";
import type { PluginRuntime } from "./types.js";
@@ -14,24 +15,33 @@ type RuntimeWhatsAppOutbound =
type RuntimeWhatsAppLogin =
typeof import("./runtime-whatsapp-login.runtime.js").runtimeWhatsAppLogin;
const sendMessageWhatsAppLazy: PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"] = async (
...args
) => {
const runtimeWhatsAppOutbound = await loadWebOutbound();
return runtimeWhatsAppOutbound.sendMessageWhatsApp(...args);
};
const loadWebOutbound = createLazyRuntimeSurface(
() => import("./runtime-whatsapp-outbound.runtime.js"),
({ runtimeWhatsAppOutbound }) => runtimeWhatsAppOutbound,
);
const sendPollWhatsAppLazy: PluginRuntime["channel"]["whatsapp"]["sendPollWhatsApp"] = async (
...args
) => {
const runtimeWhatsAppOutbound = await loadWebOutbound();
return runtimeWhatsAppOutbound.sendPollWhatsApp(...args);
};
const loadWebLogin = createLazyRuntimeSurface(
() => import("./runtime-whatsapp-login.runtime.js"),
({ runtimeWhatsAppLogin }) => runtimeWhatsAppLogin,
);
const loginWebLazy: PluginRuntime["channel"]["whatsapp"]["loginWeb"] = async (...args) => {
const runtimeWhatsAppLogin = await loadWebLogin();
return runtimeWhatsAppLogin.loginWeb(...args);
};
const sendMessageWhatsAppLazy = createLazyRuntimeMethod<
RuntimeWhatsAppOutbound,
Parameters<PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"]>,
ReturnType<PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"]>
>(loadWebOutbound, (runtimeWhatsAppOutbound) => runtimeWhatsAppOutbound.sendMessageWhatsApp);
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 startWebLoginWithQrLazy: PluginRuntime["channel"]["whatsapp"]["startWebLoginWithQr"] = async (
...args
@@ -64,26 +74,10 @@ let webLoginQrPromise: Promise<
typeof import("../../../extensions/whatsapp/src/login-qr.js")
> | null = null;
let webChannelPromise: Promise<typeof import("../../channels/web/index.js")> | null = null;
let webOutboundPromise: Promise<RuntimeWhatsAppOutbound> | null = null;
let webLoginPromise: Promise<RuntimeWhatsAppLogin> | null = null;
let whatsappActionsPromise: Promise<
typeof import("../../agents/tools/whatsapp-actions.js")
> | null = null;
function loadWebOutbound() {
webOutboundPromise ??= import("./runtime-whatsapp-outbound.runtime.js").then(
({ runtimeWhatsAppOutbound }) => runtimeWhatsAppOutbound,
);
return webOutboundPromise;
}
function loadWebLogin() {
webLoginPromise ??= import("./runtime-whatsapp-login.runtime.js").then(
({ runtimeWhatsAppLogin }) => runtimeWhatsAppLogin,
);
return webLoginPromise;
}
function loadWebLoginQr() {
webLoginQrPromise ??= import("../../../extensions/whatsapp/src/login-qr.js");
return webLoginQrPromise;

View File

@@ -1 +1,10 @@
export { collectChannelSecurityFindings } from "./audit-channel.js";
import { collectChannelSecurityFindings as collectChannelSecurityFindingsImpl } from "./audit-channel.js";
type CollectChannelSecurityFindings =
typeof import("./audit-channel.js").collectChannelSecurityFindings;
export function collectChannelSecurityFindings(
...args: Parameters<CollectChannelSecurityFindings>
): ReturnType<CollectChannelSecurityFindings> {
return collectChannelSecurityFindingsImpl(...args);
}

View File

@@ -1,9 +1,17 @@
export { readChannelAllowFromStore } from "../pairing/pairing-store.js";
export {
isDiscordMutableAllowEntry,
isZalouserMutableGroupEntry,
} from "./mutable-allowlist-detectors.js";
export {
import { readChannelAllowFromStore } from "../pairing/pairing-store.js";
import {
isNumericTelegramUserId,
normalizeTelegramAllowFromEntry,
} from "../plugin-sdk/telegram.js";
import {
isDiscordMutableAllowEntry,
isZalouserMutableGroupEntry,
} from "./mutable-allowlist-detectors.js";
export const auditChannelRuntime = {
readChannelAllowFromStore,
isDiscordMutableAllowEntry,
isZalouserMutableGroupEntry,
isNumericTelegramUserId,
normalizeTelegramAllowFromEntry,
};

View File

@@ -11,18 +11,15 @@ import { resolveNativeCommandsEnabled, resolveNativeSkillsEnabled } from "../con
import type { OpenClawConfig } from "../config/config.js";
import { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js";
import { formatErrorMessage } from "../infra/errors.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import { normalizeStringEntries } from "../shared/string-normalization.js";
import type { SecurityAuditFinding, SecurityAuditSeverity } from "./audit.js";
import { resolveDmAllowState } from "./dm-policy-shared.js";
let auditChannelRuntimeModulePromise:
| Promise<typeof import("./audit-channel.runtime.js")>
| undefined;
function loadAuditChannelRuntimeModule() {
auditChannelRuntimeModulePromise ??= import("./audit-channel.runtime.js");
return auditChannelRuntimeModulePromise;
}
const loadAuditChannelRuntimeModule = createLazyRuntimeSurface(
() => import("./audit-channel.runtime.js"),
({ auditChannelRuntime }) => auditChannelRuntime,
);
function normalizeAllowFromList(list: Array<string | number> | undefined | null): string[] {
return normalizeStringEntries(Array.isArray(list) ? list : undefined);

View File

@@ -1 +1,9 @@
export { runSecurityAudit } from "./audit.js";
import { runSecurityAudit as runSecurityAuditImpl } from "./audit.js";
type RunSecurityAudit = typeof import("./audit.js").runSecurityAudit;
export function runSecurityAudit(
...args: Parameters<RunSecurityAudit>
): ReturnType<RunSecurityAudit> {
return runSecurityAuditImpl(...args);
}

View File

@@ -0,0 +1,21 @@
export function createLazyRuntimeSurface<TModule, TSurface>(
importer: () => Promise<TModule>,
select: (module: TModule) => TSurface,
): () => Promise<TSurface> {
let cached: Promise<TSurface> | null = null;
return () => {
cached ??= importer().then(select);
return cached;
};
}
export function createLazyRuntimeMethod<TSurface, TArgs extends unknown[], TResult>(
load: () => Promise<TSurface>,
select: (surface: TSurface) => (...args: TArgs) => TResult,
): (...args: TArgs) => Promise<Awaited<TResult>> {
const invoke = async (...args: TArgs): Promise<Awaited<TResult>> => {
const method = select(await load());
return await method(...args);
};
return invoke;
}