VSCodeClient¶
The main entry point for connecting to VS Code.
VSCodeClient
¶
Main client for interacting with VS Code via Sockpuppet extension.
Initialize the VS Code client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipe_path
|
Optional[str]
|
Path to the named pipe/socket. If None, checks VSCODE_SOCKPUPPET_PIPE environment variable, then falls back to platform default. |
None
|
Source code in vscode_sockpuppet/client.py
connect
¶
Connect to the VS Code extension via named pipe/socket.
Source code in vscode_sockpuppet/client.py
disconnect
¶
Disconnect from the VS Code extension.
Source code in vscode_sockpuppet/client.py
is_connected
¶
execute_command
¶
Execute a VS Code command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
The command identifier |
required |
*args
|
Arguments to pass to the command |
()
|
Returns:
| Type | Description |
|---|---|
Any
|
The result of the command execution |
Source code in vscode_sockpuppet/client.py
get_commands
¶
Get all available VS Code commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_internal
|
bool
|
Whether to filter internal commands |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of command identifiers |
Source code in vscode_sockpuppet/client.py
add_event_listener
¶
Register a handler for a server-sent event and return an unsubscribe callable.
This replaces the old subscribe() API. The first listener for an event
will trigger a server-side subscription (events.subscribe) and the last
listener removed will trigger events.unsubscribe.
Source code in vscode_sockpuppet/client.py
remove_event_listener
¶
Remove a previously registered event handler or all handlers for an event.
If handler is None, explicitly unsubscribe from the server and remove the emitter.
Source code in vscode_sockpuppet/client.py
get_subscriptions
¶
Get list of currently subscribed events.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of event names |
get_emitter
¶
Return the EventEmitter for a named event, creating it if necessary.
This allows callers to access the per-event emitter when they need to inspect or interact with listeners directly. It preserves the same on_first_add/on_no_listeners hook behavior as before.
Source code in vscode_sockpuppet/client.py
__enter__
¶
__exit__
¶
add_session_listener
¶
Register a listener for session state notifications.
Source code in vscode_sockpuppet/client.py
remove_session_listener
¶
Remove a previously registered session listener.
Source code in vscode_sockpuppet/client.py
session_listener
¶
Context manager to automatically add and remove a session listener.
Source code in vscode_sockpuppet/client.py
subscription
¶
Context manager that registers a subscription and ensures it's removed.
Example:
with client.subscription('webview.onDidReceiveMessage', handler):
# handler will receive events here
...