wezterm-agent-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +107 -0
- package/README.md +288 -0
- package/build/platform.d.ts +57 -0
- package/build/platform.js +286 -0
- package/build/platform.js.map +1 -0
- package/build/wez-mcp.d.ts +9 -0
- package/build/wez-mcp.js +2214 -0
- package/build/wez-mcp.js.map +1 -0
- package/package.json +49 -0
- package/wezterm.lua +151 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# PolyForm Strict License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/strict/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose, other than distributing
|
|
17
|
+
the software or making changes or new works based on the
|
|
18
|
+
software.
|
|
19
|
+
|
|
20
|
+
## Patent License
|
|
21
|
+
|
|
22
|
+
The licensor grants you a patent license for the software
|
|
23
|
+
that covers patent claims the licensor can license, or
|
|
24
|
+
becomes able to license, that you would infringe by using
|
|
25
|
+
the software.
|
|
26
|
+
|
|
27
|
+
## Noncommercial Purposes
|
|
28
|
+
|
|
29
|
+
Any noncommercial purpose is a permitted purpose.
|
|
30
|
+
|
|
31
|
+
## Personal Uses
|
|
32
|
+
|
|
33
|
+
Personal use for research, experiment, and testing for
|
|
34
|
+
the benefit of public knowledge, personal study, private
|
|
35
|
+
entertainment, hobby projects, amateur pursuits, or
|
|
36
|
+
religious observance, without any anticipated commercial
|
|
37
|
+
application, is use for a permitted purpose.
|
|
38
|
+
|
|
39
|
+
## Noncommercial Organizations
|
|
40
|
+
|
|
41
|
+
Use by any charitable organization, educational
|
|
42
|
+
institution, public research organization, public safety
|
|
43
|
+
or health organization, environmental protection
|
|
44
|
+
organization, or government institution is use for a
|
|
45
|
+
permitted purpose regardless of the source of funding or
|
|
46
|
+
obligations resulting from the funding.
|
|
47
|
+
|
|
48
|
+
## Fair Use
|
|
49
|
+
|
|
50
|
+
You may have "fair use" rights for the software under
|
|
51
|
+
the law. These terms do not limit them.
|
|
52
|
+
|
|
53
|
+
## No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not allow you to sublicense or transfer
|
|
56
|
+
any of your licenses to anyone else, or prevent the
|
|
57
|
+
licensor from granting licenses to anyone else. These
|
|
58
|
+
terms do not imply any other licenses.
|
|
59
|
+
|
|
60
|
+
## Patent Defense
|
|
61
|
+
|
|
62
|
+
If you make any written claim that the software infringes
|
|
63
|
+
or contributes to infringement of any patent, your patent
|
|
64
|
+
license for the software granted under these terms ends
|
|
65
|
+
immediately. If your company makes such a claim, your
|
|
66
|
+
patent license ends immediately for work on behalf of
|
|
67
|
+
your company.
|
|
68
|
+
|
|
69
|
+
## Violations
|
|
70
|
+
|
|
71
|
+
The first time you are notified in writing that you have
|
|
72
|
+
violated any of these terms, or done anything with the
|
|
73
|
+
software not covered by your licenses, your licenses can
|
|
74
|
+
nonetheless continue if you come into full compliance
|
|
75
|
+
with these terms, and take practical steps to correct past
|
|
76
|
+
violations, within 32 days of receiving notice.
|
|
77
|
+
|
|
78
|
+
## No Liability
|
|
79
|
+
|
|
80
|
+
***As far as the law allows, the software comes as is,
|
|
81
|
+
without any warranty or condition, and the licensor will
|
|
82
|
+
not be liable to anyone for any damages related to this
|
|
83
|
+
software or this license, under any kind of legal claim.***
|
|
84
|
+
|
|
85
|
+
## Definitions
|
|
86
|
+
|
|
87
|
+
The **licensor** is the individual or entity offering
|
|
88
|
+
these terms, and the **software** is the software the
|
|
89
|
+
licensor makes available under these terms.
|
|
90
|
+
|
|
91
|
+
**You** refers to the individual or entity agreeing to
|
|
92
|
+
these terms.
|
|
93
|
+
|
|
94
|
+
**Your company** is any legal entity, sole
|
|
95
|
+
proprietorship, or other kind of organization that you
|
|
96
|
+
work for, plus all organizations that have control over,
|
|
97
|
+
are under the control of, or are under common control
|
|
98
|
+
with that organization. **Control** means ownership of
|
|
99
|
+
substantially all the assets of an entity, or the power
|
|
100
|
+
to direct its management and policies by vote, contract,
|
|
101
|
+
or otherwise. Control can be direct or indirect.
|
|
102
|
+
|
|
103
|
+
**Your licenses** are all the licenses granted to you for
|
|
104
|
+
the software under these terms.
|
|
105
|
+
|
|
106
|
+
**Use** means anything you do with the software requiring
|
|
107
|
+
one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# wezterm-mcp
|
|
2
|
+
|
|
3
|
+
Wezterm MCP Server — a programmable terminal control plane for multi-agent AI workflows.
|
|
4
|
+
|
|
5
|
+
Turns [Wezterm](https://wezfurlong.org/wezterm/) into a remote-controllable terminal multiplexer that any AI coding CLI can be orchestrated through. One orchestrator agent spawns, monitors, and communicates with any number of AI agents running in parallel across multiple projects.
|
|
6
|
+
|
|
7
|
+
## What This Does
|
|
8
|
+
|
|
9
|
+
- **Spawn AI agents** in Wezterm panes — Claude Code, Gemini CLI, Codex CLI, OpenCode, Goose
|
|
10
|
+
- **Inject prompts** into running agent sessions as if a human typed them
|
|
11
|
+
- **Read output** from any pane — passive (fast) or deep (asks agents for status)
|
|
12
|
+
- **Manage windows** — one window per project, auto-titled, with N/M numbering for duplicates
|
|
13
|
+
- **Session recovery** — save/restore full layouts including CLI session IDs after a crash
|
|
14
|
+
- **Auto-skip permissions** — each CLI's autonomous mode is handled automatically
|
|
15
|
+
- **Cross-platform** — Linux, macOS, and Windows via a platform abstraction layer
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌─────────────────────────────────────────────────────┐
|
|
21
|
+
│ Your AI Agent (Claude, etc.) │
|
|
22
|
+
│ │
|
|
23
|
+
│ "Launch 5 Claude agents for the auth-service project"│
|
|
24
|
+
│ │ │
|
|
25
|
+
│ MCP Tool Calls │
|
|
26
|
+
│ │ │
|
|
27
|
+
├─────────────────────────┼───────────────────────────┤
|
|
28
|
+
│ wezterm-mcp │
|
|
29
|
+
│ (this MCP server) │
|
|
30
|
+
│ │ │
|
|
31
|
+
│ wezterm cli commands │
|
|
32
|
+
│ │ │
|
|
33
|
+
├─────────────────────────┼───────────────────────────┤
|
|
34
|
+
│ Wezterm │
|
|
35
|
+
│ │
|
|
36
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
37
|
+
│ │ Window 1 │ │ Window 2 │ │ Window 3 │ │
|
|
38
|
+
│ │ auth-svc │ │ pay-api │ │ dashboard│ │
|
|
39
|
+
│ │ ┌──┬──┐ │ │ ┌──┬──┐ │ │ ┌──┐ │ │
|
|
40
|
+
│ │ │C1│C2│ │ │ │C1│G1│ │ │ │C1│ │ │
|
|
41
|
+
│ │ ├──┼──┤ │ │ └──┴──┘ │ │ └──┘ │ │
|
|
42
|
+
│ │ │C3│C4│ │ │ │ │ │ │
|
|
43
|
+
│ │ └──┴──┘ │ │ │ │ │ │
|
|
44
|
+
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
45
|
+
└─────────────────────────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
### Prerequisites
|
|
51
|
+
|
|
52
|
+
- [Node.js](https://nodejs.org/) (v18+)
|
|
53
|
+
- [Wezterm](https://wezfurlong.org/wezterm/installation)
|
|
54
|
+
|
|
55
|
+
### Setup
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
git clone https://github.com/multiagentcognition/wezterm-mcp.git
|
|
59
|
+
cd wezterm-mcp
|
|
60
|
+
npm install
|
|
61
|
+
npm run build
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Wezterm Lua Config
|
|
65
|
+
|
|
66
|
+
Copy `wezterm.lua` to your Wezterm config directory:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Linux
|
|
70
|
+
cp wezterm.lua ~/.config/wezterm/wezterm.lua
|
|
71
|
+
|
|
72
|
+
# macOS
|
|
73
|
+
cp wezterm.lua ~/.config/wezterm/wezterm.lua
|
|
74
|
+
|
|
75
|
+
# Windows
|
|
76
|
+
copy wezterm.lua %USERPROFILE%\.config\wezterm\wezterm.lua
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
It provides:
|
|
80
|
+
- **Auto-maximize** on startup
|
|
81
|
+
- **Window titles** derived from project directory
|
|
82
|
+
- **N/M numbering** for multiple windows of the same project
|
|
83
|
+
- **Tab titles** auto-derived from pane CLI contents (e.g., "Claude (3) + shell")
|
|
84
|
+
- **F11** toggles fullscreen
|
|
85
|
+
|
|
86
|
+
## Configuration
|
|
87
|
+
|
|
88
|
+
Add to your MCP client config (e.g., `.mcp.json`, Claude Code settings, etc.):
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"wezterm": {
|
|
94
|
+
"command": "node",
|
|
95
|
+
"args": ["/path/to/wezterm-mcp/build/wez-mcp.js"],
|
|
96
|
+
"env": {
|
|
97
|
+
"WEZ_PROJECT_ROOT": "/path/to/your/project"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Environment Variables
|
|
105
|
+
|
|
106
|
+
| Variable | Description | Default |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| `WEZ_PROJECT_ROOT` | Default working directory for all panes | `process.cwd()` |
|
|
109
|
+
| `MACP_PROJECT_ROOT` | Fallback if `WEZ_PROJECT_ROOT` not set | — |
|
|
110
|
+
| `WEZ_GIT_BRANCH` | Informational git branch (not enforced) | auto-detected |
|
|
111
|
+
|
|
112
|
+
## Supported CLIs
|
|
113
|
+
|
|
114
|
+
| CLI | Binary | Skip-permissions | Session resume |
|
|
115
|
+
|---|---|---|---|
|
|
116
|
+
| **Claude Code** | `claude` | `--dangerously-skip-permissions` | `--resume <session-id>` or `--continue` |
|
|
117
|
+
| **Gemini CLI** | `gemini` | `--sandbox=none` | `--resume latest` |
|
|
118
|
+
| **Codex CLI** | `codex` | `-a never` | `codex resume <session-id>` or `resume --last` |
|
|
119
|
+
| **OpenCode** | `opencode` | Config: `permission: "allow"` | `--session <id>` or `--continue` |
|
|
120
|
+
| **Goose** | `goose` | Env: `GOOSE_MODE=auto` | `goose session --resume --session-id <id>` |
|
|
121
|
+
|
|
122
|
+
Each CLI's autonomous mode is handled automatically — flags, config files, and env vars are set before launch. Directory trust is pre-configured for Claude Code, Gemini, and Codex so no interactive prompts block startup.
|
|
123
|
+
|
|
124
|
+
## MCP Tools (41 total)
|
|
125
|
+
|
|
126
|
+
### Status & Lifecycle
|
|
127
|
+
|
|
128
|
+
| Tool | Description |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `wez_status` | Full status: windows, tabs, panes with CLI detection and state |
|
|
131
|
+
| `wez_list` | List all panes with CLI type, state, CWD |
|
|
132
|
+
| `wez_start` | Start Wezterm if not running |
|
|
133
|
+
|
|
134
|
+
### Launching
|
|
135
|
+
|
|
136
|
+
| Tool | Description |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `wez_launch_agents` | Open a project window with N agents (auto-grid layout) |
|
|
139
|
+
| `wez_launch_mixed` | Multiple different CLIs in one tab |
|
|
140
|
+
| `wez_launch_grid` | Manual grid of panes (rows × cols) |
|
|
141
|
+
| `wez_spawn` | New window/tab with optional CLI or command |
|
|
142
|
+
| `wez_split` | Split a pane (right/bottom) with optional CLI |
|
|
143
|
+
|
|
144
|
+
### Text I/O
|
|
145
|
+
|
|
146
|
+
| Tool | Description |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `wez_send_text` | Type text into a pane (no Enter) |
|
|
149
|
+
| `wez_send_text_submit` | Type text + Enter (primary method for injecting prompts) |
|
|
150
|
+
| `wez_send_text_all` | Different text to each pane in a tab |
|
|
151
|
+
| `wez_send_text_submit_all` | Broadcast same text to all panes in a tab |
|
|
152
|
+
| `wez_send_text_submit_some` | Send text to specific pane IDs |
|
|
153
|
+
| `wez_get_text` | Read text from a pane (supports scrollback) |
|
|
154
|
+
|
|
155
|
+
### Reading & Monitoring
|
|
156
|
+
|
|
157
|
+
| Tool | Description |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `wez_read_all` | Quick passive read of ALL panes — fast, never interrupts |
|
|
160
|
+
| `wez_read_all_deep` | Deep read — prompts idle agents for status summaries |
|
|
161
|
+
| `wez_read_tab` | Read all panes in a specific tab |
|
|
162
|
+
| `wez_screenshot` | Screenshot the active Wezterm window |
|
|
163
|
+
| `wez_screenshot_all_tabs` | Screenshot each tab |
|
|
164
|
+
|
|
165
|
+
### Special Keys
|
|
166
|
+
|
|
167
|
+
| Tool | Description |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `wez_send_key` | Send ctrl+c, ctrl+d, escape, enter, arrow keys, etc. |
|
|
170
|
+
| `wez_send_key_all` | Send a key to all panes in a tab |
|
|
171
|
+
|
|
172
|
+
### Navigation & Layout
|
|
173
|
+
|
|
174
|
+
| Tool | Description |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `wez_focus_pane` | Focus a pane by ID |
|
|
177
|
+
| `wez_focus_direction` | Focus Up/Down/Left/Right |
|
|
178
|
+
| `wez_focus_tab` | Switch to tab by index |
|
|
179
|
+
| `wez_resize_pane` | Resize a pane |
|
|
180
|
+
| `wez_zoom_pane` | Toggle zoom (maximize/restore) |
|
|
181
|
+
| `wez_move_to_tab` | Move a pane into its own tab |
|
|
182
|
+
| `wez_fullscreen` | Toggle fullscreen |
|
|
183
|
+
|
|
184
|
+
### Titles & Workspace
|
|
185
|
+
|
|
186
|
+
| Tool | Description |
|
|
187
|
+
|---|---|
|
|
188
|
+
| `wez_set_tab_title` | Set a tab's title |
|
|
189
|
+
| `wez_set_window_title` | Set a window's title |
|
|
190
|
+
| `wez_rename_workspace` | Rename a workspace |
|
|
191
|
+
|
|
192
|
+
### Pane Management
|
|
193
|
+
|
|
194
|
+
| Tool | Description |
|
|
195
|
+
|---|---|
|
|
196
|
+
| `wez_kill_pane` | Close a single pane |
|
|
197
|
+
| `wez_kill_tab` | Kill all panes in a tab |
|
|
198
|
+
| `wez_kill_all` | Full shutdown (panes + GUI + mux + sockets) |
|
|
199
|
+
| `wez_kill_gui` | Kill GUI process only |
|
|
200
|
+
| `wez_kill_mux` | Kill mux-server only |
|
|
201
|
+
| `wez_clean_sockets` | Remove stale socket files |
|
|
202
|
+
| `wez_restart_pane` | Kill + relaunch same CLI in place |
|
|
203
|
+
|
|
204
|
+
### Session Recovery
|
|
205
|
+
|
|
206
|
+
| Tool | Description |
|
|
207
|
+
|---|---|
|
|
208
|
+
| `wez_session_save` | Save state (windows, tabs, panes, CLIs, session IDs) to manifest |
|
|
209
|
+
| `wez_session_recover` | Recreate full layout from manifest, resume each CLI session |
|
|
210
|
+
| `wez_reconcile` | Compare manifest vs live state, report drift |
|
|
211
|
+
|
|
212
|
+
## Session Recovery — How It Works
|
|
213
|
+
|
|
214
|
+
### Session ID Capture
|
|
215
|
+
|
|
216
|
+
Each CLI stores sessions differently. The MCP reads session IDs from the filesystem:
|
|
217
|
+
|
|
218
|
+
| CLI | Session ID Source |
|
|
219
|
+
|---|---|
|
|
220
|
+
| Claude | `~/.claude/projects/{encoded}/` → session `.jsonl` files |
|
|
221
|
+
| Gemini | `~/.gemini/projects.json` → slug → chats directory |
|
|
222
|
+
| Codex | `~/.codex/sessions/` → rollout `.jsonl` files |
|
|
223
|
+
| OpenCode | SQLite DB → session table with directory column |
|
|
224
|
+
| Goose | `goose session list --format json` |
|
|
225
|
+
|
|
226
|
+
### Recovery Flow
|
|
227
|
+
|
|
228
|
+
1. **Save** — captures windows → tabs → panes with CLI type, session ID, and CWD
|
|
229
|
+
2. **Crash** — Wezterm dies but manifest and CLI session files persist
|
|
230
|
+
3. **Recover** — recreates windows/tabs/panes, validates each session ID exists on disk, resumes with `--resume <id>` or falls back to `--continue`
|
|
231
|
+
|
|
232
|
+
## Platform Support
|
|
233
|
+
|
|
234
|
+
All OS-specific behavior is centralised in `src/platform.ts` with three implementations sharing a Unix base:
|
|
235
|
+
|
|
236
|
+
| Concern | Linux | macOS | Windows |
|
|
237
|
+
|---|---|---|---|
|
|
238
|
+
| Socket dir | `/run/user/{uid}/wezterm` | `~/.local/share/wezterm` | `~/.local/share/wezterm` |
|
|
239
|
+
| WezTerm binary | PATH | `/Applications/WezTerm.app/...` | `Program Files\WezTerm\` |
|
|
240
|
+
| Screenshot | import/scrot/grim/gnome-screenshot | screencapture | PowerShell |
|
|
241
|
+
| Process mgmt | pgrep/pkill | pgrep/pkill | tasklist/taskkill |
|
|
242
|
+
| Enter key | CR (PTY translates to LF) | CR | LF (ConPTY) |
|
|
243
|
+
| Shell | bash | bash | cmd.exe |
|
|
244
|
+
| CLI wrapping | direct exec | direct exec | cmd.exe /c (npm shims) |
|
|
245
|
+
|
|
246
|
+
## Testing
|
|
247
|
+
|
|
248
|
+
The `test/` directory contains 11 test suites covering all 41 tools:
|
|
249
|
+
|
|
250
|
+
| Test | Focus |
|
|
251
|
+
|---|---|
|
|
252
|
+
| `recovery-test.md` | Full session recovery (7 windows, 22 panes, 14 CLI agents) |
|
|
253
|
+
| `01-startup-status.md` | Status, list, start |
|
|
254
|
+
| `02-spawn-split-read.md` | Spawn, split, get_text |
|
|
255
|
+
| `03-input-methods.md` | send_text, send_text_submit, send_key |
|
|
256
|
+
| `04-bulk-input.md` | Broadcast, per-pane, selective send |
|
|
257
|
+
| `05-navigation.md` | Focus pane, direction, tab |
|
|
258
|
+
| `06-layout.md` | Resize, zoom, move_to_tab, fullscreen |
|
|
259
|
+
| `07-titles-workspace.md` | Tab/window titles, workspace rename |
|
|
260
|
+
| `08-reading-screenshots.md` | read_tab, read_all, read_all_deep, screenshots |
|
|
261
|
+
| `09-lifecycle.md` | kill_pane, kill_tab, restart_pane, kill_gui/mux |
|
|
262
|
+
| `10-launchers-sessions.md` | launch_agents, launch_grid, launch_mixed, save/recover |
|
|
263
|
+
|
|
264
|
+
Tests are designed to be run by an AI agent via MCP tool calls — each test doc describes the steps, expected outputs, and pass criteria.
|
|
265
|
+
|
|
266
|
+
## Known Limitations
|
|
267
|
+
|
|
268
|
+
- **Wezterm version**: Tested with 20240203. The `format-window-title` callback parameter types vary between versions.
|
|
269
|
+
- **Session resume**: Only works if the CLI's session file persists on disk. Short-lived sessions that get cleaned up before save can't be resumed.
|
|
270
|
+
- **Deep read timeout**: `wez_read_all_deep` waits up to 30 seconds per idle agent.
|
|
271
|
+
- **screenshot_all_tabs**: Flaky due to tab-switching timing — may capture 0 tabs.
|
|
272
|
+
- **Stale mux servers**: Wezterm can leave stale mux servers. After `wez_kill_all`, use `wez_start` before spawning new panes.
|
|
273
|
+
|
|
274
|
+
## Disclaimer
|
|
275
|
+
|
|
276
|
+
**USE AT YOUR OWN RISK.** This software launches AI coding agents in autonomous mode with permissions to read, write, and execute files on your system. By design, it bypasses each CLI's safety prompts (`--dangerously-skip-permissions`, `--sandbox=none`, `-a never`, etc.) so agents can operate without human approval of individual actions.
|
|
277
|
+
|
|
278
|
+
This means:
|
|
279
|
+
- Agents **can and will** modify files, run shell commands, and make network requests without asking
|
|
280
|
+
- Multiple agents running in parallel can produce unexpected interactions
|
|
281
|
+
- There is no undo — changes agents make to your filesystem are immediate and permanent
|
|
282
|
+
- Session recovery resumes agents with full conversation context, which may include stale or incorrect instructions
|
|
283
|
+
|
|
284
|
+
**Do not run this on production systems, with access to sensitive data, or in environments where unreviewed code execution is unacceptable.** Use isolated directories, sandboxed environments, or disposable VMs when possible. The authors accept no liability for any damage, data loss, or unintended consequences resulting from use of this software.
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
[PolyForm Strict 1.0.0](https://polyformproject.org/licenses/strict/1.0.0) — personal and non-commercial use only. No modifications, no commercial/enterprise use. See [LICENSE](LICENSE) for full terms.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform abstraction layer for Wezterm MCP Server.
|
|
3
|
+
*
|
|
4
|
+
* Centralises all OS-specific behaviour so the main code never
|
|
5
|
+
* branches on IS_WIN / IS_MAC. Three concrete implementations
|
|
6
|
+
* share a Unix base; Linux and macOS override where they differ.
|
|
7
|
+
*/
|
|
8
|
+
declare function sleepMs(ms: number): void;
|
|
9
|
+
export interface Platform {
|
|
10
|
+
readonly name: 'linux' | 'macos' | 'windows';
|
|
11
|
+
weztermBin(): string;
|
|
12
|
+
weztermGuiBin(): string;
|
|
13
|
+
isWezInstalled(): boolean;
|
|
14
|
+
isProcessRunning(name: string): boolean;
|
|
15
|
+
killProcess(name: string): void;
|
|
16
|
+
socketDir(): string;
|
|
17
|
+
/** Value for execSync's `shell` option. */
|
|
18
|
+
readonly shell: string | true;
|
|
19
|
+
/** Default interactive shell binary (bash / cmd.exe). */
|
|
20
|
+
readonly defaultShell: string;
|
|
21
|
+
/** Wrap a command string for shell execution → [shell, flag, cmd]. */
|
|
22
|
+
shellExec(cmd: string): string[];
|
|
23
|
+
/** Syntax for setting an env var inline: 'KEY=val' (unix) / 'set KEY=val' (win). */
|
|
24
|
+
setEnvCmd(key: string, val: string): string;
|
|
25
|
+
/** Build a shell command with env var prefixes: 'K=v cmd' (unix) / 'set K=v && cmd' (win). */
|
|
26
|
+
envShellCommand(envParts: string[], cmd: string): string;
|
|
27
|
+
/** Character to send as Enter keypress. CR on Unix (PTY icrnl translates to LF), LF on Windows (ConPTY has no icrnl). */
|
|
28
|
+
readonly enterKey: string;
|
|
29
|
+
/** Cross-platform synchronous sleep. */
|
|
30
|
+
sleep(seconds: number): void;
|
|
31
|
+
/** Find the PID of a CLI binary running on a given TTY/pane. */
|
|
32
|
+
getCliPid(ttyName: string, binName: string): string | null;
|
|
33
|
+
/** Return both slash variants of a path (forward + backslash). Single-item on Unix. */
|
|
34
|
+
pathVariants(cwd: string): string[];
|
|
35
|
+
/** Normalise a file:// URI (as returned by wezterm list) to a local path. */
|
|
36
|
+
normalizeCwd(raw: string): string;
|
|
37
|
+
/** Encode a cwd for Claude's trust directory name. */
|
|
38
|
+
encodeTrustPath(cwd: string): string;
|
|
39
|
+
/** Strip trailing path separator(s). */
|
|
40
|
+
stripTrailingSep(p: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* On Windows npm-installed CLIs use .cmd wrappers that wezterm cannot exec
|
|
43
|
+
* directly — wrap them in cmd.exe. On Unix this is a no-op pass-through.
|
|
44
|
+
* Returns { parts, shellCommand, needsShell }.
|
|
45
|
+
*/
|
|
46
|
+
wrapCliForSpawn(cli: string, parts: string[]): {
|
|
47
|
+
parts: string[];
|
|
48
|
+
shellCommand: string;
|
|
49
|
+
needsShell: boolean;
|
|
50
|
+
};
|
|
51
|
+
screenshotCmds(filePath: string): string[];
|
|
52
|
+
readonly screenshotErrorMsg: string;
|
|
53
|
+
toggleFullscreen(): void;
|
|
54
|
+
readonly fullscreenErrorMsg: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const OS: Platform;
|
|
57
|
+
export { sleepMs };
|