mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 07:31:44 +00:00
refactor: bundle lazy runtime surfaces
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { clearRuntimeAuthProfileStoreSnapshots } from "../../agents/auth-profiles/store.js";
|
||||
import {
|
||||
createAuthTestLifecycle,
|
||||
createExitThrowingRuntime,
|
||||
@@ -7,7 +6,8 @@ import {
|
||||
readAuthProfilesForAgent,
|
||||
requireOpenClawAgentDir,
|
||||
setupAuthTestEnv,
|
||||
} from "../../commands/test-wizard-helpers.js";
|
||||
} from "../../../test/helpers/auth-wizard.js";
|
||||
import { clearRuntimeAuthProfileStoreSnapshots } from "../../agents/auth-profiles/store.js";
|
||||
import { applyAuthChoiceLoadedPluginProvider } from "../../plugins/provider-auth-choice.js";
|
||||
import { buildProviderPluginMethodChoice } from "../provider-wizard.js";
|
||||
import { requireProviderContractProvider, uniqueProviderContractProviders } from "./registry.js";
|
||||
@@ -27,7 +27,6 @@ const resolveProviderPluginChoiceMock = vi.hoisted(() => vi.fn<ResolveProviderPl
|
||||
const runProviderModelSelectedHookMock = vi.hoisted(() =>
|
||||
vi.fn<RunProviderModelSelectedHook>(async () => {}),
|
||||
);
|
||||
const resolvePreferredProviderPluginProvidersMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../../../extensions/qwen-portal-auth/oauth.js", () => ({
|
||||
loginQwenPortalOAuth: loginQwenPortalOAuthMock,
|
||||
@@ -43,15 +42,6 @@ vi.mock("../../plugins/provider-auth-choice.runtime.js", () => ({
|
||||
runProviderModelSelectedHook: runProviderModelSelectedHookMock,
|
||||
}));
|
||||
|
||||
vi.mock("../../plugins/providers.js", async () => {
|
||||
const actual = await vi.importActual<object>("../../plugins/providers.js");
|
||||
return {
|
||||
...actual,
|
||||
resolvePluginProviders: (...args: unknown[]) =>
|
||||
resolvePreferredProviderPluginProvidersMock(...args),
|
||||
};
|
||||
});
|
||||
|
||||
const { resolvePreferredProviderForAuthChoice } =
|
||||
await import("../../plugins/provider-auth-choice-preference.js");
|
||||
|
||||
@@ -84,8 +74,24 @@ describe("provider auth-choice contract", () => {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
resolvePreferredProviderPluginProvidersMock.mockReset();
|
||||
resolvePreferredProviderPluginProvidersMock.mockReturnValue(uniqueProviderContractProviders);
|
||||
resolvePluginProvidersMock.mockReset();
|
||||
resolvePluginProvidersMock.mockReturnValue(uniqueProviderContractProviders);
|
||||
resolveProviderPluginChoiceMock.mockReset();
|
||||
resolveProviderPluginChoiceMock.mockImplementation(({ providers, choice }) => {
|
||||
const provider = providers.find((entry) =>
|
||||
entry.auth.some(
|
||||
(method) => buildProviderPluginMethodChoice(entry.id, method.id) === choice,
|
||||
),
|
||||
);
|
||||
if (!provider) {
|
||||
return null;
|
||||
}
|
||||
const method =
|
||||
provider.auth.find(
|
||||
(entry) => buildProviderPluginMethodChoice(provider.id, entry.id) === choice,
|
||||
) ?? null;
|
||||
return method ? { provider, method } : null;
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -117,18 +123,18 @@ describe("provider auth-choice contract", () => {
|
||||
});
|
||||
|
||||
for (const scenario of pluginFallbackScenarios) {
|
||||
resolvePreferredProviderPluginProvidersMock.mockClear();
|
||||
resolvePluginProvidersMock.mockClear();
|
||||
await expect(
|
||||
resolvePreferredProviderForAuthChoice({ choice: scenario.authChoice }),
|
||||
).resolves.toBe(scenario.expectedProvider);
|
||||
expect(resolvePreferredProviderPluginProvidersMock).toHaveBeenCalled();
|
||||
expect(resolvePluginProvidersMock).toHaveBeenCalled();
|
||||
}
|
||||
|
||||
resolvePreferredProviderPluginProvidersMock.mockClear();
|
||||
resolvePluginProvidersMock.mockClear();
|
||||
await expect(resolvePreferredProviderForAuthChoice({ choice: "unknown" })).resolves.toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(resolvePreferredProviderPluginProvidersMock).toHaveBeenCalled();
|
||||
expect(resolvePluginProvidersMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("applies qwen portal auth choices through the shared plugin-provider path", async () => {
|
||||
|
||||
@@ -518,7 +518,7 @@ describe("provider runtime contract", () => {
|
||||
});
|
||||
|
||||
it("falls back to legacy pi auth tokens for usage auth", async () => {
|
||||
const provider = requireProvider("zai");
|
||||
const provider = requireProviderContractProvider("zai");
|
||||
const home = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-zai-contract-"));
|
||||
await fs.mkdir(path.join(home, ".pi", "agent"), { recursive: true });
|
||||
await fs.writeFile(
|
||||
|
||||
@@ -19,132 +19,48 @@ import {
|
||||
sendTypingDiscord as sendTypingDiscordImpl,
|
||||
unpinMessageDiscord as unpinMessageDiscordImpl,
|
||||
} from "../../../extensions/discord/src/send.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
type AuditDiscordChannelPermissions =
|
||||
typeof import("../../../extensions/discord/src/audit.js").auditDiscordChannelPermissions;
|
||||
type ListDiscordDirectoryGroupsLive =
|
||||
typeof import("../../../extensions/discord/src/directory-live.js").listDiscordDirectoryGroupsLive;
|
||||
type ListDiscordDirectoryPeersLive =
|
||||
typeof import("../../../extensions/discord/src/directory-live.js").listDiscordDirectoryPeersLive;
|
||||
type MonitorDiscordProvider =
|
||||
typeof import("../../../extensions/discord/src/monitor.js").monitorDiscordProvider;
|
||||
type ProbeDiscord = typeof import("../../../extensions/discord/src/probe.js").probeDiscord;
|
||||
type ResolveDiscordChannelAllowlist =
|
||||
typeof import("../../../extensions/discord/src/resolve-channels.js").resolveDiscordChannelAllowlist;
|
||||
type ResolveDiscordUserAllowlist =
|
||||
typeof import("../../../extensions/discord/src/resolve-users.js").resolveDiscordUserAllowlist;
|
||||
type CreateThreadDiscord =
|
||||
typeof import("../../../extensions/discord/src/send.js").createThreadDiscord;
|
||||
type DeleteMessageDiscord =
|
||||
typeof import("../../../extensions/discord/src/send.js").deleteMessageDiscord;
|
||||
type EditChannelDiscord =
|
||||
typeof import("../../../extensions/discord/src/send.js").editChannelDiscord;
|
||||
type EditMessageDiscord =
|
||||
typeof import("../../../extensions/discord/src/send.js").editMessageDiscord;
|
||||
type PinMessageDiscord = typeof import("../../../extensions/discord/src/send.js").pinMessageDiscord;
|
||||
type SendDiscordComponentMessage =
|
||||
typeof import("../../../extensions/discord/src/send.js").sendDiscordComponentMessage;
|
||||
type SendMessageDiscord =
|
||||
typeof import("../../../extensions/discord/src/send.js").sendMessageDiscord;
|
||||
type SendPollDiscord = typeof import("../../../extensions/discord/src/send.js").sendPollDiscord;
|
||||
type SendTypingDiscord = typeof import("../../../extensions/discord/src/send.js").sendTypingDiscord;
|
||||
type UnpinMessageDiscord =
|
||||
typeof import("../../../extensions/discord/src/send.js").unpinMessageDiscord;
|
||||
type RuntimeDiscordOps = Pick<
|
||||
PluginRuntimeChannel["discord"],
|
||||
| "auditChannelPermissions"
|
||||
| "listDirectoryGroupsLive"
|
||||
| "listDirectoryPeersLive"
|
||||
| "probeDiscord"
|
||||
| "resolveChannelAllowlist"
|
||||
| "resolveUserAllowlist"
|
||||
| "sendComponentMessage"
|
||||
| "sendMessageDiscord"
|
||||
| "sendPollDiscord"
|
||||
| "monitorDiscordProvider"
|
||||
> & {
|
||||
typing: Pick<PluginRuntimeChannel["discord"]["typing"], "pulse">;
|
||||
conversationActions: Pick<
|
||||
PluginRuntimeChannel["discord"]["conversationActions"],
|
||||
"editMessage" | "deleteMessage" | "pinMessage" | "unpinMessage" | "createThread" | "editChannel"
|
||||
>;
|
||||
};
|
||||
|
||||
export function auditDiscordChannelPermissions(
|
||||
...args: Parameters<AuditDiscordChannelPermissions>
|
||||
): ReturnType<AuditDiscordChannelPermissions> {
|
||||
return auditDiscordChannelPermissionsImpl(...args);
|
||||
}
|
||||
|
||||
export function listDiscordDirectoryGroupsLive(
|
||||
...args: Parameters<ListDiscordDirectoryGroupsLive>
|
||||
): ReturnType<ListDiscordDirectoryGroupsLive> {
|
||||
return listDiscordDirectoryGroupsLiveImpl(...args);
|
||||
}
|
||||
|
||||
export function listDiscordDirectoryPeersLive(
|
||||
...args: Parameters<ListDiscordDirectoryPeersLive>
|
||||
): ReturnType<ListDiscordDirectoryPeersLive> {
|
||||
return listDiscordDirectoryPeersLiveImpl(...args);
|
||||
}
|
||||
|
||||
export function monitorDiscordProvider(
|
||||
...args: Parameters<MonitorDiscordProvider>
|
||||
): ReturnType<MonitorDiscordProvider> {
|
||||
return monitorDiscordProviderImpl(...args);
|
||||
}
|
||||
|
||||
export function probeDiscord(...args: Parameters<ProbeDiscord>): ReturnType<ProbeDiscord> {
|
||||
return probeDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function resolveDiscordChannelAllowlist(
|
||||
...args: Parameters<ResolveDiscordChannelAllowlist>
|
||||
): ReturnType<ResolveDiscordChannelAllowlist> {
|
||||
return resolveDiscordChannelAllowlistImpl(...args);
|
||||
}
|
||||
|
||||
export function resolveDiscordUserAllowlist(
|
||||
...args: Parameters<ResolveDiscordUserAllowlist>
|
||||
): ReturnType<ResolveDiscordUserAllowlist> {
|
||||
return resolveDiscordUserAllowlistImpl(...args);
|
||||
}
|
||||
|
||||
export function createThreadDiscord(
|
||||
...args: Parameters<CreateThreadDiscord>
|
||||
): ReturnType<CreateThreadDiscord> {
|
||||
return createThreadDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function deleteMessageDiscord(
|
||||
...args: Parameters<DeleteMessageDiscord>
|
||||
): ReturnType<DeleteMessageDiscord> {
|
||||
return deleteMessageDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function editChannelDiscord(
|
||||
...args: Parameters<EditChannelDiscord>
|
||||
): ReturnType<EditChannelDiscord> {
|
||||
return editChannelDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function editMessageDiscord(
|
||||
...args: Parameters<EditMessageDiscord>
|
||||
): ReturnType<EditMessageDiscord> {
|
||||
return editMessageDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function pinMessageDiscord(
|
||||
...args: Parameters<PinMessageDiscord>
|
||||
): ReturnType<PinMessageDiscord> {
|
||||
return pinMessageDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function sendDiscordComponentMessage(
|
||||
...args: Parameters<SendDiscordComponentMessage>
|
||||
): ReturnType<SendDiscordComponentMessage> {
|
||||
return sendDiscordComponentMessageImpl(...args);
|
||||
}
|
||||
|
||||
export function sendMessageDiscord(
|
||||
...args: Parameters<SendMessageDiscord>
|
||||
): ReturnType<SendMessageDiscord> {
|
||||
return sendMessageDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function sendPollDiscord(...args: Parameters<SendPollDiscord>): ReturnType<SendPollDiscord> {
|
||||
return sendPollDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function sendTypingDiscord(
|
||||
...args: Parameters<SendTypingDiscord>
|
||||
): ReturnType<SendTypingDiscord> {
|
||||
return sendTypingDiscordImpl(...args);
|
||||
}
|
||||
|
||||
export function unpinMessageDiscord(
|
||||
...args: Parameters<UnpinMessageDiscord>
|
||||
): ReturnType<UnpinMessageDiscord> {
|
||||
return unpinMessageDiscordImpl(...args);
|
||||
}
|
||||
export const runtimeDiscordOps = {
|
||||
auditChannelPermissions: auditDiscordChannelPermissionsImpl,
|
||||
listDirectoryGroupsLive: listDiscordDirectoryGroupsLiveImpl,
|
||||
listDirectoryPeersLive: listDiscordDirectoryPeersLiveImpl,
|
||||
probeDiscord: probeDiscordImpl,
|
||||
resolveChannelAllowlist: resolveDiscordChannelAllowlistImpl,
|
||||
resolveUserAllowlist: resolveDiscordUserAllowlistImpl,
|
||||
sendComponentMessage: sendDiscordComponentMessageImpl,
|
||||
sendMessageDiscord: sendMessageDiscordImpl,
|
||||
sendPollDiscord: sendPollDiscordImpl,
|
||||
monitorDiscordProvider: monitorDiscordProviderImpl,
|
||||
typing: {
|
||||
pulse: sendTypingDiscordImpl,
|
||||
},
|
||||
conversationActions: {
|
||||
editMessage: editMessageDiscordImpl,
|
||||
deleteMessage: deleteMessageDiscordImpl,
|
||||
pinMessage: pinMessageDiscordImpl,
|
||||
unpinMessage: unpinMessageDiscordImpl,
|
||||
createThread: createThreadDiscordImpl,
|
||||
editChannel: editChannelDiscordImpl,
|
||||
},
|
||||
} satisfies RuntimeDiscordOps;
|
||||
|
||||
@@ -12,116 +12,119 @@ import {
|
||||
import { createDiscordTypingLease } from "./runtime-discord-typing.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
let runtimeDiscordOpsPromise: Promise<typeof import("./runtime-discord-ops.runtime.js")> | null =
|
||||
null;
|
||||
type RuntimeDiscordOps = typeof import("./runtime-discord-ops.runtime.js").runtimeDiscordOps;
|
||||
|
||||
let runtimeDiscordOpsPromise: Promise<RuntimeDiscordOps> | null = null;
|
||||
|
||||
function loadRuntimeDiscordOps() {
|
||||
runtimeDiscordOpsPromise ??= import("./runtime-discord-ops.runtime.js");
|
||||
runtimeDiscordOpsPromise ??= import("./runtime-discord-ops.runtime.js").then(
|
||||
({ runtimeDiscordOps }) => runtimeDiscordOps,
|
||||
);
|
||||
return runtimeDiscordOpsPromise;
|
||||
}
|
||||
|
||||
const auditChannelPermissionsLazy: PluginRuntimeChannel["discord"]["auditChannelPermissions"] =
|
||||
async (...args) => {
|
||||
const { auditDiscordChannelPermissions } = await loadRuntimeDiscordOps();
|
||||
return auditDiscordChannelPermissions(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.auditChannelPermissions(...args);
|
||||
};
|
||||
|
||||
const listDirectoryGroupsLiveLazy: PluginRuntimeChannel["discord"]["listDirectoryGroupsLive"] =
|
||||
async (...args) => {
|
||||
const { listDiscordDirectoryGroupsLive } = await loadRuntimeDiscordOps();
|
||||
return listDiscordDirectoryGroupsLive(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.listDirectoryGroupsLive(...args);
|
||||
};
|
||||
|
||||
const listDirectoryPeersLiveLazy: PluginRuntimeChannel["discord"]["listDirectoryPeersLive"] =
|
||||
async (...args) => {
|
||||
const { listDiscordDirectoryPeersLive } = await loadRuntimeDiscordOps();
|
||||
return listDiscordDirectoryPeersLive(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.listDirectoryPeersLive(...args);
|
||||
};
|
||||
|
||||
const probeDiscordLazy: PluginRuntimeChannel["discord"]["probeDiscord"] = async (...args) => {
|
||||
const { probeDiscord } = await loadRuntimeDiscordOps();
|
||||
return probeDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.probeDiscord(...args);
|
||||
};
|
||||
|
||||
const resolveChannelAllowlistLazy: PluginRuntimeChannel["discord"]["resolveChannelAllowlist"] =
|
||||
async (...args) => {
|
||||
const { resolveDiscordChannelAllowlist } = await loadRuntimeDiscordOps();
|
||||
return resolveDiscordChannelAllowlist(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.resolveChannelAllowlist(...args);
|
||||
};
|
||||
|
||||
const resolveUserAllowlistLazy: PluginRuntimeChannel["discord"]["resolveUserAllowlist"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { resolveDiscordUserAllowlist } = await loadRuntimeDiscordOps();
|
||||
return resolveDiscordUserAllowlist(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.resolveUserAllowlist(...args);
|
||||
};
|
||||
|
||||
const sendComponentMessageLazy: PluginRuntimeChannel["discord"]["sendComponentMessage"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendDiscordComponentMessage } = await loadRuntimeDiscordOps();
|
||||
return sendDiscordComponentMessage(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.sendComponentMessage(...args);
|
||||
};
|
||||
|
||||
const sendMessageDiscordLazy: PluginRuntimeChannel["discord"]["sendMessageDiscord"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendMessageDiscord } = await loadRuntimeDiscordOps();
|
||||
return sendMessageDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.sendMessageDiscord(...args);
|
||||
};
|
||||
|
||||
const sendPollDiscordLazy: PluginRuntimeChannel["discord"]["sendPollDiscord"] = async (...args) => {
|
||||
const { sendPollDiscord } = await loadRuntimeDiscordOps();
|
||||
return sendPollDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.sendPollDiscord(...args);
|
||||
};
|
||||
|
||||
const monitorDiscordProviderLazy: PluginRuntimeChannel["discord"]["monitorDiscordProvider"] =
|
||||
async (...args) => {
|
||||
const { monitorDiscordProvider } = await loadRuntimeDiscordOps();
|
||||
return monitorDiscordProvider(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.monitorDiscordProvider(...args);
|
||||
};
|
||||
|
||||
const sendTypingDiscordLazy: PluginRuntimeChannel["discord"]["typing"]["pulse"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendTypingDiscord } = await loadRuntimeDiscordOps();
|
||||
return sendTypingDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.typing.pulse(...args);
|
||||
};
|
||||
|
||||
const editMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["editMessage"] =
|
||||
async (...args) => {
|
||||
const { editMessageDiscord } = await loadRuntimeDiscordOps();
|
||||
return editMessageDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.conversationActions.editMessage(...args);
|
||||
};
|
||||
|
||||
const deleteMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["deleteMessage"] =
|
||||
async (...args) => {
|
||||
const { deleteMessageDiscord } = await loadRuntimeDiscordOps();
|
||||
return deleteMessageDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.conversationActions.deleteMessage(...args);
|
||||
};
|
||||
|
||||
const pinMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["pinMessage"] =
|
||||
async (...args) => {
|
||||
const { pinMessageDiscord } = await loadRuntimeDiscordOps();
|
||||
return pinMessageDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.conversationActions.pinMessage(...args);
|
||||
};
|
||||
|
||||
const unpinMessageDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["unpinMessage"] =
|
||||
async (...args) => {
|
||||
const { unpinMessageDiscord } = await loadRuntimeDiscordOps();
|
||||
return unpinMessageDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.conversationActions.unpinMessage(...args);
|
||||
};
|
||||
|
||||
const createThreadDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["createThread"] =
|
||||
async (...args) => {
|
||||
const { createThreadDiscord } = await loadRuntimeDiscordOps();
|
||||
return createThreadDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.conversationActions.createThread(...args);
|
||||
};
|
||||
|
||||
const editChannelDiscordLazy: PluginRuntimeChannel["discord"]["conversationActions"]["editChannel"] =
|
||||
async (...args) => {
|
||||
const { editChannelDiscord } = await loadRuntimeDiscordOps();
|
||||
return editChannelDiscord(...args);
|
||||
const runtimeDiscordOps = await loadRuntimeDiscordOps();
|
||||
return runtimeDiscordOps.conversationActions.editChannel(...args);
|
||||
};
|
||||
|
||||
export function createRuntimeDiscord(): PluginRuntimeChannel["discord"] {
|
||||
|
||||
@@ -8,63 +8,27 @@ import { resolveSlackChannelAllowlist as resolveSlackChannelAllowlistImpl } from
|
||||
import { resolveSlackUserAllowlist as resolveSlackUserAllowlistImpl } from "../../../extensions/slack/src/resolve-users.js";
|
||||
import { sendMessageSlack as sendMessageSlackImpl } from "../../../extensions/slack/src/send.js";
|
||||
import { handleSlackAction as handleSlackActionImpl } from "../../agents/tools/slack-actions.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
type ListSlackDirectoryGroupsLive =
|
||||
typeof import("../../../extensions/slack/src/directory-live.js").listSlackDirectoryGroupsLive;
|
||||
type ListSlackDirectoryPeersLive =
|
||||
typeof import("../../../extensions/slack/src/directory-live.js").listSlackDirectoryPeersLive;
|
||||
type MonitorSlackProvider =
|
||||
typeof import("../../../extensions/slack/src/index.js").monitorSlackProvider;
|
||||
type ProbeSlack = typeof import("../../../extensions/slack/src/probe.js").probeSlack;
|
||||
type ResolveSlackChannelAllowlist =
|
||||
typeof import("../../../extensions/slack/src/resolve-channels.js").resolveSlackChannelAllowlist;
|
||||
type ResolveSlackUserAllowlist =
|
||||
typeof import("../../../extensions/slack/src/resolve-users.js").resolveSlackUserAllowlist;
|
||||
type SendMessageSlack = typeof import("../../../extensions/slack/src/send.js").sendMessageSlack;
|
||||
type HandleSlackAction = typeof import("../../agents/tools/slack-actions.js").handleSlackAction;
|
||||
type RuntimeSlackOps = Pick<
|
||||
PluginRuntimeChannel["slack"],
|
||||
| "listDirectoryGroupsLive"
|
||||
| "listDirectoryPeersLive"
|
||||
| "probeSlack"
|
||||
| "resolveChannelAllowlist"
|
||||
| "resolveUserAllowlist"
|
||||
| "sendMessageSlack"
|
||||
| "monitorSlackProvider"
|
||||
| "handleSlackAction"
|
||||
>;
|
||||
|
||||
export function listSlackDirectoryGroupsLive(
|
||||
...args: Parameters<ListSlackDirectoryGroupsLive>
|
||||
): ReturnType<ListSlackDirectoryGroupsLive> {
|
||||
return listSlackDirectoryGroupsLiveImpl(...args);
|
||||
}
|
||||
|
||||
export function listSlackDirectoryPeersLive(
|
||||
...args: Parameters<ListSlackDirectoryPeersLive>
|
||||
): ReturnType<ListSlackDirectoryPeersLive> {
|
||||
return listSlackDirectoryPeersLiveImpl(...args);
|
||||
}
|
||||
|
||||
export function monitorSlackProvider(
|
||||
...args: Parameters<MonitorSlackProvider>
|
||||
): ReturnType<MonitorSlackProvider> {
|
||||
return monitorSlackProviderImpl(...args);
|
||||
}
|
||||
|
||||
export function probeSlack(...args: Parameters<ProbeSlack>): ReturnType<ProbeSlack> {
|
||||
return probeSlackImpl(...args);
|
||||
}
|
||||
|
||||
export function resolveSlackChannelAllowlist(
|
||||
...args: Parameters<ResolveSlackChannelAllowlist>
|
||||
): ReturnType<ResolveSlackChannelAllowlist> {
|
||||
return resolveSlackChannelAllowlistImpl(...args);
|
||||
}
|
||||
|
||||
export function resolveSlackUserAllowlist(
|
||||
...args: Parameters<ResolveSlackUserAllowlist>
|
||||
): ReturnType<ResolveSlackUserAllowlist> {
|
||||
return resolveSlackUserAllowlistImpl(...args);
|
||||
}
|
||||
|
||||
export function sendMessageSlack(
|
||||
...args: Parameters<SendMessageSlack>
|
||||
): ReturnType<SendMessageSlack> {
|
||||
return sendMessageSlackImpl(...args);
|
||||
}
|
||||
|
||||
export function handleSlackAction(
|
||||
...args: Parameters<HandleSlackAction>
|
||||
): ReturnType<HandleSlackAction> {
|
||||
return handleSlackActionImpl(...args);
|
||||
}
|
||||
export const runtimeSlackOps = {
|
||||
listDirectoryGroupsLive: listSlackDirectoryGroupsLiveImpl,
|
||||
listDirectoryPeersLive: listSlackDirectoryPeersLiveImpl,
|
||||
probeSlack: probeSlackImpl,
|
||||
resolveChannelAllowlist: resolveSlackChannelAllowlistImpl,
|
||||
resolveUserAllowlist: resolveSlackUserAllowlistImpl,
|
||||
sendMessageSlack: sendMessageSlackImpl,
|
||||
monitorSlackProvider: monitorSlackProviderImpl,
|
||||
handleSlackAction: handleSlackActionImpl,
|
||||
} satisfies RuntimeSlackOps;
|
||||
|
||||
@@ -1,60 +1,64 @@
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
let runtimeSlackOpsPromise: Promise<typeof import("./runtime-slack-ops.runtime.js")> | null = null;
|
||||
type RuntimeSlackOps = typeof import("./runtime-slack-ops.runtime.js").runtimeSlackOps;
|
||||
|
||||
let runtimeSlackOpsPromise: Promise<RuntimeSlackOps> | null = null;
|
||||
|
||||
function loadRuntimeSlackOps() {
|
||||
runtimeSlackOpsPromise ??= import("./runtime-slack-ops.runtime.js");
|
||||
runtimeSlackOpsPromise ??= import("./runtime-slack-ops.runtime.js").then(
|
||||
({ runtimeSlackOps }) => runtimeSlackOps,
|
||||
);
|
||||
return runtimeSlackOpsPromise;
|
||||
}
|
||||
|
||||
const listDirectoryGroupsLiveLazy: PluginRuntimeChannel["slack"]["listDirectoryGroupsLive"] =
|
||||
async (...args) => {
|
||||
const { listSlackDirectoryGroupsLive } = await loadRuntimeSlackOps();
|
||||
return listSlackDirectoryGroupsLive(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.listDirectoryGroupsLive(...args);
|
||||
};
|
||||
|
||||
const listDirectoryPeersLiveLazy: PluginRuntimeChannel["slack"]["listDirectoryPeersLive"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { listSlackDirectoryPeersLive } = await loadRuntimeSlackOps();
|
||||
return listSlackDirectoryPeersLive(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.listDirectoryPeersLive(...args);
|
||||
};
|
||||
|
||||
const probeSlackLazy: PluginRuntimeChannel["slack"]["probeSlack"] = async (...args) => {
|
||||
const { probeSlack } = await loadRuntimeSlackOps();
|
||||
return probeSlack(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.probeSlack(...args);
|
||||
};
|
||||
|
||||
const resolveChannelAllowlistLazy: PluginRuntimeChannel["slack"]["resolveChannelAllowlist"] =
|
||||
async (...args) => {
|
||||
const { resolveSlackChannelAllowlist } = await loadRuntimeSlackOps();
|
||||
return resolveSlackChannelAllowlist(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.resolveChannelAllowlist(...args);
|
||||
};
|
||||
|
||||
const resolveUserAllowlistLazy: PluginRuntimeChannel["slack"]["resolveUserAllowlist"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { resolveSlackUserAllowlist } = await loadRuntimeSlackOps();
|
||||
return resolveSlackUserAllowlist(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.resolveUserAllowlist(...args);
|
||||
};
|
||||
|
||||
const sendMessageSlackLazy: PluginRuntimeChannel["slack"]["sendMessageSlack"] = async (...args) => {
|
||||
const { sendMessageSlack } = await loadRuntimeSlackOps();
|
||||
return sendMessageSlack(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.sendMessageSlack(...args);
|
||||
};
|
||||
|
||||
const monitorSlackProviderLazy: PluginRuntimeChannel["slack"]["monitorSlackProvider"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { monitorSlackProvider } = await loadRuntimeSlackOps();
|
||||
return monitorSlackProvider(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.monitorSlackProvider(...args);
|
||||
};
|
||||
|
||||
const handleSlackActionLazy: PluginRuntimeChannel["slack"]["handleSlackAction"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { handleSlackAction } = await loadRuntimeSlackOps();
|
||||
return handleSlackAction(...args);
|
||||
const runtimeSlackOps = await loadRuntimeSlackOps();
|
||||
return runtimeSlackOps.handleSlackAction(...args);
|
||||
};
|
||||
|
||||
export function createRuntimeSlack(): PluginRuntimeChannel["slack"] {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
auditTelegramGroupMembership as auditTelegramGroupMembershipImpl,
|
||||
collectTelegramUnmentionedGroupIds as collectTelegramUnmentionedGroupIdsImpl,
|
||||
} from "../../../extensions/telegram/src/audit.js";
|
||||
import { auditTelegramGroupMembership as auditTelegramGroupMembershipImpl } from "../../../extensions/telegram/src/audit.js";
|
||||
import { monitorTelegramProvider as monitorTelegramProviderImpl } from "../../../extensions/telegram/src/monitor.js";
|
||||
import { probeTelegram as probeTelegramImpl } from "../../../extensions/telegram/src/probe.js";
|
||||
import {
|
||||
@@ -15,113 +12,43 @@ import {
|
||||
sendTypingTelegram as sendTypingTelegramImpl,
|
||||
unpinMessageTelegram as unpinMessageTelegramImpl,
|
||||
} from "../../../extensions/telegram/src/send.js";
|
||||
import { resolveTelegramToken as resolveTelegramTokenImpl } from "../../../extensions/telegram/src/token.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
type AuditTelegramGroupMembership =
|
||||
typeof import("../../../extensions/telegram/src/audit.js").auditTelegramGroupMembership;
|
||||
type CollectTelegramUnmentionedGroupIds =
|
||||
typeof import("../../../extensions/telegram/src/audit.js").collectTelegramUnmentionedGroupIds;
|
||||
type MonitorTelegramProvider =
|
||||
typeof import("../../../extensions/telegram/src/monitor.js").monitorTelegramProvider;
|
||||
type ProbeTelegram = typeof import("../../../extensions/telegram/src/probe.js").probeTelegram;
|
||||
type DeleteMessageTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").deleteMessageTelegram;
|
||||
type EditMessageReplyMarkupTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").editMessageReplyMarkupTelegram;
|
||||
type EditMessageTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").editMessageTelegram;
|
||||
type PinMessageTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").pinMessageTelegram;
|
||||
type RenameForumTopicTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").renameForumTopicTelegram;
|
||||
type SendMessageTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").sendMessageTelegram;
|
||||
type SendPollTelegram = typeof import("../../../extensions/telegram/src/send.js").sendPollTelegram;
|
||||
type SendTypingTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").sendTypingTelegram;
|
||||
type UnpinMessageTelegram =
|
||||
typeof import("../../../extensions/telegram/src/send.js").unpinMessageTelegram;
|
||||
type ResolveTelegramToken =
|
||||
typeof import("../../../extensions/telegram/src/token.js").resolveTelegramToken;
|
||||
type RuntimeTelegramOps = Pick<
|
||||
PluginRuntimeChannel["telegram"],
|
||||
| "auditGroupMembership"
|
||||
| "probeTelegram"
|
||||
| "sendMessageTelegram"
|
||||
| "sendPollTelegram"
|
||||
| "monitorTelegramProvider"
|
||||
> & {
|
||||
typing: Pick<PluginRuntimeChannel["telegram"]["typing"], "pulse">;
|
||||
conversationActions: Pick<
|
||||
PluginRuntimeChannel["telegram"]["conversationActions"],
|
||||
| "editMessage"
|
||||
| "editReplyMarkup"
|
||||
| "deleteMessage"
|
||||
| "renameTopic"
|
||||
| "pinMessage"
|
||||
| "unpinMessage"
|
||||
>;
|
||||
};
|
||||
|
||||
export function auditTelegramGroupMembership(
|
||||
...args: Parameters<AuditTelegramGroupMembership>
|
||||
): ReturnType<AuditTelegramGroupMembership> {
|
||||
return auditTelegramGroupMembershipImpl(...args);
|
||||
}
|
||||
|
||||
export function collectTelegramUnmentionedGroupIds(
|
||||
...args: Parameters<CollectTelegramUnmentionedGroupIds>
|
||||
): ReturnType<CollectTelegramUnmentionedGroupIds> {
|
||||
return collectTelegramUnmentionedGroupIdsImpl(...args);
|
||||
}
|
||||
|
||||
export function monitorTelegramProvider(
|
||||
...args: Parameters<MonitorTelegramProvider>
|
||||
): ReturnType<MonitorTelegramProvider> {
|
||||
return monitorTelegramProviderImpl(...args);
|
||||
}
|
||||
|
||||
export function probeTelegram(...args: Parameters<ProbeTelegram>): ReturnType<ProbeTelegram> {
|
||||
return probeTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function deleteMessageTelegram(
|
||||
...args: Parameters<DeleteMessageTelegram>
|
||||
): ReturnType<DeleteMessageTelegram> {
|
||||
return deleteMessageTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function editMessageReplyMarkupTelegram(
|
||||
...args: Parameters<EditMessageReplyMarkupTelegram>
|
||||
): ReturnType<EditMessageReplyMarkupTelegram> {
|
||||
return editMessageReplyMarkupTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function editMessageTelegram(
|
||||
...args: Parameters<EditMessageTelegram>
|
||||
): ReturnType<EditMessageTelegram> {
|
||||
return editMessageTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function pinMessageTelegram(
|
||||
...args: Parameters<PinMessageTelegram>
|
||||
): ReturnType<PinMessageTelegram> {
|
||||
return pinMessageTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function renameForumTopicTelegram(
|
||||
...args: Parameters<RenameForumTopicTelegram>
|
||||
): ReturnType<RenameForumTopicTelegram> {
|
||||
return renameForumTopicTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function sendMessageTelegram(
|
||||
...args: Parameters<SendMessageTelegram>
|
||||
): ReturnType<SendMessageTelegram> {
|
||||
return sendMessageTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function sendPollTelegram(
|
||||
...args: Parameters<SendPollTelegram>
|
||||
): ReturnType<SendPollTelegram> {
|
||||
return sendPollTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function sendTypingTelegram(
|
||||
...args: Parameters<SendTypingTelegram>
|
||||
): ReturnType<SendTypingTelegram> {
|
||||
return sendTypingTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function unpinMessageTelegram(
|
||||
...args: Parameters<UnpinMessageTelegram>
|
||||
): ReturnType<UnpinMessageTelegram> {
|
||||
return unpinMessageTelegramImpl(...args);
|
||||
}
|
||||
|
||||
export function resolveTelegramToken(
|
||||
...args: Parameters<ResolveTelegramToken>
|
||||
): ReturnType<ResolveTelegramToken> {
|
||||
return resolveTelegramTokenImpl(...args);
|
||||
}
|
||||
export const runtimeTelegramOps = {
|
||||
auditGroupMembership: auditTelegramGroupMembershipImpl,
|
||||
probeTelegram: probeTelegramImpl,
|
||||
sendMessageTelegram: sendMessageTelegramImpl,
|
||||
sendPollTelegram: sendPollTelegramImpl,
|
||||
monitorTelegramProvider: monitorTelegramProviderImpl,
|
||||
typing: {
|
||||
pulse: sendTypingTelegramImpl,
|
||||
},
|
||||
conversationActions: {
|
||||
editMessage: editMessageTelegramImpl,
|
||||
editReplyMarkup: editMessageReplyMarkupTelegramImpl,
|
||||
deleteMessage: deleteMessageTelegramImpl,
|
||||
renameTopic: renameForumTopicTelegramImpl,
|
||||
pinMessage: pinMessageTelegramImpl,
|
||||
unpinMessage: unpinMessageTelegramImpl,
|
||||
},
|
||||
} satisfies RuntimeTelegramOps;
|
||||
|
||||
@@ -8,87 +8,90 @@ import { resolveTelegramToken } from "../../../extensions/telegram/src/token.js"
|
||||
import { createTelegramTypingLease } from "./runtime-telegram-typing.js";
|
||||
import type { PluginRuntimeChannel } from "./types-channel.js";
|
||||
|
||||
let runtimeTelegramOpsPromise: Promise<typeof import("./runtime-telegram-ops.runtime.js")> | null =
|
||||
null;
|
||||
type RuntimeTelegramOps = typeof import("./runtime-telegram-ops.runtime.js").runtimeTelegramOps;
|
||||
|
||||
let runtimeTelegramOpsPromise: Promise<RuntimeTelegramOps> | null = null;
|
||||
|
||||
function loadRuntimeTelegramOps() {
|
||||
runtimeTelegramOpsPromise ??= import("./runtime-telegram-ops.runtime.js");
|
||||
runtimeTelegramOpsPromise ??= import("./runtime-telegram-ops.runtime.js").then(
|
||||
({ runtimeTelegramOps }) => runtimeTelegramOps,
|
||||
);
|
||||
return runtimeTelegramOpsPromise;
|
||||
}
|
||||
|
||||
const auditGroupMembershipLazy: PluginRuntimeChannel["telegram"]["auditGroupMembership"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { auditTelegramGroupMembership } = await loadRuntimeTelegramOps();
|
||||
return auditTelegramGroupMembership(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.auditGroupMembership(...args);
|
||||
};
|
||||
|
||||
const probeTelegramLazy: PluginRuntimeChannel["telegram"]["probeTelegram"] = async (...args) => {
|
||||
const { probeTelegram } = await loadRuntimeTelegramOps();
|
||||
return probeTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.probeTelegram(...args);
|
||||
};
|
||||
|
||||
const sendMessageTelegramLazy: PluginRuntimeChannel["telegram"]["sendMessageTelegram"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendMessageTelegram } = await loadRuntimeTelegramOps();
|
||||
return sendMessageTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.sendMessageTelegram(...args);
|
||||
};
|
||||
|
||||
const sendPollTelegramLazy: PluginRuntimeChannel["telegram"]["sendPollTelegram"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendPollTelegram } = await loadRuntimeTelegramOps();
|
||||
return sendPollTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.sendPollTelegram(...args);
|
||||
};
|
||||
|
||||
const monitorTelegramProviderLazy: PluginRuntimeChannel["telegram"]["monitorTelegramProvider"] =
|
||||
async (...args) => {
|
||||
const { monitorTelegramProvider } = await loadRuntimeTelegramOps();
|
||||
return monitorTelegramProvider(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.monitorTelegramProvider(...args);
|
||||
};
|
||||
|
||||
const sendTypingTelegramLazy: PluginRuntimeChannel["telegram"]["typing"]["pulse"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendTypingTelegram } = await loadRuntimeTelegramOps();
|
||||
return sendTypingTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.typing.pulse(...args);
|
||||
};
|
||||
|
||||
const editMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["editMessage"] =
|
||||
async (...args) => {
|
||||
const { editMessageTelegram } = await loadRuntimeTelegramOps();
|
||||
return editMessageTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.conversationActions.editMessage(...args);
|
||||
};
|
||||
|
||||
const editMessageReplyMarkupTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["editReplyMarkup"] =
|
||||
async (...args) => {
|
||||
const { editMessageReplyMarkupTelegram } = await loadRuntimeTelegramOps();
|
||||
return editMessageReplyMarkupTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.conversationActions.editReplyMarkup(...args);
|
||||
};
|
||||
|
||||
const deleteMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["deleteMessage"] =
|
||||
async (...args) => {
|
||||
const { deleteMessageTelegram } = await loadRuntimeTelegramOps();
|
||||
return deleteMessageTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.conversationActions.deleteMessage(...args);
|
||||
};
|
||||
|
||||
const renameForumTopicTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["renameTopic"] =
|
||||
async (...args) => {
|
||||
const { renameForumTopicTelegram } = await loadRuntimeTelegramOps();
|
||||
return renameForumTopicTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.conversationActions.renameTopic(...args);
|
||||
};
|
||||
|
||||
const pinMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["pinMessage"] =
|
||||
async (...args) => {
|
||||
const { pinMessageTelegram } = await loadRuntimeTelegramOps();
|
||||
return pinMessageTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.conversationActions.pinMessage(...args);
|
||||
};
|
||||
|
||||
const unpinMessageTelegramLazy: PluginRuntimeChannel["telegram"]["conversationActions"]["unpinMessage"] =
|
||||
async (...args) => {
|
||||
const { unpinMessageTelegram } = await loadRuntimeTelegramOps();
|
||||
return unpinMessageTelegram(...args);
|
||||
const runtimeTelegramOps = await loadRuntimeTelegramOps();
|
||||
return runtimeTelegramOps.conversationActions.unpinMessage(...args);
|
||||
};
|
||||
|
||||
export function createRuntimeTelegram(): PluginRuntimeChannel["telegram"] {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { loginWeb as loginWebImpl } from "../../../extensions/whatsapp/src/login.js";
|
||||
import type { PluginRuntime } from "./types.js";
|
||||
|
||||
type LoginWeb = typeof import("../../../extensions/whatsapp/src/login.js").loginWeb;
|
||||
type RuntimeWhatsAppLogin = Pick<PluginRuntime["channel"]["whatsapp"], "loginWeb">;
|
||||
|
||||
export function loginWeb(...args: Parameters<LoginWeb>): ReturnType<LoginWeb> {
|
||||
return loginWebImpl(...args);
|
||||
}
|
||||
export const runtimeWhatsAppLogin = {
|
||||
loginWeb: loginWebImpl,
|
||||
} satisfies RuntimeWhatsAppLogin;
|
||||
|
||||
@@ -2,19 +2,14 @@ import {
|
||||
sendMessageWhatsApp as sendMessageWhatsAppImpl,
|
||||
sendPollWhatsApp as sendPollWhatsAppImpl,
|
||||
} from "../../../extensions/whatsapp/src/send.js";
|
||||
import type { PluginRuntime } from "./types.js";
|
||||
|
||||
type SendMessageWhatsApp =
|
||||
typeof import("../../../extensions/whatsapp/src/send.js").sendMessageWhatsApp;
|
||||
type SendPollWhatsApp = typeof import("../../../extensions/whatsapp/src/send.js").sendPollWhatsApp;
|
||||
type RuntimeWhatsAppOutbound = Pick<
|
||||
PluginRuntime["channel"]["whatsapp"],
|
||||
"sendMessageWhatsApp" | "sendPollWhatsApp"
|
||||
>;
|
||||
|
||||
export function sendMessageWhatsApp(
|
||||
...args: Parameters<SendMessageWhatsApp>
|
||||
): ReturnType<SendMessageWhatsApp> {
|
||||
return sendMessageWhatsAppImpl(...args);
|
||||
}
|
||||
|
||||
export function sendPollWhatsApp(
|
||||
...args: Parameters<SendPollWhatsApp>
|
||||
): ReturnType<SendPollWhatsApp> {
|
||||
return sendPollWhatsAppImpl(...args);
|
||||
}
|
||||
export const runtimeWhatsAppOutbound = {
|
||||
sendMessageWhatsApp: sendMessageWhatsAppImpl,
|
||||
sendPollWhatsApp: sendPollWhatsAppImpl,
|
||||
} satisfies RuntimeWhatsAppOutbound;
|
||||
|
||||
@@ -9,23 +9,28 @@ import {
|
||||
import { createRuntimeWhatsAppLoginTool } from "./runtime-whatsapp-login-tool.js";
|
||||
import type { PluginRuntime } from "./types.js";
|
||||
|
||||
type RuntimeWhatsAppOutbound =
|
||||
typeof import("./runtime-whatsapp-outbound.runtime.js").runtimeWhatsAppOutbound;
|
||||
type RuntimeWhatsAppLogin =
|
||||
typeof import("./runtime-whatsapp-login.runtime.js").runtimeWhatsAppLogin;
|
||||
|
||||
const sendMessageWhatsAppLazy: PluginRuntime["channel"]["whatsapp"]["sendMessageWhatsApp"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendMessageWhatsApp } = await loadWebOutbound();
|
||||
return sendMessageWhatsApp(...args);
|
||||
const runtimeWhatsAppOutbound = await loadWebOutbound();
|
||||
return runtimeWhatsAppOutbound.sendMessageWhatsApp(...args);
|
||||
};
|
||||
|
||||
const sendPollWhatsAppLazy: PluginRuntime["channel"]["whatsapp"]["sendPollWhatsApp"] = async (
|
||||
...args
|
||||
) => {
|
||||
const { sendPollWhatsApp } = await loadWebOutbound();
|
||||
return sendPollWhatsApp(...args);
|
||||
const runtimeWhatsAppOutbound = await loadWebOutbound();
|
||||
return runtimeWhatsAppOutbound.sendPollWhatsApp(...args);
|
||||
};
|
||||
|
||||
const loginWebLazy: PluginRuntime["channel"]["whatsapp"]["loginWeb"] = async (...args) => {
|
||||
const { loginWeb } = await loadWebLogin();
|
||||
return loginWeb(...args);
|
||||
const runtimeWhatsAppLogin = await loadWebLogin();
|
||||
return runtimeWhatsAppLogin.loginWeb(...args);
|
||||
};
|
||||
|
||||
const startWebLoginWithQrLazy: PluginRuntime["channel"]["whatsapp"]["startWebLoginWithQr"] = async (
|
||||
@@ -59,20 +64,23 @@ let webLoginQrPromise: Promise<
|
||||
typeof import("../../../extensions/whatsapp/src/login-qr.js")
|
||||
> | null = null;
|
||||
let webChannelPromise: Promise<typeof import("../../channels/web/index.js")> | null = null;
|
||||
let webOutboundPromise: Promise<typeof import("./runtime-whatsapp-outbound.runtime.js")> | null =
|
||||
null;
|
||||
let webLoginPromise: Promise<typeof import("./runtime-whatsapp-login.runtime.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");
|
||||
webOutboundPromise ??= import("./runtime-whatsapp-outbound.runtime.js").then(
|
||||
({ runtimeWhatsAppOutbound }) => runtimeWhatsAppOutbound,
|
||||
);
|
||||
return webOutboundPromise;
|
||||
}
|
||||
|
||||
function loadWebLogin() {
|
||||
webLoginPromise ??= import("./runtime-whatsapp-login.runtime.js");
|
||||
webLoginPromise ??= import("./runtime-whatsapp-login.runtime.js").then(
|
||||
({ runtimeWhatsAppLogin }) => runtimeWhatsAppLogin,
|
||||
);
|
||||
return webLoginPromise;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user