@@ -25,61 +25,61 @@ function getDefaultUIDistPath(): string {
2525 *
2626 * The registry:
2727 * - Loads default bundled HTML from dist/ui/ at runtime
28- * - Allows overriding UIs via register()
28+ * - Allows adding or replacing UIs via register()
2929 * - Provides get() to retrieve UI HTML for a tool
3030 */
3131export class UIRegistry {
32- private overrides : Map < string , string > = new Map ( ) ;
32+ private customUIs : Map < string , string > = new Map ( ) ;
3333 private cache : Map < string , string > = new Map ( ) ;
3434 private uiDistPath : string ;
3535
36- constructor ( options ?: { uiDistPath ?: string ; overrides ?: Record < string , string > } ) {
36+ constructor ( options ?: { uiDistPath ?: string ; customUIs ?: Record < string , string > } ) {
3737 // Use provided path or auto-detect the dist/ui location
3838 this . uiDistPath = options ?. uiDistPath ?? getDefaultUIDistPath ( ) ;
3939
40- // Apply initial overrides if provided
41- if ( options ?. overrides ) {
42- for ( const [ toolName , html ] of Object . entries ( options . overrides ) ) {
40+ // Apply initial custom UIs if provided
41+ if ( options ?. customUIs ) {
42+ for ( const [ toolName , html ] of Object . entries ( options . customUIs ) ) {
4343 this . register ( toolName , html ) ;
4444 }
4545 }
4646 }
4747
4848 /**
49- * Register a custom UI HTML string for a tool, overriding the default
49+ * Register a custom UI HTML string for a tool
5050 * @param toolName The name of the tool (e.g., 'list-databases')
5151 * @param html The HTML string to use for this tool's UI
5252 */
5353 register ( toolName : string , html : string ) : void {
54- this . overrides . set ( toolName , html ) ;
54+ this . customUIs . set ( toolName , html ) ;
5555 }
5656
5757 /**
58- * Unregister a custom UI for a tool, reverting to the default
58+ * Unregister a custom UI for a tool, reverting to the default (if one exists)
5959 * @param toolName The name of the tool
6060 */
6161 unregister ( toolName : string ) : void {
62- this . overrides . delete ( toolName ) ;
62+ this . customUIs . delete ( toolName ) ;
6363 }
6464
6565 /**
66- * Check if a tool has a UI registered (either override or default)
66+ * Check if a tool has a UI registered (either custom or default)
6767 * @param toolName The name of the tool
6868 */
6969 has ( toolName : string ) : boolean {
70- return this . overrides . has ( toolName ) || toolName in uiMap ;
70+ return this . customUIs . has ( toolName ) || toolName in uiMap ;
7171 }
7272
7373 /**
7474 * Get the UI HTML string for a tool
75- * Returns the override if registered, otherwise loads the default from disk
75+ * Returns the custom UI if registered, otherwise loads the default from disk
7676 * @param toolName The name of the tool
7777 * @returns The HTML string, or undefined if no UI exists for this tool
7878 */
7979 get ( toolName : string ) : string | undefined {
80- // Check for override first
81- if ( this . overrides . has ( toolName ) ) {
82- return this . overrides . get ( toolName ) ;
80+ // Check for custom UI first
81+ if ( this . customUIs . has ( toolName ) ) {
82+ return this . customUIs . get ( toolName ) ;
8383 }
8484
8585 // Check if we have a mapping for this tool
@@ -117,10 +117,10 @@ export class UIRegistry {
117117 }
118118
119119 /**
120- * Get all registered tool names (both overrides and defaults )
120+ * Get all registered tool names (both custom and default )
121121 */
122122 getRegisteredTools ( ) : string [ ] {
123- const tools = new Set < string > ( [ ...this . overrides . keys ( ) , ...Object . keys ( uiMap ) ] ) ;
123+ const tools = new Set < string > ( [ ...this . customUIs . keys ( ) , ...Object . keys ( uiMap ) ] ) ;
124124 return Array . from ( tools ) ;
125125 }
126126}
0 commit comments