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

@@ -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,