@@ -85,26 +85,53 @@ def handle_command_result(event_data):
8585 future .set_result (event_data )
8686
8787
88- async def list_all_commands () -> dict :
88+ async def list_all_commands (query : Optional [ str ] = None ) -> dict :
8989 """
9090 Retrieve a list of all available JupyterLab commands.
9191
9292 This function emits a request to the JupyterLab frontend to retrieve all
9393 registered commands in the application. It waits for the response and
9494 returns the complete list of available commands with their metadata.
9595
96+ Args:
97+ query (Optional[str], optional): An optional search query to filter commands.
98+ When provided, only commands whose ID, label,
99+ caption, or description contain the query string
100+ (case-insensitive) will be returned. If None or
101+ omitted, all commands will be returned.
102+ Defaults to None.
103+
96104 Returns:
97105 dict: A dictionary containing the command list response from JupyterLab.
98106 The structure typically includes:
99107 - success (bool): Whether the operation succeeded
100- - commands (list): List of available command objects, with arguments and types
108+ - commandCount (int): Number of commands returned
109+ - commands (list): List of available command objects, each with:
110+ - id (str): The command identifier
111+ - label (str, optional): Human-readable command label
112+ - caption (str, optional): Short description
113+ - description (str, optional): Detailed usage information
114+ - args (dict, optional): Command argument schema
101115 - error (str, optional): Error message if the operation failed
102116
103117 Raises:
104118 asyncio.TimeoutError: If the frontend doesn't respond within the timeout period
119+
120+ Examples:
121+ >>> # Get all commands
122+ >>> await list_all_commands()
123+ {'success': True, 'commandCount': 150, 'commands': [...]}
124+
125+ >>> # Filter commands by query
126+ >>> await list_all_commands(query="notebook")
127+ {'success': True, 'commandCount': 25, 'commands': [...]}
105128 """
129+ args = {}
130+ if query is not None :
131+ args ["query" ] = query
132+
106133 return await emit_and_wait_for_result (
107- {"name" : "jupyterlab-commands-toolkit:list-all-commands" , "args" : {} }
134+ {"name" : "jupyterlab-commands-toolkit:list-all-commands" , "args" : args }
108135 )
109136
110137
0 commit comments