Builder protocol - tmuxp.workspace.builder.protocol¶
Public contract for tmuxp workspace builders.
A workspace builder turns an expanded workspace dict into a live tmux
session. tmuxp.workspace.builder.classic.ClassicWorkspaceBuilder is the
default implementation; third parties may ship their own and select them with
the workspace_builder config key (see
tmuxp.workspace.builder.registry).
This module is intentionally dependency-light (typing only) so builder authors can import the contract without pulling in tmuxp’s resolution machinery.
The contract is synchronous today. Async builders are an additive future
extension: a subclass protocol can declare an async build entry point and a
capability flag, discovered through the same entry-point group, without
changing this sync surface.
-
class tmuxp.workspace.builder.protocol.WorkspaceBuilderProtocol¶class tmuxp.workspace.builder.protocol.WorkspaceBuilderProtocol¶
Bases:
ProtocolContract a builder must satisfy to be driven by
tmuxp load.A conforming builder is constructed with at least
session_configandserver(plus the optionalpluginsandon_*callbacks the classic builder accepts). It exposesbuild(), surfaces the populated tmux session viasession, and honors the plugin/progress integration points the CLI drives.Because the protocol carries data members (
session,plugins, theon_*callbacks), validate instances withisinstance(); class-levelissubclasschecks are not supported for runtime-checkable protocols with non-method members.Examples
A builder implementing the full contract satisfies the protocol:
>>> from tmuxp.workspace.builder.protocol import WorkspaceBuilderProtocol >>> class MiniBuilder: ... plugins: list = [] ... on_progress = None ... on_before_script = None ... on_script_output = None ... on_build_event = None ... def __init__(self, session_config, server, **kwargs): ... self._session_config = session_config ... def build(self, session=None, append=False): ... ... ... def session_exists(self, session_name): ... ... ... def find_current_attached_session(self): ... ... ... @property ... def session(self): ... ... >>> builder = MiniBuilder(session_config={}, server=None) >>> isinstance(builder, WorkspaceBuilderProtocol) True
An object missing the contract does not:
>>> isinstance(object(), WorkspaceBuilderProtocol) False