

























@@ -3,6 +3,10 @@ import { describe, expect, it, vi } from "vitest";
33const mocks = vi.hoisted(() => {
44const runtimeConfig = { channels: { discord: { token: "token" } } };
55const apiModule = {
6+buildDiscordComponentMessage: vi.fn((params: { spec: { text?: string } }) => ({
7+components: [],
8+text: params.spec.text ?? "",
9+})),
610collectDiscordStatusIssues: vi.fn(() => []),
711discordOnboardingAdapter: { kind: "legacy-onboarding" },
812inspectDiscordAccount: vi.fn(() => ({ accountId: "default" })),
@@ -33,7 +37,9 @@ const mocks = vi.hoisted(() => {
3337cfg: params.cfg,
3438})),
3539collectDiscordAuditChannelIds: vi.fn(() => ({ channelIds: [], unresolvedChannels: [] })),
40+editDiscordComponentMessage: vi.fn(async () => ({ id: "message" })),
3641listThreadBindingsBySessionKey: vi.fn(() => []),
42+registerBuiltDiscordComponentMessage: vi.fn(),
3743unbindThreadBindingsBySessionKey: vi.fn(() => []),
3844};
3945@@ -78,6 +84,7 @@ describe("discord plugin-sdk compatibility facade", () => {
7884"PAIRING_APPROVED_MESSAGE",
7985"applyAccountNameToChannelSection",
8086"autoBindSpawnedDiscordSubagent",
87+"buildDiscordComponentMessage",
8188"buildChannelConfigSchema",
8289"buildComputedAccountStatusSnapshot",
8390"buildTokenChannelStatusSummary",
@@ -97,6 +104,8 @@ describe("discord plugin-sdk compatibility facade", () => {
97104"normalizeDiscordMessagingTarget",
98105"normalizeDiscordOutboundTarget",
99106"projectCredentialSnapshotFields",
107+"editDiscordComponentMessage",
108+"registerBuiltDiscordComponentMessage",
100109"resolveConfiguredFromCredentialStatuses",
101110"resolveDefaultDiscordAccountId",
102111"resolveDiscordAccount",
@@ -108,6 +117,40 @@ describe("discord plugin-sdk compatibility facade", () => {
108117}
109118});
110119120+it("forwards Discord component helpers through the compatibility facade", async () => {
121+const {
122+ buildDiscordComponentMessage,
123+ editDiscordComponentMessage,
124+ registerBuiltDiscordComponentMessage,
125+} = await import("./discord.js");
126+127+const built = buildDiscordComponentMessage({ spec: { text: "hello" } });
128+await editDiscordComponentMessage(
129+"channel",
130+"message",
131+{ text: "edited" },
132+{ cfg: mocks.runtimeConfig },
133+);
134+registerBuiltDiscordComponentMessage({
135+buildResult: built,
136+messageId: "message",
137+});
138+139+expect(mocks.apiModule.buildDiscordComponentMessage).toHaveBeenCalledWith({
140+spec: { text: "hello" },
141+});
142+expect(mocks.runtimeModule.editDiscordComponentMessage).toHaveBeenCalledWith(
143+"channel",
144+"message",
145+{ text: "edited" },
146+{ cfg: mocks.runtimeConfig },
147+);
148+expect(mocks.runtimeModule.registerBuiltDiscordComponentMessage).toHaveBeenCalledWith({
149+buildResult: built,
150+messageId: "message",
151+});
152+});
153+111154it("keeps legacy Discord subagent auto-bind calls working without cfg", async () => {
112155const { autoBindSpawnedDiscordSubagent } = await import("./discord.js");
113156此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。