























@@ -13,6 +13,7 @@ import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot
1313import { clearSecretsRuntimeSnapshot } from "../secrets/runtime.js";
1414import type { AuthProfileStore } from "./auth-profiles/types.js";
1515import { resolveOptionalMediaToolFactoryPlan } from "./openclaw-tools.media-factory-plan.js";
16+import { DEFAULT_PLUGIN_TOOLS_ALLOWLIST_ENTRY } from "./tool-policy.js";
1617import * as pdfModelConfigModule from "./tools/pdf-tool.model-config.js";
17181819type CreateOpenClawToolsOptions = Parameters<
@@ -229,6 +230,74 @@ describe("optional media tool factory planning", () => {
229230});
230231});
231232233+it("preserves implicit allow-all from alsoAllow-only policies for built-in media factories", async () => {
234+const config: OpenClawConfig = {
235+agents: {
236+defaults: {
237+imageGenerationModel: { primary: "image-owner/model" },
238+videoGenerationModel: { primary: "video-owner/model" },
239+musicGenerationModel: { primary: "music-owner/model" },
240+pdfModel: { primary: "media-owner/model" },
241+},
242+},
243+};
244+const allowlistFromAlsoAllowOnlyPolicy = ["group:memory", DEFAULT_PLUGIN_TOOLS_ALLOWLIST_ENTRY];
245+installSnapshot(config, []);
246+247+expect(
248+resolveOptionalMediaToolFactoryPlan({
249+ config,
250+authStore: createAuthStore(),
251+toolAllowlist: allowlistFromAlsoAllowOnlyPolicy,
252+}),
253+).toEqual({
254+imageGenerate: true,
255+videoGenerate: true,
256+musicGenerate: true,
257+pdf: true,
258+});
259+260+const toolNames = (
261+await createOpenClawToolsForTest({
262+ config,
263+agentDir: "/tmp/openclaw-agent-main",
264+authProfileStore: createAuthStore(),
265+pluginToolAllowlist: allowlistFromAlsoAllowOnlyPolicy,
266+})
267+).map((tool) => tool.name);
268+expect(toolNames).toEqual(
269+expect.arrayContaining(["image_generate", "video_generate", "music_generate", "pdf"]),
270+);
271+});
272+273+it("keeps denylists authoritative when alsoAllow-only policies preserve factory construction", () => {
274+const config: OpenClawConfig = {
275+agents: {
276+defaults: {
277+imageGenerationModel: { primary: "image-owner/model" },
278+videoGenerationModel: { primary: "video-owner/model" },
279+musicGenerationModel: { primary: "music-owner/model" },
280+pdfModel: { primary: "media-owner/model" },
281+},
282+},
283+};
284+installSnapshot(config, []);
285+286+expect(
287+resolveOptionalMediaToolFactoryPlan({
288+ config,
289+authStore: createAuthStore(),
290+toolAllowlist: [DEFAULT_PLUGIN_TOOLS_ALLOWLIST_ENTRY],
291+toolDenylist: ["video_generate", "pdf"],
292+}),
293+).toEqual({
294+imageGenerate: true,
295+videoGenerate: false,
296+musicGenerate: true,
297+pdf: false,
298+});
299+});
300+232301it("skips tools that the resolved allowlist cannot expose", () => {
233302const config: OpenClawConfig = {};
234303installSnapshot(config, [
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。