@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
22import os from "node:os" ;
33import path from "node:path" ;
44import type { AnyAgentTool } from "openclaw/plugin-sdk/agent-runtime" ;
5+ import type { PluginTrustedToolPolicyRegistration } from "openclaw/plugin-sdk/core" ;
56import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api" ;
67import { afterEach , describe , expect , it , vi } from "vitest" ;
78import plugin , {
@@ -657,18 +658,30 @@ describe("skill-workshop", () => {
657658 const store = new SkillWorkshopStore ( { stateDir, workspaceDir } ) ;
658659 expect ( await store . list ( "pending" ) ) . toHaveLength ( 1 ) ;
659660 expect ( await store . list ( "applied" ) ) . toHaveLength ( 0 ) ;
661+ } ) ;
660662
661- const applied = await tool ?. execute ?.( "call-2" , {
662- action : "apply" ,
663- id : proposalId ,
663+ it ( "requires operator approval before applying queued proposals in pending mode" , async ( ) => {
664+ let trustedPolicy : PluginTrustedToolPolicyRegistration | undefined ;
665+ const api = createTestPluginApi ( {
666+ pluginConfig : { approvalPolicy : "pending" } ,
667+ registerTrustedToolPolicy ( policy ) {
668+ trustedPolicy = policy ;
669+ } ,
664670 } ) ;
665671
666- expect ( applied ?. details ) . toMatchObject ( { status : "applied" } ) ;
667- await expect (
668- fs . access ( path . join ( workspaceDir , "skills" , "screenshot-asset-workflow" , "SKILL.md" ) ) ,
669- ) . resolves . toBeUndefined ( ) ;
670- expect ( await store . list ( "pending" ) ) . toHaveLength ( 0 ) ;
671- expect ( await store . list ( "applied" ) ) . toHaveLength ( 1 ) ;
672+ plugin . register ( api ) ;
673+
674+ const result = await trustedPolicy ?. evaluate (
675+ { toolName : "skill_workshop" , params : { action : "apply" , id : "proposal-1" } } ,
676+ { toolName : "skill_workshop" } ,
677+ ) ;
678+
679+ expect ( result ) . toMatchObject ( {
680+ requireApproval : {
681+ title : "Apply workspace skill proposal" ,
682+ allowedDecisions : [ "allow-once" , "deny" ] ,
683+ } ,
684+ } ) ;
672685 } ) ;
673686
674687 it ( "uses the reviewer to propose existing skill repairs" , async ( ) => {
0 commit comments