@@ -4,66 +4,10 @@ import { expectDefined } from "@openclaw/normalization-core";
44import { beforeEach , describe , expect , it , vi } from "vitest" ;
55import { installGatewayTestHooks , testState , writeSessionStore } from "../test-helpers.js" ;
66import { getGatewayConfigModule , sessionStoreEntry } from "../test/server-sessions.test-helpers.js" ;
7+ import { toolsEffectiveGlobalAgentRuntimeMocks as inventoryMocks } from "./__mocks__/tools-effective.runtime.js" ;
78import { testing , toolsEffectiveHandlers } from "./tools-effective.js" ;
89
9- const inventoryMocks = vi . hoisted ( ( ) => ( {
10- resolveEffectiveToolInventory : vi . fn (
11- ( params : { agentId : string ; modelProvider ?: string ; modelId ?: string } ) => ( {
12- agentId : params . agentId ,
13- profile : "coding" ,
14- groups : [
15- {
16- id : "core" ,
17- label : "Built-in tools" ,
18- source : "core" ,
19- tools : [
20- {
21- id : "exec" ,
22- label : "Exec" ,
23- description : "Run shell commands" ,
24- source : "core" ,
25- } ,
26- ] ,
27- } ,
28- ] ,
29- modelProvider : params . modelProvider ,
30- modelId : params . modelId ,
31- } ) ,
32- ) ,
33- resolveEffectiveToolInventoryRuntimeModelContext : vi . fn ( ( _params ?: unknown ) => ( {
34- modelApi : "openai-responses" ,
35- runtimeModel : {
36- id : "work-model" ,
37- name : "Work model" ,
38- provider : "openai" ,
39- api : "openai-responses" ,
40- baseUrl : "https://api.openai.com/v1" ,
41- } ,
42- } ) ) ,
43- resolveEffectiveToolInventoryRuntimeModelContextAsync : vi . fn ( async ( params : unknown ) =>
44- inventoryMocks . resolveEffectiveToolInventoryRuntimeModelContext ( params ) ,
45- ) ,
46- } ) ) ;
47-
48- vi . mock ( "./tools-effective.runtime.js" , async ( importOriginal ) => {
49- const actual = await importOriginal < typeof import ( "./tools-effective.runtime.js" ) > ( ) ;
50- return {
51- ...actual ,
52- resolveEffectiveToolInventory : inventoryMocks . resolveEffectiveToolInventory ,
53- resolveEffectiveToolInventoryRuntimeModelContext :
54- inventoryMocks . resolveEffectiveToolInventoryRuntimeModelContext ,
55- resolveEffectiveToolInventoryRuntimeModelContextAsync :
56- inventoryMocks . resolveEffectiveToolInventoryRuntimeModelContextAsync ,
57- peekSessionMcpRuntime : vi . fn ( ( ) => undefined ) ,
58- resolveSessionMcpConfigSummary : vi . fn ( ( ) => ( { fingerprint : "mcp:0" , serverNames : [ ] } ) ) ,
59- buildBundleMcpToolsFromCatalog : vi . fn ( ( ) => [ ] ) ,
60- applyFinalEffectiveToolPolicy : vi . fn (
61- ( params : { bundledTools : unknown [ ] } ) => params . bundledTools ,
62- ) ,
63- getActivePluginRegistryVersion : vi . fn ( ( ) => 1 ) ,
64- getActivePluginChannelRegistryVersion : vi . fn ( ( ) => 1 ) ,
65- } ;
66- } ) ;
10+ vi . mock ( "./tools-effective.runtime.js" ) ;
6711
6812installGatewayTestHooks ( ) ;
6913
0 commit comments