terminator-mcp-agent 0.12.18 → 0.13.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.
Files changed (2) hide show
  1. package/README.md +145 -8
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -117,15 +117,15 @@ Tool call wrapper format (`workflow.json`):
117
117
  }
118
118
  ```
119
119
 
120
- **JavaScript Execution in Workflows:**
120
+ **Code Execution in Workflows (engine mode):**
121
121
 
122
- Execute custom JavaScript code with access to desktop automation APIs:
122
+ Execute custom JavaScript or Python with access to desktop automation APIs via `run_command`:
123
123
 
124
124
  ```yaml
125
125
  steps:
126
- - tool_name: run_javascript
126
+ - tool_name: run_command
127
127
  arguments:
128
- engine: "nodejs"
128
+ engine: "javascript"
129
129
  script: |
130
130
  // Access desktop automation APIs
131
131
  const elements = await desktop.locator('role:button').all();
@@ -227,6 +227,140 @@ For simpler tasks, you can record your own actions to generate a baseline workfl
227
227
  3. **Stop and Save**: Call `record_workflow` with `action: "stop"`. This returns a complete workflow JSON file containing all your recorded actions.
228
228
  4. **Refine and Parse**: The recorded workflow is a great starting point. You can then refine the selectors for robustness, add a final step to capture the UI tree, and attach an `output_parser` to extract structured data, just as you would in the iterative workflow.
229
229
 
230
+ ### Browser DOM Inspection
231
+
232
+ The `execute_browser_script` tool enables direct JavaScript execution in browser contexts, providing access to the full HTML DOM. This is particularly useful when you need information not available in the accessibility tree.
233
+
234
+ #### When to Use DOM vs Accessibility Tree
235
+
236
+ **Use Accessibility Tree (default) when:**
237
+ - Navigating and interacting with UI elements
238
+ - Working with semantic page structure
239
+ - Building reliable automation workflows
240
+ - Performance is critical (faster, cleaner data)
241
+
242
+ **Use DOM Inspection when:**
243
+ - Extracting data attributes, meta tags, or hidden inputs
244
+ - Debugging why elements aren't appearing in accessibility tree
245
+ - Scraping structured data from specific HTML patterns
246
+ - Validating complete page structure or SEO elements
247
+
248
+ #### Basic DOM Retrieval Patterns
249
+
250
+ ```javascript
251
+ // Get full HTML DOM (be mindful of size limits)
252
+ execute_browser_script({
253
+ selector: "role:Window|name:Google Chrome",
254
+ script: "document.documentElement.outerHTML"
255
+ })
256
+
257
+ // Get structured page information
258
+ execute_browser_script({
259
+ selector: "role:Window|name:Google Chrome",
260
+ script: `({
261
+ url: window.location.href,
262
+ title: document.title,
263
+ html: document.documentElement.outerHTML,
264
+ bodyText: document.body.innerText.substring(0, 1000)
265
+ })`
266
+ })
267
+
268
+ // Extract specific data (forms, hidden inputs, meta tags)
269
+ execute_browser_script({
270
+ selector: "role:Window|name:Google Chrome",
271
+ script: `({
272
+ forms: Array.from(document.forms).map(f => ({
273
+ id: f.id,
274
+ action: f.action,
275
+ method: f.method,
276
+ inputs: Array.from(f.elements).map(e => ({
277
+ name: e.name,
278
+ type: e.type,
279
+ value: e.type === 'password' ? '[REDACTED]' : e.value
280
+ }))
281
+ })),
282
+ hiddenInputs: Array.from(document.querySelectorAll('input[type="hidden"]')).map(e => ({
283
+ name: e.name,
284
+ value: e.value
285
+ })),
286
+ metaTags: Array.from(document.querySelectorAll('meta')).map(m => ({
287
+ name: m.name || m.property,
288
+ content: m.content
289
+ }))
290
+ })`
291
+ })
292
+ ```
293
+
294
+ #### Handling Large DOMs
295
+
296
+ The MCP protocol has response size limits (~30KB). For large DOMs, use truncation strategies:
297
+
298
+ ```javascript
299
+ execute_browser_script({
300
+ selector: "role:Window|name:Google Chrome",
301
+ script: `
302
+ const html = document.documentElement.outerHTML;
303
+ const maxLength = 30000;
304
+
305
+ ({
306
+ url: window.location.href,
307
+ title: document.title,
308
+ html: html.length > maxLength
309
+ ? html.substring(0, maxLength) + '... [truncated at ' + maxLength + ' chars]'
310
+ : html,
311
+ totalLength: html.length,
312
+ truncated: html.length > maxLength
313
+ })
314
+ `
315
+ })
316
+ ```
317
+
318
+ #### Advanced DOM Analysis
319
+
320
+ ```javascript
321
+ // Analyze page structure and extract semantic content
322
+ execute_browser_script({
323
+ selector: "role:Window|name:Google Chrome",
324
+ script: `
325
+ // Remove scripts and styles for cleaner analysis
326
+ const clonedDoc = document.documentElement.cloneNode(true);
327
+ clonedDoc.querySelectorAll('script, style, noscript').forEach(el => el.remove());
328
+
329
+ ({
330
+ // Page metrics
331
+ domElementCount: document.querySelectorAll('*').length,
332
+ formCount: document.forms.length,
333
+ linkCount: document.links.length,
334
+ imageCount: document.images.length,
335
+
336
+ // Semantic structure
337
+ headings: Array.from(document.querySelectorAll('h1,h2,h3')).map(h => ({
338
+ level: h.tagName,
339
+ text: h.innerText.substring(0, 100)
340
+ })),
341
+
342
+ // Clean HTML without scripts/styles
343
+ cleanHtml: clonedDoc.outerHTML.substring(0, 20000),
344
+
345
+ // Data extraction
346
+ jsonLd: Array.from(document.querySelectorAll('script[type="application/ld+json"]'))
347
+ .map(s => { try { return JSON.parse(s.textContent); } catch { return null; } })
348
+ .filter(Boolean)
349
+ })
350
+ `
351
+ })
352
+ ```
353
+
354
+ #### Important Notes
355
+
356
+ 1. **Chrome Extension Required**: The `execute_browser_script` tool requires the Terminator browser extension to be installed. See the installation workflow examples for automated setup.
357
+
358
+ 2. **Security Considerations**: Be cautious when extracting sensitive data. The examples above redact password fields and you should follow similar practices.
359
+
360
+ 3. **Performance**: DOM operations are synchronous and can be slow on large pages. Consider using specific selectors rather than traversing the entire DOM.
361
+
362
+ 4. **Error Handling**: Always wrap complex DOM operations in try-catch blocks and return meaningful error messages.
363
+
230
364
  ## Local Development
231
365
 
232
366
  To build and test the agent from the source code:
@@ -309,11 +443,14 @@ terminator mcp run workflow.yml --url http://localhost:3000/mcp
309
443
  **Solution**: Verify JavaScript execution and API access:
310
444
 
311
445
  ```bash
312
- # Test basic JavaScript execution
313
- terminator mcp exec run_javascript '{"script": "return {test: true};"}'
446
+ # Test basic JavaScript execution via run_command engine mode
447
+ terminator mcp exec run_command '{"engine": "javascript", "run": "return {test: true};"}'
448
+
449
+ # Test desktop API access with node engine
450
+ terminator mcp exec run_command '{"engine": "node", "run": "const elements = await desktop.locator(\\\"role:button\\\").all(); return {count: elements.length};"}'
314
451
 
315
- # Test desktop API access with nodejs engine
316
- terminator mcp exec run_javascript '{"engine": "nodejs", "script": "const elements = await desktop.locator(\"role:button\").all(); return {count: elements.length};"}'
452
+ # Test Python engine
453
+ terminator mcp exec run_command '{"engine": "python", "run": "return {\\\"py\\\": True}"}'
317
454
 
318
455
  # Debug with verbose logging
319
456
  terminator mcp run workflow.yml --verbose
package/package.json CHANGED
@@ -15,10 +15,10 @@
15
15
  ],
16
16
  "name": "terminator-mcp-agent",
17
17
  "optionalDependencies": {
18
- "terminator-mcp-darwin-arm64": "0.12.18",
19
- "terminator-mcp-darwin-x64": "0.12.18",
20
- "terminator-mcp-linux-x64-gnu": "0.12.18",
21
- "terminator-mcp-win32-x64-msvc": "0.12.18"
18
+ "terminator-mcp-darwin-arm64": "0.13.0",
19
+ "terminator-mcp-darwin-x64": "0.13.0",
20
+ "terminator-mcp-linux-x64-gnu": "0.13.0",
21
+ "terminator-mcp-win32-x64-msvc": "0.13.0"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
@@ -30,5 +30,5 @@
30
30
  "sync-version": "node ./utils/sync-version.js",
31
31
  "update-badges": "node ./utils/update-badges.js"
32
32
  },
33
- "version": "0.12.18"
33
+ "version": "0.13.0"
34
34
  }