terminator-mcp-agent 0.15.19 → 0.16.3

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.
Files changed (3) hide show
  1. package/README.md +10 -13
  2. package/index.js +51 -3
  3. package/package.json +7 -6
package/README.md CHANGED
@@ -233,9 +233,9 @@ The Terminator MCP agent offers two primary workflows for automating desktop tas
233
233
  This is the most powerful and flexible method. You build a workflow step-by-step, using MCP tools to inspect the UI and refine your actions.
234
234
 
235
235
  1. **Inspect the UI**: Start by using `get_focused_window_tree` to understand the structure of your target application. This gives you the roles, names, and IDs of all elements. For performance optimization:
236
- - Use `include_tree: { max_depth: 2 }` to limit tree depth when you only need shallow inspection
237
- - Use `include_tree: { from_selector: "role:Dialog" }` to get subtree from a specific element
238
- - Use `include_tree: { from_selector: "true" }` to start from the currently focused element
236
+ - Use `tree_max_depth: 2` to limit tree depth when you only need shallow inspection
237
+ - Use `tree_from_selector: "role:Dialog"` to get subtree from a specific element
238
+ - Use `tree_from_selector: "true"` to start from the currently focused element
239
239
  2. **Build a Sequence**: Create an `execute_sequence` tool call with a series of actions (`click_element`, `type_into_element`, etc.). Use robust selectors (like `role|name` or stable `properties:AutomationId:value` selectors) whenever possible.
240
240
  3. **Capture the Final State**: Ensure the last step in your sequence is an action that returns a UI tree. The `wait_for_element` tool with `include_tree: true` is perfect for this, as it captures the application's state after your automation has run.
241
241
  4. **Extract Structured Data with `output_parser`**: Add the `output_parser` argument to your `execute_sequence` call. Write JavaScript code to parse the final UI tree and extract structured data. If successful, the tool result will contain a `parsed_output` field with your clean JSON data.
@@ -717,9 +717,9 @@ The virtual display manager creates a memory-based display context that satisfie
717
717
  - Implement delays between rapid operations
718
718
  - Consider using `include_tree: false` for intermediate steps
719
719
  - For tree extraction tools, optimize with:
720
- - `include_tree: { max_depth: 2 }` - Limit depth for large trees
721
- - `include_tree: { from_selector: "role:List" }` - Get subtree from specific element
722
- - `include_tree: { from_selector: "true" }` - Start from focused element
720
+ - `tree_max_depth: 2` - Limit depth for large trees
721
+ - `tree_from_selector: "role:List"` - Get subtree from specific element
722
+ - `tree_from_selector: "true"` - Start from focused element
723
723
 
724
724
  **JavaScript Performance**:
725
725
 
@@ -907,19 +907,16 @@ steps:
907
907
  - tool_name: get_window_tree
908
908
  arguments:
909
909
  pid: 1234
910
- include_tree:
911
- max_depth: 2 # Only get 2 levels deep
910
+ tree_max_depth: 2 # Only get 2 levels deep
912
911
 
913
912
  - tool_name: get_focused_window_tree
914
913
  arguments:
915
- include_tree:
916
- from_selector: "role:Dialog" # Start tree from first dialog
917
- max_depth: 3 # Limit depth from that point
914
+ tree_from_selector: "role:Dialog" # Start tree from first dialog
915
+ tree_max_depth: 3 # Limit depth from that point
918
916
 
919
917
  - tool_name: get_focused_window_tree
920
918
  arguments:
921
- include_tree:
922
- from_selector: "true" # Start from focused element
919
+ tree_from_selector: "true" # Start from focused element
923
920
 
924
921
  # Backward compatible - still works
925
922
  - tool_name: get_window_tree
package/index.js CHANGED
@@ -185,10 +185,58 @@ if (argv.includes("--add-to-app")) {
185
185
  process.on("SIGTERM", shutdown);
186
186
  process.on("exit", shutdown);
187
187
 
188
- child.on("exit", (code) => {
189
- if (code !== 0) {
190
- console.error(`[MCP exited with code ${code}]`);
188
+ let restartAttempts = 0;
189
+ const MAX_RESTART_ATTEMPTS = 3;
190
+ const RESTART_DELAY = 1000; // 1 second
191
+
192
+ child.on("exit", (code, signal) => {
193
+ // Check for stack overflow exit code on Windows (3221225725 = 0xC00000FD)
194
+ const isStackOverflow = code === 3221225725 || code === -1073741571;
195
+
196
+ if (code !== 0 && !shuttingDown) {
197
+ console.error(`[MCP exited with code ${code}${signal ? ` (signal: ${signal})` : ''}]`);
198
+
199
+ // Auto-restart on crash if under max attempts
200
+ if (restartAttempts < MAX_RESTART_ATTEMPTS) {
201
+ restartAttempts++;
202
+
203
+ if (isStackOverflow) {
204
+ console.error(`[Stack overflow detected - this often happens with deeply nested UI trees]`);
205
+ }
206
+
207
+ console.error(`[Attempting to restart MCP server (attempt ${restartAttempts}/${MAX_RESTART_ATTEMPTS})...]`);
208
+
209
+ setTimeout(() => {
210
+ console.error(`[Restarting MCP server...]`);
211
+
212
+ // Spawn new process
213
+ const newChild = spawn(binary, agentArgs, {
214
+ stdio: ["pipe", "pipe", "pipe"],
215
+ shell: false,
216
+ detached: process.platform !== "win32",
217
+ });
218
+
219
+ // Reconnect pipes
220
+ process.stdin.unpipe(child.stdin);
221
+ process.stdin.pipe(newChild.stdin);
222
+ newChild.stdout.pipe(process.stdout);
223
+ newChild.stderr.pipe(process.stderr);
224
+
225
+ // Replace child reference
226
+ child = newChild;
227
+
228
+ // Reattach exit handler with same logic
229
+ child.on("exit", arguments.callee);
230
+
231
+ console.error(`[MCP server restarted successfully]`);
232
+ }, RESTART_DELAY);
233
+
234
+ return; // Don't exit the wrapper process
235
+ } else {
236
+ console.error(`[Max restart attempts reached. Exiting.]`);
237
+ }
191
238
  }
239
+
192
240
  process.exit(code);
193
241
  });
194
242
  }
package/package.json CHANGED
@@ -3,7 +3,8 @@
3
3
  "terminator-mcp-agent": "index.js"
4
4
  },
5
5
  "dependencies": {
6
- "@modelcontextprotocol/sdk": "^1.17.3"
6
+ "@modelcontextprotocol/sdk": "^1.17.3",
7
+ "node-fetch": "^2.7.0"
7
8
  },
8
9
  "description": "Cross-platform Model Context Protocol (MCP) agent for Terminator",
9
10
  "engines": {
@@ -15,10 +16,10 @@
15
16
  ],
16
17
  "name": "terminator-mcp-agent",
17
18
  "optionalDependencies": {
18
- "terminator-mcp-darwin-arm64": "0.15.19",
19
- "terminator-mcp-darwin-x64": "0.15.19",
20
- "terminator-mcp-linux-x64-gnu": "0.15.19",
21
- "terminator-mcp-win32-x64-msvc": "0.15.19"
19
+ "terminator-mcp-darwin-arm64": "0.16.3",
20
+ "terminator-mcp-darwin-x64": "0.16.3",
21
+ "terminator-mcp-linux-x64-gnu": "0.16.3",
22
+ "terminator-mcp-win32-x64-msvc": "0.16.3"
22
23
  },
23
24
  "repository": {
24
25
  "type": "git",
@@ -30,5 +31,5 @@
30
31
  "sync-version": "node ./utils/sync-version.js",
31
32
  "update-badges": "node ./utils/update-badges.js"
32
33
  },
33
- "version": "0.15.19"
34
+ "version": "0.16.3"
34
35
  }