terminator-mcp-agent 0.9.4 → 0.9.6
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/README.md +51 -30
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -130,31 +130,62 @@ This is the most powerful and flexible method. You build a workflow step-by-step
|
|
|
130
130
|
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.
|
|
131
131
|
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.
|
|
132
132
|
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.
|
|
133
|
-
4. **Extract Structured Data with `output_parser`**: Add the `output_parser` argument to your `execute_sequence` call.
|
|
133
|
+
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.
|
|
134
134
|
|
|
135
135
|
Here is an example of an `output_parser` that extracts insurance quote data from a web page:
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
```yaml
|
|
137
|
+
output_parser:
|
|
138
|
+
ui_tree_source_step_id: capture_quotes_tree
|
|
139
|
+
javascript_code: |
|
|
140
|
+
// Find all quote groups with Image and Text children
|
|
141
|
+
const results = [];
|
|
142
|
+
|
|
143
|
+
function findElementsRecursively(element) {
|
|
144
|
+
if (element.attributes && element.attributes.role === 'Group') {
|
|
145
|
+
const children = element.children || [];
|
|
146
|
+
const hasImage = children.some(child =>
|
|
147
|
+
child.attributes && child.attributes.role === 'Image'
|
|
148
|
+
);
|
|
149
|
+
const hasText = children.some(child =>
|
|
150
|
+
child.attributes && child.attributes.role === 'Text'
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
if (hasImage && hasText) {
|
|
154
|
+
const textElements = children.filter(child =>
|
|
155
|
+
child.attributes && child.attributes.role === 'Text' && child.attributes.name
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
let carrierProduct = '';
|
|
159
|
+
let monthlyPrice = '';
|
|
160
|
+
|
|
161
|
+
for (const textEl of textElements) {
|
|
162
|
+
const text = textEl.attributes.name;
|
|
163
|
+
if (text.includes(':')) {
|
|
164
|
+
carrierProduct = text;
|
|
165
|
+
}
|
|
166
|
+
if (text.startsWith('$')) {
|
|
167
|
+
monthlyPrice = text;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (carrierProduct && monthlyPrice) {
|
|
172
|
+
results.push({
|
|
173
|
+
carrierProduct: carrierProduct,
|
|
174
|
+
monthlyPrice: monthlyPrice
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
147
178
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"conditions": [{ "property": "name", "op": "startsWith", "value": "$" }],
|
|
153
|
-
"extractProperty": "name"
|
|
179
|
+
|
|
180
|
+
if (element.children) {
|
|
181
|
+
for (const child of element.children) {
|
|
182
|
+
findElementsRecursively(child);
|
|
154
183
|
}
|
|
155
184
|
}
|
|
156
185
|
}
|
|
157
|
-
|
|
186
|
+
|
|
187
|
+
findElementsRecursively(tree);
|
|
188
|
+
return results;
|
|
158
189
|
```
|
|
159
190
|
|
|
160
191
|
#### 2. Recording Human Actions with `record_workflow`
|
|
@@ -397,17 +428,7 @@ For additional help, see the [Terminator CLI documentation](../terminator-cli/RE
|
|
|
397
428
|
}
|
|
398
429
|
],
|
|
399
430
|
"output_parser": { // 5️⃣ Turn the tree into clean JSON
|
|
400
|
-
"
|
|
401
|
-
"fieldsToExtract": {
|
|
402
|
-
"displayValue": {
|
|
403
|
-
"fromChild": {
|
|
404
|
-
"conditions": [
|
|
405
|
-
{ "property": "role", "op": "equals", "value": "Text" }
|
|
406
|
-
],
|
|
407
|
-
"extractProperty": "name"
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
431
|
+
"javascript_code": "// Extract calculator display value\nconst results = [];\n\nfunction findElementsRecursively(element) {\n if (element.attributes && element.attributes.role === 'Text') {\n const item = {\n displayValue: element.attributes.name || ''\n };\n results.push(item);\n }\n \n if (element.children) {\n for (const child of element.children) {\n findElementsRecursively(child);\n }\n }\n}\n\nfindElementsRecursively(tree);\nreturn results;"
|
|
411
432
|
}
|
|
412
433
|
}
|
|
413
434
|
}
|
package/package.json
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
],
|
|
13
13
|
"name": "terminator-mcp-agent",
|
|
14
14
|
"optionalDependencies": {
|
|
15
|
-
"terminator-mcp-darwin-arm64": "0.9.
|
|
16
|
-
"terminator-mcp-darwin-x64": "0.9.
|
|
17
|
-
"terminator-mcp-linux-x64-gnu": "0.9.
|
|
18
|
-
"terminator-mcp-win32-x64-msvc": "0.9.
|
|
15
|
+
"terminator-mcp-darwin-arm64": "0.9.6",
|
|
16
|
+
"terminator-mcp-darwin-x64": "0.9.6",
|
|
17
|
+
"terminator-mcp-linux-x64-gnu": "0.9.6",
|
|
18
|
+
"terminator-mcp-win32-x64-msvc": "0.9.6"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"sync-version": "node ./utils/sync-version.js",
|
|
28
28
|
"update-badges": "node ./utils/update-badges.js"
|
|
29
29
|
},
|
|
30
|
-
"version": "0.9.
|
|
30
|
+
"version": "0.9.6"
|
|
31
31
|
}
|