@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
22import { afterEach , test , vi } from 'vitest' ;
33import type { AgentDeviceClientConfig } from '@agent-device/contracts/client' ;
44import type { AgentDeviceClient } from '@agent-device/command-surface' ;
5+ import { listMcpExposedCommandNames } from '@agent-device/command-registry/registry' ;
56import { createCommandToolExecutor } from '../command-tools.ts' ;
67
78afterEach ( ( ) => {
@@ -28,10 +29,24 @@ async function clientConfigFor(input: Record<string, unknown>): Promise<AgentDev
2829test ( 'AGENT_DEVICE_SESSION_LOCK sets the lock policy of every tool call' , async ( ) => {
2930 vi . stubEnv ( 'AGENT_DEVICE_SESSION' , 'qa' ) ;
3031 vi . stubEnv ( 'AGENT_DEVICE_SESSION_LOCK' , 'strip' ) ;
32+ const policies = new Map < string , unknown > ( ) ;
33+ let current = '' ;
34+ const executor = createCommandToolExecutor ( {
35+ createClient : ( config ) => {
36+ policies . set ( current , config . lockPolicy ) ;
37+ return { } as AgentDeviceClient ;
38+ } ,
39+ runCommand : async ( ) => ( { ok : true } ) ,
40+ } ) ;
3141
32- const config = await clientConfigFor ( { } ) ;
42+ // Every tool, including ones such as `test` and `devices` that declare few flags of their own.
43+ for ( const name of listMcpExposedCommandNames ( ) ) {
44+ current = name ;
45+ await executor . execute ( name , { } ) ;
46+ }
3347
34- assert . equal ( config . lockPolicy , 'strip' ) ;
48+ assert . equal ( policies . size , listMcpExposedCommandNames ( ) . length ) ;
49+ for ( const [ name , policy ] of policies ) assert . equal ( policy , 'strip' , name ) ;
3550} ) ;
3651
3752test ( 'AGENT_DEVICE_SESSION turns on the reject lock bound to AGENT_DEVICE_PLATFORM' , async ( ) => {
0 commit comments