tauri-agent-tools 0.2.1 → 0.4.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/.agents/skills/tauri-agent-tools/SKILL.md +63 -6
- package/.agents/skills/tauri-bridge-setup/SKILL.md +24 -2
- package/AGENTS.md +8 -3
- package/README.md +58 -4
- package/dist/bridge/client.d.ts +5 -2
- package/dist/bridge/client.js +26 -4
- package/dist/bridge/client.js.map +1 -1
- package/dist/bridge/tokenDiscovery.d.ts +1 -1
- package/dist/bridge/tokenDiscovery.js +3 -6
- package/dist/bridge/tokenDiscovery.js.map +1 -1
- package/dist/cli.js +10 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/consoleMonitor.js +15 -10
- package/dist/commands/consoleMonitor.js.map +1 -1
- package/dist/commands/diff.d.ts +2 -0
- package/dist/commands/diff.js +91 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/dom.d.ts +1 -0
- package/dist/commands/dom.js +81 -6
- package/dist/commands/dom.js.map +1 -1
- package/dist/commands/eval.js +6 -1
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/ipcMonitor.js +21 -9
- package/dist/commands/ipcMonitor.js.map +1 -1
- package/dist/commands/listWindows.js +5 -1
- package/dist/commands/listWindows.js.map +1 -1
- package/dist/commands/mutations.d.ts +5 -0
- package/dist/commands/mutations.js +146 -0
- package/dist/commands/mutations.js.map +1 -0
- package/dist/commands/pageState.js +2 -1
- package/dist/commands/pageState.js.map +1 -1
- package/dist/commands/rustLogs.d.ts +2 -0
- package/dist/commands/rustLogs.js +105 -0
- package/dist/commands/rustLogs.js.map +1 -0
- package/dist/commands/screenshot.js +12 -2
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/shared.d.ts +6 -0
- package/dist/commands/shared.js +11 -0
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/snapshot.d.ts +3 -0
- package/dist/commands/snapshot.js +138 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/storage.js +26 -22
- package/dist/commands/storage.js.map +1 -1
- package/dist/commands/wait.js +27 -5
- package/dist/commands/wait.js.map +1 -1
- package/dist/platform/macos.d.ts +2 -1
- package/dist/platform/macos.js +3 -1
- package/dist/platform/macos.js.map +1 -1
- package/dist/platform/wayland.d.ts +2 -1
- package/dist/platform/wayland.js +4 -3
- package/dist/platform/wayland.js.map +1 -1
- package/dist/platform/x11.d.ts +2 -1
- package/dist/platform/x11.js +17 -18
- package/dist/platform/x11.js.map +1 -1
- package/dist/schemas/bridge.d.ts +120 -0
- package/dist/schemas/bridge.js +38 -0
- package/dist/schemas/bridge.js.map +1 -0
- package/dist/schemas/commands.d.ts +245 -0
- package/dist/schemas/commands.js +65 -0
- package/dist/schemas/commands.js.map +1 -0
- package/dist/schemas/dom.d.ts +22 -0
- package/dist/schemas/dom.js +22 -0
- package/dist/schemas/dom.js.map +1 -0
- package/dist/schemas/index.d.ts +11 -0
- package/dist/schemas/index.js +12 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/platform.d.ts +61 -0
- package/dist/schemas/platform.js +34 -0
- package/dist/schemas/platform.js.map +1 -0
- package/dist/types.d.ts +2 -11
- package/dist/util/exec.js +2 -4
- package/dist/util/exec.js.map +1 -1
- package/dist/util/image.d.ts +2 -1
- package/dist/util/image.js.map +1 -1
- package/examples/tauri-bridge/Cargo.toml +2 -0
- package/examples/tauri-bridge/src/dev_bridge.rs +232 -7
- package/package.json +6 -3
- package/rust-bridge/README.md +9 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tauri-agent-tools
|
|
3
3
|
description: CLI for inspecting Tauri desktop apps — DOM queries, screenshots, IPC/console monitoring, storage, and page state
|
|
4
|
-
version: 0.
|
|
5
|
-
tags: [tauri, desktop, debugging, screenshot, dom, inspection]
|
|
4
|
+
version: 0.4.0
|
|
5
|
+
tags: [tauri, desktop, debugging, screenshot, dom, inspection, diff, mutations, snapshot]
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# tauri-agent-tools
|
|
@@ -32,10 +32,10 @@ npm install -g tauri-agent-tools
|
|
|
32
32
|
Some commands require the Rust dev bridge running inside the Tauri app. Others work standalone.
|
|
33
33
|
|
|
34
34
|
**Bridge required** (needs running Tauri app with bridge):
|
|
35
|
-
`screenshot --selector`, `dom`, `eval`, `wait --selector`, `wait --eval`, `ipc-monitor`, `console-monitor`, `storage`, `page-state`
|
|
35
|
+
`screenshot --selector`, `dom`, `eval`, `wait --selector`, `wait --eval`, `ipc-monitor`, `console-monitor`, `rust-logs`, `storage`, `page-state`, `mutations`, `snapshot`
|
|
36
36
|
|
|
37
37
|
**Standalone** (no bridge needed):
|
|
38
|
-
`screenshot --title` (full window only), `wait --title`, `list-windows`, `info`
|
|
38
|
+
`screenshot --title` (full window only), `wait --title`, `list-windows`, `info`, `diff`
|
|
39
39
|
|
|
40
40
|
The bridge auto-discovers via token files in `/tmp/tauri-dev-bridge-*.token`. No manual port/token configuration needed.
|
|
41
41
|
|
|
@@ -80,25 +80,82 @@ tauri-agent-tools storage --type local --json
|
|
|
80
80
|
tauri-agent-tools console-monitor --level error --duration 5000 --json
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
### Capture a full debug snapshot
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Screenshot + DOM + page state + storage in one call
|
|
87
|
+
tauri-agent-tools snapshot -o /tmp/debug --json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Compare screenshots
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Pixel-level comparison
|
|
94
|
+
tauri-agent-tools diff /tmp/before.png /tmp/after.png --json
|
|
95
|
+
|
|
96
|
+
# Fail CI if more than 1% of pixels differ
|
|
97
|
+
tauri-agent-tools diff /tmp/expected.png /tmp/actual.png --threshold 1
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Monitor Rust logs and sidecar output
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Watch Rust tracing logs for 10 seconds
|
|
104
|
+
tauri-agent-tools rust-logs --duration 10000 --json
|
|
105
|
+
|
|
106
|
+
# Only warnings and errors (severity-based: warn shows warn+error)
|
|
107
|
+
tauri-agent-tools rust-logs --level warn --duration 5000 --json
|
|
108
|
+
|
|
109
|
+
# Filter to a specific Rust module
|
|
110
|
+
tauri-agent-tools rust-logs --target "myapp::db" --duration 5000 --json
|
|
111
|
+
|
|
112
|
+
# Only sidecar output (e.g. ffmpeg, python scripts)
|
|
113
|
+
tauri-agent-tools rust-logs --source sidecar --duration 10000 --json
|
|
114
|
+
|
|
115
|
+
# Specific sidecar
|
|
116
|
+
tauri-agent-tools rust-logs --source sidecar:ffmpeg --duration 5000 --json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Watch DOM mutations
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Observe child additions/removals for 10 seconds
|
|
123
|
+
tauri-agent-tools mutations "#todo-list" --duration 10000 --json
|
|
124
|
+
|
|
125
|
+
# Also track attribute changes
|
|
126
|
+
tauri-agent-tools mutations ".sidebar" --attributes --duration 5000
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Find elements by text
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Search for elements containing text
|
|
133
|
+
tauri-agent-tools dom --text "Settings" --first --json
|
|
134
|
+
```
|
|
135
|
+
|
|
83
136
|
## Command Reference
|
|
84
137
|
|
|
85
138
|
| Command | Key Flags | Bridge? | Description |
|
|
86
139
|
|---------|-----------|---------|-------------|
|
|
87
140
|
| `screenshot` | `--selector <css>`, `--title <regex>`, `-o <path>`, `--max-width <n>` | selector: yes, title: no | Capture window or DOM element screenshot |
|
|
88
|
-
| `dom` | `[selector]`, `--depth <n>`, `--styles`, `--mode accessibility`, `--json` | yes | Query DOM structure |
|
|
141
|
+
| `dom` | `[selector]`, `--depth <n>`, `--styles`, `--text <pattern>`, `--mode accessibility`, `--json` | yes | Query DOM structure or find elements by text |
|
|
89
142
|
| `eval` | `<js-expression>` | yes | Evaluate JavaScript in webview |
|
|
90
143
|
| `wait` | `--selector <css>`, `--eval <js>`, `--title <regex>`, `--timeout <ms>` | selector/eval: yes | Wait for a condition |
|
|
91
144
|
| `list-windows` | `--tauri`, `--json` | no | List visible windows |
|
|
92
145
|
| `info` | `--title <regex>`, `--json` | no | Window geometry and display info |
|
|
93
146
|
| `ipc-monitor` | `--filter <cmd>`, `--duration <ms>`, `--json` | yes | Monitor Tauri IPC calls |
|
|
94
147
|
| `console-monitor` | `--level <lvl>`, `--filter <regex>`, `--duration <ms>`, `--json` | yes | Monitor console output |
|
|
148
|
+
| `rust-logs` | `--level <lvl>`, `--target <regex>`, `--source <src>`, `--duration <ms>`, `--json` | yes | Monitor Rust logs and sidecar output |
|
|
95
149
|
| `storage` | `--type <local\|session\|cookies\|all>`, `--key <name>`, `--json` | yes | Inspect browser storage |
|
|
96
150
|
| `page-state` | `--json` | yes | URL, title, viewport, scroll, document size |
|
|
151
|
+
| `diff` | `<image1> <image2>`, `-o <path>`, `--threshold <pct>`, `--json` | no | Compare two screenshots with difference metrics |
|
|
152
|
+
| `mutations` | `<selector>`, `--attributes`, `--duration <ms>`, `--json` | yes | Watch DOM mutations on a CSS selector |
|
|
153
|
+
| `snapshot` | `-o <prefix>`, `-s <css>`, `--dom-depth <n>`, `--eval <js>`, `--json` | yes | Capture screenshot + DOM + page state + storage in one shot |
|
|
97
154
|
|
|
98
155
|
## Important Notes
|
|
99
156
|
|
|
100
157
|
- **All read-only.** No commands modify app state, inject input, or write to storage.
|
|
101
158
|
- **Use `--json`** for structured, parseable output in automation.
|
|
102
|
-
- **Always use `--duration`** with `ipc-monitor
|
|
159
|
+
- **Always use `--duration`** with `ipc-monitor`, `console-monitor`, `rust-logs`, and `mutations` — without it, they run indefinitely.
|
|
103
160
|
- **`screenshot --selector`** requires both the bridge AND platform screenshot tools (`imagemagick`).
|
|
104
161
|
- **One bridge at a time.** Auto-discovery picks the first token file found. If multiple Tauri apps run simultaneously, use `--port` and `--token` explicitly.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tauri-bridge-setup
|
|
3
3
|
description: How to add the tauri-agent-tools Rust dev bridge to a Tauri application
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
tags: [tauri, rust, bridge, setup, integration]
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -22,6 +22,8 @@ serde_json = "1"
|
|
|
22
22
|
scopeguard = "1"
|
|
23
23
|
rand = "0.8"
|
|
24
24
|
uuid = { version = "1", features = ["v4"] }
|
|
25
|
+
tracing = "0.1"
|
|
26
|
+
tracing-subscriber = { version = "0.3", features = ["registry"] }
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
## Step 2 — Copy the bridge module
|
|
@@ -61,7 +63,7 @@ fn main() {
|
|
|
61
63
|
builder
|
|
62
64
|
.setup(|app| {
|
|
63
65
|
if cfg!(debug_assertions) {
|
|
64
|
-
if let Err(e) = dev_bridge::start_bridge(app.handle()) {
|
|
66
|
+
if let Err(e) = dev_bridge::start_bridge(app.handle()).map(|_| ()) {
|
|
65
67
|
eprintln!("Warning: Failed to start dev bridge: {e}");
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -98,6 +100,26 @@ tauri-agent-tools dom --depth 2
|
|
|
98
100
|
|
|
99
101
|
Both commands succeeding confirms the bridge is working.
|
|
100
102
|
|
|
103
|
+
## Optional: Sidecar Log Capture
|
|
104
|
+
|
|
105
|
+
To capture stdout/stderr from sidecar processes (external binaries), use `spawn_sidecar_monitored()`:
|
|
106
|
+
|
|
107
|
+
```rust
|
|
108
|
+
if cfg!(debug_assertions) {
|
|
109
|
+
let (_port, log_buffer) = dev_bridge::start_bridge(app.handle())?;
|
|
110
|
+
|
|
111
|
+
// Spawn a sidecar with monitored output
|
|
112
|
+
dev_bridge::spawn_sidecar_monitored(
|
|
113
|
+
"ffmpeg", // name (appears as source: "sidecar:ffmpeg")
|
|
114
|
+
"ffmpeg", // command
|
|
115
|
+
&["-i", "input.mp4", "-f", "null", "-"], // args
|
|
116
|
+
&log_buffer,
|
|
117
|
+
)?;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Then monitor with: `tauri-agent-tools rust-logs --source sidecar --duration 10000`
|
|
122
|
+
|
|
101
123
|
## Troubleshooting
|
|
102
124
|
|
|
103
125
|
**"No bridge found" error:**
|
package/AGENTS.md
CHANGED
|
@@ -8,7 +8,7 @@ This package includes two [Agent Skills](https://agentskills.io):
|
|
|
8
8
|
|
|
9
9
|
| Skill | Path | Purpose |
|
|
10
10
|
|-------|------|---------|
|
|
11
|
-
| `tauri-agent-tools` | `.agents/skills/tauri-agent-tools/SKILL.md` | Using the
|
|
11
|
+
| `tauri-agent-tools` | `.agents/skills/tauri-agent-tools/SKILL.md` | Using the 14 CLI commands to inspect Tauri apps |
|
|
12
12
|
| `tauri-bridge-setup` | `.agents/skills/tauri-bridge-setup/SKILL.md` | Adding the Rust dev bridge to a Tauri project |
|
|
13
13
|
|
|
14
14
|
## Quick Reference
|
|
@@ -21,10 +21,15 @@ This package includes two [Agent Skills](https://agentskills.io):
|
|
|
21
21
|
`list-windows`, `info`, `screenshot --title`, `wait --title`
|
|
22
22
|
|
|
23
23
|
**Bridge-required commands** (Tauri app must have dev bridge running):
|
|
24
|
-
`dom`, `eval`, `screenshot --selector`, `wait --selector/--eval`, `ipc-monitor`, `console-monitor`, `storage`, `page-state`
|
|
24
|
+
`dom`, `eval`, `screenshot --selector`, `wait --selector/--eval`, `ipc-monitor`, `console-monitor`, `rust-logs`, `storage`, `page-state`, `mutations`, `snapshot`
|
|
25
|
+
|
|
26
|
+
**Local-only commands** (no bridge needed):
|
|
27
|
+
`diff`
|
|
25
28
|
|
|
26
29
|
**Bridge auto-discovery:** The CLI finds the running bridge via token files in `/tmp/tauri-dev-bridge-*.token`. No manual configuration needed.
|
|
27
30
|
|
|
28
31
|
**Structured output:** Use `--json` on any command for machine-readable output.
|
|
29
32
|
|
|
30
|
-
**Monitors:** Always pass `--duration <ms>` to `ipc-monitor
|
|
33
|
+
**Monitors:** Always pass `--duration <ms>` to `ipc-monitor`, `console-monitor`, `rust-logs`, and `mutations` to avoid indefinite execution.
|
|
34
|
+
|
|
35
|
+
**Sidecar monitoring:** `rust-logs` can capture stdout/stderr from sidecar processes (external binaries spawned by the Tauri app). Use `--source sidecar` for all sidecars or `--source sidecar:<name>` for a specific one.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Agent-driven inspection toolkit for Tauri desktop apps**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
14 read-only commands to screenshot, inspect, and monitor Tauri apps from the CLI.
|
|
8
8
|
|
|
9
9
|
[](https://github.com/cesarandreslopez/tauri-agent-tools/actions/workflows/ci.yml)
|
|
10
10
|
[](https://www.npmjs.com/package/tauri-agent-tools)
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
[](https://nodejs.org)
|
|
14
14
|
|
|
15
|
+

|
|
16
|
+
|
|
15
17
|
</div>
|
|
16
18
|
|
|
17
19
|
## The Problem
|
|
@@ -50,7 +52,7 @@ npm install -g tauri-agent-tools
|
|
|
50
52
|
|
|
51
53
|
### 1. Add the bridge to your Tauri app
|
|
52
54
|
|
|
53
|
-
See [rust-bridge/README.md](rust-bridge/README.md) for step-by-step integration
|
|
55
|
+
See [rust-bridge/README.md](rust-bridge/README.md) for step-by-step integration.
|
|
54
56
|
|
|
55
57
|
The bridge runs a localhost-only, token-authenticated HTTP server during development. It auto-cleans up on exit.
|
|
56
58
|
|
|
@@ -107,6 +109,7 @@ Query DOM structure from the Tauri app.
|
|
|
107
109
|
| `--depth <number>` | Max child depth (default: 3) |
|
|
108
110
|
| `--tree` | Compact tree view (default) |
|
|
109
111
|
| `--styles` | Include computed styles |
|
|
112
|
+
| `--text <pattern>` | Find elements containing this text (case-insensitive) |
|
|
110
113
|
| `--count` | Just output match count |
|
|
111
114
|
| `--first` | Only return first match |
|
|
112
115
|
| `--json` | Full structured JSON output |
|
|
@@ -189,6 +192,57 @@ Query webview page state: URL, title, viewport, scroll position, document size,
|
|
|
189
192
|
|--------|-------------|
|
|
190
193
|
| `--json` | Output as JSON |
|
|
191
194
|
|
|
195
|
+
### `diff`
|
|
196
|
+
|
|
197
|
+
Compare two screenshots and output difference metrics.
|
|
198
|
+
|
|
199
|
+
| Option | Description |
|
|
200
|
+
|--------|-------------|
|
|
201
|
+
| `<image1>` | First image path |
|
|
202
|
+
| `<image2>` | Second image path |
|
|
203
|
+
| `-o, --output <path>` | Diff image output path |
|
|
204
|
+
| `--threshold <percent>` | Fail (exit code 1) if difference exceeds this percentage |
|
|
205
|
+
| `--json` | Output structured JSON |
|
|
206
|
+
|
|
207
|
+
### `mutations`
|
|
208
|
+
|
|
209
|
+
Watch DOM mutations on a CSS selector (read-only). Patches a `MutationObserver` into the webview, polls for changes, and cleans up on exit.
|
|
210
|
+
|
|
211
|
+
| Option | Description |
|
|
212
|
+
|--------|-------------|
|
|
213
|
+
| `<selector>` | CSS selector of the element to observe |
|
|
214
|
+
| `--attributes` | Also watch attribute changes |
|
|
215
|
+
| `--interval <ms>` | Poll interval in milliseconds (default: 500) |
|
|
216
|
+
| `--duration <ms>` | Auto-stop after N milliseconds |
|
|
217
|
+
| `--json` | Output one JSON object per line |
|
|
218
|
+
|
|
219
|
+
### `snapshot`
|
|
220
|
+
|
|
221
|
+
Capture screenshot + DOM tree + page state + storage in one shot. Writes multiple files with a shared prefix.
|
|
222
|
+
|
|
223
|
+
| Option | Description |
|
|
224
|
+
|--------|-------------|
|
|
225
|
+
| `-o, --output <prefix>` | Output path prefix (e.g. `/tmp/debug`) |
|
|
226
|
+
| `-s, --selector <css>` | CSS selector to screenshot (full window if omitted) |
|
|
227
|
+
| `-t, --title <regex>` | Window title to match (default: auto-discover) |
|
|
228
|
+
| `--dom-depth <number>` | DOM tree depth (default: 3) |
|
|
229
|
+
| `--eval <js>` | Additional JS to eval and save |
|
|
230
|
+
| `--json` | Output structured manifest |
|
|
231
|
+
|
|
232
|
+
### `rust-logs`
|
|
233
|
+
|
|
234
|
+
Monitor Rust backend logs and sidecar output in real-time. Unlike `console-monitor` (which captures JavaScript console output), this captures Rust `tracing`/`log` output and sidecar process stdout/stderr via the bridge's `/logs` endpoint.
|
|
235
|
+
|
|
236
|
+
| Option | Description |
|
|
237
|
+
|--------|-------------|
|
|
238
|
+
| `--level <level>` | Minimum log level: `trace`, `debug`, `info`, `warn`, `error` |
|
|
239
|
+
| `--target <regex>` | Filter by Rust module path (e.g. `myapp::db`) |
|
|
240
|
+
| `--source <source>` | Filter by source: `rust`, `sidecar`, `all`, or `sidecar:<name>` (default: all) |
|
|
241
|
+
| `--filter <regex>` | Filter messages by regex pattern |
|
|
242
|
+
| `--interval <ms>` | Poll interval in milliseconds (default: 500) |
|
|
243
|
+
| `--duration <ms>` | Auto-stop after N milliseconds |
|
|
244
|
+
| `--json` | Output one JSON object per line |
|
|
245
|
+
|
|
192
246
|
## How It Works
|
|
193
247
|
|
|
194
248
|
```
|
|
@@ -253,7 +307,7 @@ This package ships [Agent Skills](https://agentskills.io) so AI coding agents ca
|
|
|
253
307
|
|
|
254
308
|
| Skill | Description |
|
|
255
309
|
|-------|-------------|
|
|
256
|
-
| `tauri-agent-tools` | Using all
|
|
310
|
+
| `tauri-agent-tools` | Using all 14 CLI commands to inspect Tauri apps |
|
|
257
311
|
| `tauri-bridge-setup` | Adding the Rust dev bridge to a Tauri project |
|
|
258
312
|
|
|
259
313
|
<details>
|
|
@@ -307,7 +361,7 @@ Full documentation is available at the [docs site](https://cesarandreslopez.gith
|
|
|
307
361
|
- [Installation](https://cesarandreslopez.github.io/tauri-agent-tools/getting-started/installation/) — system requirements and setup
|
|
308
362
|
- [Quick Start](https://cesarandreslopez.github.io/tauri-agent-tools/getting-started/quick-start/) — get running in 5 minutes
|
|
309
363
|
- [Bridge Setup](https://cesarandreslopez.github.io/tauri-agent-tools/getting-started/bridge-setup/) — integrate the Rust bridge into your Tauri app
|
|
310
|
-
- [Command Reference](https://cesarandreslopez.github.io/tauri-agent-tools/commands/) — all
|
|
364
|
+
- [Command Reference](https://cesarandreslopez.github.io/tauri-agent-tools/commands/) — all 14 commands with examples
|
|
311
365
|
- [Platform Support](https://cesarandreslopez.github.io/tauri-agent-tools/platform-support/) — X11, Wayland, macOS details
|
|
312
366
|
- [Architecture](https://cesarandreslopez.github.io/tauri-agent-tools/architecture/overview/) — how it works under the hood
|
|
313
367
|
|
package/dist/bridge/client.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { BridgeConfig
|
|
1
|
+
import type { BridgeConfig } from '../schemas/bridge.js';
|
|
2
|
+
import type { ElementRect, RustLogEntry } from '../schemas/bridge.js';
|
|
3
|
+
import type { A11yNode } from '../schemas/dom.js';
|
|
2
4
|
export declare class BridgeClient {
|
|
3
5
|
private baseUrl;
|
|
4
6
|
private token;
|
|
@@ -10,6 +12,7 @@ export declare class BridgeClient {
|
|
|
10
12
|
height: number;
|
|
11
13
|
}>;
|
|
12
14
|
getDocumentTitle(): Promise<string>;
|
|
13
|
-
getAccessibilityTree(selector?: string, depth?: number): Promise<
|
|
15
|
+
getAccessibilityTree(selector?: string, depth?: number): Promise<A11yNode | null>;
|
|
16
|
+
fetchLogs(timeout?: number): Promise<RustLogEntry[]>;
|
|
14
17
|
ping(): Promise<boolean>;
|
|
15
18
|
}
|
package/dist/bridge/client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ElementRectSchema, ViewportSizeSchema, BridgeEvalResponseSchema, BridgeLogsResponseSchema, } from '../schemas/bridge.js';
|
|
2
|
+
import { A11yNodeSchema } from '../schemas/dom.js';
|
|
1
3
|
export class BridgeClient {
|
|
2
4
|
baseUrl;
|
|
3
5
|
token;
|
|
@@ -19,7 +21,7 @@ export class BridgeClient {
|
|
|
19
21
|
}
|
|
20
22
|
throw new Error(`Bridge error (${res.status}): ${text}`);
|
|
21
23
|
}
|
|
22
|
-
const data = await res.json();
|
|
24
|
+
const data = BridgeEvalResponseSchema.parse(await res.json());
|
|
23
25
|
return data.result;
|
|
24
26
|
}
|
|
25
27
|
async getElementRect(selector) {
|
|
@@ -33,12 +35,12 @@ export class BridgeClient {
|
|
|
33
35
|
const result = await this.eval(js);
|
|
34
36
|
if (result === null || result === undefined)
|
|
35
37
|
return null;
|
|
36
|
-
return JSON.parse(String(result));
|
|
38
|
+
return ElementRectSchema.parse(JSON.parse(String(result)));
|
|
37
39
|
}
|
|
38
40
|
async getViewportSize() {
|
|
39
41
|
const js = `JSON.stringify({ width: window.innerWidth, height: window.innerHeight })`;
|
|
40
42
|
const result = await this.eval(js);
|
|
41
|
-
return JSON.parse(String(result));
|
|
43
|
+
return ViewportSizeSchema.parse(JSON.parse(String(result)));
|
|
42
44
|
}
|
|
43
45
|
async getDocumentTitle() {
|
|
44
46
|
const result = await this.eval('document.title');
|
|
@@ -104,7 +106,27 @@ export class BridgeClient {
|
|
|
104
106
|
const result = await this.eval(js);
|
|
105
107
|
if (result === null || result === undefined)
|
|
106
108
|
return null;
|
|
107
|
-
return JSON.parse(String(result));
|
|
109
|
+
return A11yNodeSchema.parse(JSON.parse(String(result)));
|
|
110
|
+
}
|
|
111
|
+
async fetchLogs(timeout = 5000) {
|
|
112
|
+
const res = await fetch(`${this.baseUrl}/logs`, {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
headers: { 'Content-Type': 'application/json' },
|
|
115
|
+
body: JSON.stringify({ token: this.token }),
|
|
116
|
+
signal: AbortSignal.timeout(timeout),
|
|
117
|
+
});
|
|
118
|
+
if (!res.ok) {
|
|
119
|
+
if (res.status === 404) {
|
|
120
|
+
throw new Error('Bridge does not support /logs — update your dev_bridge.rs to the latest version');
|
|
121
|
+
}
|
|
122
|
+
if (res.status === 401 || res.status === 403) {
|
|
123
|
+
throw new Error('Bridge authentication failed — check your token');
|
|
124
|
+
}
|
|
125
|
+
const text = await res.text().catch(() => '');
|
|
126
|
+
throw new Error(`Bridge error (${res.status}): ${text}`);
|
|
127
|
+
}
|
|
128
|
+
const data = BridgeLogsResponseSchema.parse(await res.json());
|
|
129
|
+
return data.entries;
|
|
108
130
|
}
|
|
109
131
|
async ping() {
|
|
110
132
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/bridge/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/bridge/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,OAAO,YAAY;IACf,OAAO,CAAS;IAChB,KAAK,CAAS;IAEtB,YAAY,MAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,oBAAoB,MAAM,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU,EAAE,OAAO,GAAG,IAAI;QACnC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,OAAO,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YAC/C,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;SACrC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,MA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iFAAiF,CAClF,CAAC;YACJ,CAAC;YACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC7C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,iBAAiB,GAAG,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdir, readFile, unlink } from 'node:fs/promises';
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
|
+
import { TokenFileSchema } from '../schemas/bridge.js';
|
|
3
4
|
const TOKEN_DIR = tmpdir();
|
|
4
5
|
const TOKEN_PREFIX = 'tauri-dev-bridge-';
|
|
5
6
|
const TOKEN_SUFFIX = '.token';
|
|
@@ -26,9 +27,7 @@ export async function discoverBridge() {
|
|
|
26
27
|
const filePath = `${TOKEN_DIR}/${file}`;
|
|
27
28
|
try {
|
|
28
29
|
const content = await readFile(filePath, 'utf-8');
|
|
29
|
-
const data = JSON.parse(content);
|
|
30
|
-
if (!data.port || !data.token || !data.pid)
|
|
31
|
-
continue;
|
|
30
|
+
const data = TokenFileSchema.parse(JSON.parse(content));
|
|
32
31
|
if (!isPidAlive(data.pid)) {
|
|
33
32
|
// Clean stale token files from dead processes
|
|
34
33
|
await unlink(filePath).catch(() => { });
|
|
@@ -59,9 +58,7 @@ export async function discoverBridgesByPid() {
|
|
|
59
58
|
const filePath = `${TOKEN_DIR}/${file}`;
|
|
60
59
|
try {
|
|
61
60
|
const content = await readFile(filePath, 'utf-8');
|
|
62
|
-
const data = JSON.parse(content);
|
|
63
|
-
if (!data.port || !data.token || !data.pid)
|
|
64
|
-
continue;
|
|
61
|
+
const data = TokenFileSchema.parse(JSON.parse(content));
|
|
65
62
|
if (!isPidAlive(data.pid)) {
|
|
66
63
|
await unlink(filePath).catch(() => { });
|
|
67
64
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenDiscovery.js","sourceRoot":"","sources":["../../src/bridge/tokenDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"tokenDiscovery.js","sourceRoot":"","sources":["../../src/bridge/tokenDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAC3B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,C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 'path';
|
|
5
5
|
import { Command } from 'commander';
|
|
6
6
|
import { detectDisplayServer, ensureTools } from './platform/detect.js';
|
|
7
|
+
import { PackageJsonSchema } from './schemas/commands.js';
|
|
7
8
|
import { X11Adapter } from './platform/x11.js';
|
|
8
9
|
import { WaylandAdapter } from './platform/wayland.js';
|
|
9
10
|
import { MacOSAdapter } from './platform/macos.js';
|
|
@@ -17,8 +18,12 @@ import { registerIpcMonitor } from './commands/ipcMonitor.js';
|
|
|
17
18
|
import { registerPageState } from './commands/pageState.js';
|
|
18
19
|
import { registerStorage } from './commands/storage.js';
|
|
19
20
|
import { registerConsoleMonitor } from './commands/consoleMonitor.js';
|
|
21
|
+
import { registerMutations } from './commands/mutations.js';
|
|
22
|
+
import { registerSnapshot } from './commands/snapshot.js';
|
|
23
|
+
import { registerDiff } from './commands/diff.js';
|
|
24
|
+
import { registerRustLogs } from './commands/rustLogs.js';
|
|
20
25
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
21
|
-
const pkg = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf-8'));
|
|
26
|
+
const pkg = PackageJsonSchema.parse(JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf-8')));
|
|
22
27
|
const program = new Command()
|
|
23
28
|
.name('tauri-agent-tools')
|
|
24
29
|
.description('Agent-driven inspection toolkit for Tauri desktop apps')
|
|
@@ -47,6 +52,10 @@ registerIpcMonitor(program);
|
|
|
47
52
|
registerPageState(program);
|
|
48
53
|
registerStorage(program);
|
|
49
54
|
registerConsoleMonitor(program);
|
|
55
|
+
registerMutations(program);
|
|
56
|
+
registerSnapshot(program, getAdapter);
|
|
57
|
+
registerDiff(program);
|
|
58
|
+
registerRustLogs(program);
|
|
50
59
|
program.parseAsync().catch((err) => {
|
|
51
60
|
console.error(err instanceof Error ? err.message : String(err));
|
|
52
61
|
process.exitCode = 1;
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO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AAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACtC,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAE1B,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC1C,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { addBridgeOptions, resolveBridge, parseEnum } from './shared.js';
|
|
4
|
+
import { ConsoleEntrySchema, ConsoleLevelSchema } from '../schemas/commands.js';
|
|
3
5
|
const PATCH_SCRIPT = `(() => {
|
|
4
6
|
if (window.__tauriDevToolsConsolePatched) return 'already_patched';
|
|
5
7
|
window.__tauriDevToolsOriginalConsole = {
|
|
@@ -48,11 +50,13 @@ function matchesLevel(entry, level) {
|
|
|
48
50
|
return true;
|
|
49
51
|
return entry.level === level;
|
|
50
52
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
function compileRegex(pattern, label) {
|
|
54
|
+
try {
|
|
55
|
+
return new RegExp(pattern);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error(`Invalid ${label} regex: ${pattern}`);
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
function formatConsoleEntry(entry) {
|
|
58
62
|
const time = new Date(entry.timestamp).toISOString().slice(11, 23);
|
|
@@ -76,9 +80,10 @@ export function registerConsoleMonitor(program) {
|
|
|
76
80
|
.option('--json', 'Output one JSON object per line');
|
|
77
81
|
addBridgeOptions(cmd);
|
|
78
82
|
cmd.action(async (opts) => {
|
|
79
|
-
if (opts.level
|
|
80
|
-
|
|
83
|
+
if (opts.level) {
|
|
84
|
+
parseEnum(ConsoleLevelSchema, opts.level, 'level');
|
|
81
85
|
}
|
|
86
|
+
const filterRegex = opts.filter ? compileRegex(opts.filter, 'filter') : undefined;
|
|
82
87
|
const bridge = await resolveBridge(opts);
|
|
83
88
|
const patchResult = await bridge.eval(PATCH_SCRIPT);
|
|
84
89
|
if (patchResult === 'already_patched') {
|
|
@@ -105,11 +110,11 @@ export function registerConsoleMonitor(program) {
|
|
|
105
110
|
if (stopped)
|
|
106
111
|
break;
|
|
107
112
|
const raw = await bridge.eval(DRAIN_SCRIPT);
|
|
108
|
-
const entries = JSON.parse(String(raw));
|
|
113
|
+
const entries = z.array(ConsoleEntrySchema).parse(JSON.parse(String(raw)));
|
|
109
114
|
for (const entry of entries) {
|
|
110
115
|
if (!matchesLevel(entry, opts.level))
|
|
111
116
|
continue;
|
|
112
|
-
if (!
|
|
117
|
+
if (filterRegex && !filterRegex.test(entry.message))
|
|
113
118
|
continue;
|
|
114
119
|
if (opts.json) {
|
|
115
120
|
console.log(JSON.stringify(entry));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleMonitor.js","sourceRoot":"","sources":["../../src/commands/consoleMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"consoleMonitor.js","sourceRoot":"","sources":["../../src/commands/consoleMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE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