Implements a Zellij-based multiplexer adapter that creates and manages terminal panes for sub-agent sessions within Zellij workspaces. Provides pane lifecycle management, session isolation, and graceful shutdown for OpenCode's multiplexer interface.
Multiplexer interface with type = 'zellij'paneMode:
'agent-tab' (default): Creates dedicated "opencode-agents" tab'current-tab': Creates panes in user's current tabspawnPane() to create new panes with OpenCode attach commandsclosePane() with graceful Ctrl+C shutdown before pane terminationMultiplexerLayout to Zellij pane directions:
'main-vertical' → 'right' (vertical split)'main-horizontal' → 'down' (horizontal split)'even-horizontal', 'even-vertical', 'tiled' → null (no direction, Zellij handles tiling)opencode attach commands with session, server URL, and directoryquoteShellArg() to properly escape shell arguments1. Plugin loads → ZellijMultiplexer instantiated with layout='main-vertical'
2. First sub-agent session:
- ensureAgentTab() creates "opencode-agents" tab if not exists
- runInPane() focuses default pane and writes OpenCode attach command
- firstPaneUsed flag set to true
3. Subsequent sub-agent sessions:
- createPaneInAgentTab() creates new pane in agent tab
- Switches to agent tab, creates pane, switches back to original tab
4. Session completion:
- closePane() sends Ctrl+C → delay → kill-pane
- Pane removed from Zellij workspace
1. Plugin loads → ZellijMultiplexer instantiated with paneMode='current-tab'
2. spawnPane() calls createPaneInCurrentTab()
3. Creates pane directly in user's current tab using parentTabId
4. No tab switching overhead; user remains in their original tab
1. findTabByName() uses Zellij's list-tabs action
- Tries JSON output first (--json flag)
- Falls back to text parsing if JSON unavailable
2. getCurrentTabId() queries current-tab-info --json
3. getFirstPaneInTab() / findTabIdForPane() use listPanesJson() (list-panes --json --tab --all) filtered by tab_id
4. findTabIdForPane() correlates pane IDs with tab IDs for parent tab tracking
src/multiplexer/types.ts::Multiplexersrc/config/schema.ts::MultiplexerLayout and ZellijPaneModesrc/utils/compat.ts::crossSpawn for cross-platform process spawningsrc/index.ts instantiates ZellijMultiplexer via multiplexer factorysrc/agents/council.ts and src/agents/council-agents.ts use multiplexer for session pane management{ success: false } on failuresnormalizePaneId() strips "terminal_" prefix for numeric comparisonsbuildOpencodeAttachCommand() constructs safe shell commands with quoted argumentsbuildShellLaunchCommand() wraps commands in sh -lc for proper executionquoteShellArg() with proper escapingagentTabId: Caches the "opencode-agents" tab ID after creationfirstPaneId: Stores the initial pane ID for first sub-agent reusefirstPaneUsed: Boolean flag prevents duplicate first pane usageparentTabId: Caches parent tab ID for current-tab mode optimization1. send-keys C-c to pane (graceful interrupt)
2. 250ms delay for process cleanup
3. kill-pane with pane ID
src/multiplexer/zellij/index.test.tshasChecked flag)