






















@@ -98,6 +98,66 @@ describe("external channel secret contract api", () => {
9898expect(api?.collectRuntimeConfigAssignments).toBeTypeOf("function");
9999});
100100101+it("loads dist/ secret-contract-api sidecars for compiled npm-published external channel plugins", () => {
102+const rootDir = makeTrackedTempDir("openclaw-channel-secret-contract-dist", tempDirs);
103+fs.mkdirSync(path.join(rootDir, "dist"), { recursive: true });
104+fs.writeFileSync(
105+path.join(rootDir, "dist", "secret-contract-api.cjs"),
106+`
107+module.exports = {
108+ secretTargetRegistryEntries: [
109+ {
110+ id: "channels.discord.token",
111+ targetType: "channels.discord.token",
112+ configFile: "openclaw.json",
113+ pathPattern: "channels.discord.token",
114+ secretShape: "secret_input",
115+ expectedResolvedValue: "string",
116+ includeInPlan: true,
117+ includeInConfigure: true,
118+ includeInAudit: true
119+ }
120+ ],
121+ collectRuntimeConfigAssignments(params) {
122+ params.context.assignments.push({
123+ path: "channels.discord.token",
124+ ref: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
125+ expected: "string",
126+ apply() {}
127+ });
128+ }
129+};
130+`,
131+"utf8",
132+);
133+const record = {
134+id: "discord",
135+origin: "global",
136+channels: ["discord"],
137+channelConfigs: {},
138+ rootDir,
139+};
140+loadPluginMetadataSnapshotMock.mockReturnValue({
141+plugins: [record],
142+});
143+144+const api = loadChannelSecretContractApi({
145+channelId: "discord",
146+config: { channels: { discord: {} } },
147+env: {},
148+loadablePluginOrigins: new Map([["discord", "global"]]),
149+});
150+151+expect(api?.secretTargetRegistryEntries).toEqual(
152+expect.arrayContaining([
153+expect.objectContaining({
154+id: "channels.discord.token",
155+}),
156+]),
157+);
158+expect(api?.collectRuntimeConfigAssignments).toBeTypeOf("function");
159+});
160+101161it("skips external channel records outside the loadable plugin origin set", () => {
102162const record = writeExternalChannelPlugin({ pluginId: "discord", channelId: "discord" });
103163loadPluginMetadataSnapshotMock.mockReturnValue({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。