okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0b3299a01
main
1import test from 'node:test' ; 2import assert from 'node:assert/strict' ; 3import { build } from 'esbuild' ; 4const compiled = await build ({ entryPoints :[ 'src/lib/native-settings-response.ts' ], bundle :true , write :false , platform :'node' , format :'esm' }); 5const { nativeSettingsResponse, nativeSettingsValues} = await import ( `data:text/javascript;base64, ${ Buffer . from ( compiled . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 6test ( 'settings distinguish a host error body from a valid configuration' ,() => { 7assert . throws (() => nativeSettingsResponse ({ error :'This model is not installed. Download and prepare it first.' }), / not installed / ); 8for ( const value of [ null ,[],{}, { values :null },{ values :[]},{ values :{}, mcp :[]}]) assert . throws (() => nativeSettingsResponse ( value )); 9assert . deepEqual ( nativeSettingsResponse ({ values :{ sampling :{ temperature :0.7 }}}),{ values :{ sampling :{ temperature :0.7 }}, mcp :{}}); 10assert . deepEqual ( nativeSettingsResponse ({ values :{}, mcp :{ files :{ command :'node' }}}). mcp ,{ files :{ command :'node' }}); 11}); 12test ( 'switching from raw JSON rejects scalar or array configurations before rendering fields' ,() => { 13for ( const value of [ null ,[], true , 5 , 'text' ]) assert . throws (() => nativeSettingsValues ( value )); 14assert . deepEqual ( nativeSettingsValues ({}),{}); 15});