tauri-agent-tools 0.9.1 → 0.9.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.
- package/.agents/skills/tauri-agent-tools/SKILL.md +32 -13
- package/.agents/skills/tauri-bridge-setup/SKILL.md +4 -3
- package/.agents/skills/tauri-debug-quickstart/SKILL.md +3 -1
- package/AGENTS.md +7 -3
- package/README.md +35 -14
- package/dist/bridge/client.d.ts +1 -0
- package/dist/bridge/client.js +2 -0
- package/dist/bridge/client.js.map +1 -1
- package/dist/bridge/evaluate.d.ts +11 -0
- package/dist/bridge/evaluate.js +33 -0
- package/dist/bridge/evaluate.js.map +1 -0
- package/dist/bridge/logReader.d.ts +27 -0
- package/dist/bridge/logReader.js +26 -0
- package/dist/bridge/logReader.js.map +1 -0
- package/dist/bridge/observers.d.ts +11 -0
- package/dist/bridge/observers.js +195 -0
- package/dist/bridge/observers.js.map +1 -0
- package/dist/cli.js +28 -8
- package/dist/cli.js.map +1 -1
- package/dist/commands/bundle.js +122 -101
- package/dist/commands/bundle.js.map +1 -1
- package/dist/commands/capture.d.ts +3 -3
- package/dist/commands/capture.js +167 -141
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/check.js +44 -59
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/consoleMonitor.js +18 -85
- package/dist/commands/consoleMonitor.js.map +1 -1
- package/dist/commands/diagnose.js +4 -32
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/diff.js +28 -38
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/dom.js +2 -2
- package/dist/commands/dom.js.map +1 -1
- package/dist/commands/eval.js +11 -1
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/forensics.js +1 -7
- package/dist/commands/forensics.js.map +1 -1
- package/dist/commands/info.d.ts +2 -2
- package/dist/commands/info.js +3 -1
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/interact/click.js +14 -44
- package/dist/commands/interact/click.js.map +1 -1
- package/dist/commands/interact/scroll.js +6 -0
- package/dist/commands/interact/scroll.js.map +1 -1
- package/dist/commands/interact/select.d.ts +6 -1
- package/dist/commands/interact/select.js +87 -29
- package/dist/commands/interact/select.js.map +1 -1
- package/dist/commands/interact/shared.d.ts +96 -0
- package/dist/commands/interact/shared.js +266 -1
- package/dist/commands/interact/shared.js.map +1 -1
- package/dist/commands/interact/type.d.ts +10 -2
- package/dist/commands/interact/type.js +44 -29
- package/dist/commands/interact/type.js.map +1 -1
- package/dist/commands/ipcMonitor.d.ts +3 -3
- package/dist/commands/ipcMonitor.js +26 -96
- package/dist/commands/ipcMonitor.js.map +1 -1
- package/dist/commands/listWindows.d.ts +2 -2
- package/dist/commands/listWindows.js.map +1 -1
- package/dist/commands/logs.d.ts +4 -27
- package/dist/commands/logs.js +12 -41
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/mutations.js +20 -101
- package/dist/commands/mutations.js.map +1 -1
- package/dist/commands/osLogs.js +2 -5
- package/dist/commands/osLogs.js.map +1 -1
- package/dist/commands/probe.js +18 -16
- package/dist/commands/probe.js.map +1 -1
- package/dist/commands/rustLogs.js +23 -43
- package/dist/commands/rustLogs.js.map +1 -1
- package/dist/commands/screenshot.d.ts +2 -2
- package/dist/commands/screenshot.js +7 -4
- package/dist/commands/screenshot.js.map +1 -1
- package/dist/commands/shared.d.ts +4 -1
- package/dist/commands/shared.js +34 -4
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/sidecarReplay.js +4 -0
- package/dist/commands/sidecarReplay.js.map +1 -1
- package/dist/commands/snapshot.d.ts +2 -2
- package/dist/commands/snapshot.js +4 -4
- package/dist/commands/snapshot.js.map +1 -1
- package/dist/commands/storeInspect.js +2 -2
- package/dist/commands/storeInspect.js.map +1 -1
- package/dist/commands/wait.d.ts +2 -2
- package/dist/commands/wait.js +42 -57
- package/dist/commands/wait.js.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/platform/detect.d.ts +2 -2
- package/dist/platform/detect.js +11 -2
- package/dist/platform/detect.js.map +1 -1
- package/dist/platform/x11.d.ts +1 -0
- package/dist/platform/x11.js +16 -5
- package/dist/platform/x11.js.map +1 -1
- package/dist/schemas/commands.d.ts +6 -0
- package/dist/schemas/commands.js +2 -0
- package/dist/schemas/commands.js.map +1 -1
- package/dist/schemas/interact.d.ts +58 -0
- package/dist/schemas/interact.js +25 -0
- package/dist/schemas/interact.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/util/exec.d.ts +6 -0
- package/dist/util/exec.js +13 -1
- package/dist/util/exec.js.map +1 -1
- package/dist/util/incidentFiles.d.ts +5 -0
- package/dist/util/incidentFiles.js +61 -0
- package/dist/util/incidentFiles.js.map +1 -0
- package/dist/util/monitor.d.ts +11 -0
- package/dist/util/monitor.js +42 -0
- package/dist/util/monitor.js.map +1 -0
- package/dist/util/poll.d.ts +2 -0
- package/dist/util/poll.js +28 -0
- package/dist/util/poll.js.map +1 -0
- package/dist/util/redactText.d.ts +5 -2
- package/dist/util/redactText.js +44 -11
- package/dist/util/redactText.js.map +1 -1
- package/dist/util/tauriConfig.js +15 -18
- package/dist/util/tauriConfig.js.map +1 -1
- package/examples/tauri-bridge/Cargo.lock +4742 -0
- package/package.json +10 -3
- package/rust-bridge/README.md +7 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tauri-agent-tools
|
|
3
3
|
description: CLI for inspecting and interacting with Tauri desktop apps — DOM queries, screenshots, interaction (click/type/scroll), IPC monitoring, store inspection, structured assertions, plus bridge-free diagnostics (unified cross-layer logs, deep OS process trees, OS logs, app paths, sidecar NDJSON tap/replay, forensic bundles) and the `diagnose`/`bundle` super-commands for one-shot triage. Works against older/vendored bridges by degrading gracefully.
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
tags: [tauri, desktop, debugging, screenshot, dom, inspection, diff, mutations, snapshot, interaction, click, type, scroll, invoke, probe, capture, check, store-inspect, logs, bundle, process-tree, forensics, os-logs, app-paths, sidecar, config-inspect, diagnose]
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# tauri-agent-tools
|
|
9
9
|
|
|
10
|
-
CLI tool for agent-driven inspection and interaction with Tauri desktop applications.
|
|
10
|
+
CLI tool for agent-driven inspection and interaction with Tauri desktop applications. DOM, screenshot, and storage inspection read app state; `eval` can modify it. Monitors install temporary instrumentation. Interaction commands (click, type, scroll, etc.) are debug-only — they only work when the app runs with the dev bridge enabled.
|
|
11
11
|
|
|
12
12
|
## Prerequisites
|
|
13
13
|
|
|
@@ -30,6 +30,20 @@ npm install -g tauri-agent-tools
|
|
|
30
30
|
|
|
31
31
|
## Bridge vs Standalone
|
|
32
32
|
|
|
33
|
+
Dependency checks follow the operation: window listing/info/title waits do not require ImageMagick; full-window PNG capture on macOS/Wayland uses native tools; crop/resize/diff and X11 capture require ImageMagick.
|
|
34
|
+
|
|
35
|
+
`--title` uses a regex on X11 and a substring on macOS/Sway/Hyprland. `probe --json` reports the selected PID, port, and window label; use `--pid` when multiple apps are running.
|
|
36
|
+
|
|
37
|
+
`eval --json` returns `{ "result": value }`. It awaits promises and reports thrown expressions as errors. Commands accepting `--json` send fatal `{ "error": { "code": "…", "message": "…", "hint": "…" } }` responses to stderr and exit nonzero; result records remain on stdout.
|
|
38
|
+
|
|
39
|
+
Choose exactly one condition for `wait`. Numeric intervals/timeouts must be positive integers; `click --wait` and `capture --logs-duration` also allow zero. `check` requires an assertion; `--no-errors` fails if observation is incomplete, including interruption by SIGINT/SIGTERM. Interrupted captures save available evidence with `partial: true` and warnings.
|
|
40
|
+
|
|
41
|
+
Console/IPC/mutation collectors have independent bounded buffers, report drops, and collect a final batch on stop. They restore their own instrumentation on completion, error, SIGINT, and SIGTERM while the webview is reachable. `logs`, `rust-logs`, and `capture` use independent v0.8 cursors; older bridges warn and fall back to destructive drain reads.
|
|
42
|
+
|
|
43
|
+
`bundle` stages privately and publishes only after text redaction and residual-secret checks pass. Redaction failures prevent the new archive and directory from being published. Its archive excludes unrelated existing files and rejects artifact symlinks. Missing sources produce `partial: true`; captures also save `warnings`. Images remain unredacted: review them before sharing.
|
|
44
|
+
|
|
45
|
+
Quote the complete replay command, e.g. `--to-exec "node my-sidecar.js"`; it is split on spaces, without shell syntax or support for arguments containing spaces.
|
|
46
|
+
|
|
33
47
|
Some commands require the Rust dev bridge running inside the Tauri app. Others work standalone.
|
|
34
48
|
|
|
35
49
|
**Bridge required** (needs running Tauri app with bridge):
|
|
@@ -42,7 +56,7 @@ Some commands require the Rust dev bridge running inside the Tauri app. Others w
|
|
|
42
56
|
`screenshot --title`/`--window-id` (full window only), `wait --title`, `list-windows`, `info`, `diff`, `logs`, `app-paths`, `config inspect`, `os-logs`, `sidecar tap`, `sidecar replay`, `forensics`
|
|
43
57
|
|
|
44
58
|
**Optional bridge** (work standalone, richer with a bridge):
|
|
45
|
-
`probe`, `process-tree` (use `--deep` for a bridge-free OS walk), `logs` (merges on-disk files alone, or also
|
|
59
|
+
`probe`, `process-tree` (use `--deep` for a bridge-free OS walk), `logs` (merges on-disk files alone, or also reads the bridge ring buffer with an independent cursor on v0.8+), `bundle`, `diagnose`
|
|
46
60
|
|
|
47
61
|
The bridge auto-discovers via token files in `/tmp/tauri-dev-bridge-*.token`. No manual port/token configuration needed.
|
|
48
62
|
|
|
@@ -223,7 +237,7 @@ tauri-agent-tools os-logs --level error --source main --duration 30000
|
|
|
223
237
|
# Run a sidecar under a tap to see its stdio + validate against a JSON Schema
|
|
224
238
|
tauri-agent-tools sidecar tap --schema ./schema.json --record /tmp/run.ndjson -- node my-sidecar.js
|
|
225
239
|
# Replay deterministically
|
|
226
|
-
tauri-agent-tools sidecar replay /tmp/run.ndjson --to-exec node my-sidecar.js --rate 100
|
|
240
|
+
tauri-agent-tools sidecar replay /tmp/run.ndjson --to-exec "node my-sidecar.js" --rate 100
|
|
227
241
|
|
|
228
242
|
# One-shot forensic bundle for post-crash analysis. Works on a DEAD app.
|
|
229
243
|
tauri-agent-tools forensics --config ./src-tauri -o ./forensics-out
|
|
@@ -269,6 +283,9 @@ tauri-agent-tools type "#search" "hello world" --json
|
|
|
269
283
|
# Clear and retype
|
|
270
284
|
tauri-agent-tools type "#email" "new@email.com" --clear --json
|
|
271
285
|
|
|
286
|
+
# App applies the value on a transition/async render: wait longer for it to stick
|
|
287
|
+
tauri-agent-tools type "#q" "term" --verify-timeout 2000 --json
|
|
288
|
+
|
|
272
289
|
# Scroll to bottom
|
|
273
290
|
tauri-agent-tools scroll --to-bottom --json
|
|
274
291
|
|
|
@@ -292,6 +309,8 @@ tauri-agent-tools invoke get_release_context --json
|
|
|
292
309
|
tauri-agent-tools invoke save_item '{"id": 42}' --json
|
|
293
310
|
```
|
|
294
311
|
|
|
312
|
+
`type` and `select <value>` write through the element's native `value` setter (so React/Vue/Svelte controlled inputs see the change); `select --toggle` performs a native `click()`. Both then re-read the element. `verification: "reverted"` in the failure JSON (exit 1, with a `hint`; `type` prints it with `--json`, `select` always) means the app rolled the write back — a controlled input that rejected it — and is the app's answer, not a tooling error. `verification: "transformed"` means the app reformatted the value and counts as success (`verified: false`).
|
|
313
|
+
|
|
295
314
|
### Probe, capture, and check (workflow commands)
|
|
296
315
|
|
|
297
316
|
```bash
|
|
@@ -332,12 +351,12 @@ tauri-agent-tools eval "document.title" --window-label overlay --json
|
|
|
332
351
|
|
|
333
352
|
| Command | Key Flags | Bridge? | Description |
|
|
334
353
|
|---------|-----------|---------|-------------|
|
|
335
|
-
| `screenshot` | `--selector <css>`, `--title <
|
|
354
|
+
| `screenshot` | `--selector <css>`, `--title <pattern>`, `--window-id <id>`, `-o <path>`, `--max-width <n>` | selector: yes, title/window-id: no | Capture window or DOM element screenshot |
|
|
336
355
|
| `dom` | `[selector]`, `--depth <n>`, `--styles`, `--text <pattern>`, `--mode accessibility`, `--json` | yes | Query DOM structure or find elements by text |
|
|
337
356
|
| `eval` | `<js-expression>`, `--file <path>` | yes | Evaluate JavaScript in webview |
|
|
338
|
-
| `wait` | `--selector <css>`, `--eval <js>`, `--title <
|
|
357
|
+
| `wait` | `--selector <css>`, `--eval <js>`, `--title <pattern>`, `--timeout <ms>` | selector/eval: yes | Wait for a condition |
|
|
339
358
|
| `list-windows` | `--tauri`, `--json` | no | List visible windows |
|
|
340
|
-
| `info` | `--title <
|
|
359
|
+
| `info` | `--title <pattern>`, `--window-id <id>`, `--json` | no | Window geometry and display info |
|
|
341
360
|
| `ipc-monitor` | `--filter <cmd>`, `--duration <ms>`, `--slow <ms>`, `--stats`, `--json` | yes | Monitor Tauri IPC calls; flag slow calls + per-command latency summary |
|
|
342
361
|
| `console-monitor` | `--level <lvl>`, `--filter <regex>`, `--duration <ms>`, `--json` | yes | Monitor console output |
|
|
343
362
|
| `rust-logs` | `--level <lvl>`, `--target <regex>`, `--source <src>`, `--duration <ms>`, `--json` | yes | Monitor Rust logs and sidecar output |
|
|
@@ -347,11 +366,11 @@ tauri-agent-tools eval "document.title" --window-label overlay --json
|
|
|
347
366
|
| `mutations` | `<selector>`, `--attributes`, `--duration <ms>`, `--json` | yes | Watch DOM mutations |
|
|
348
367
|
| `snapshot` | `-o <prefix>`, `-s <css>`, `--window-id <id>`, `--dom-depth <n>`, `--eval <js>`, `--json` | yes | Screenshot + DOM + page state + storage |
|
|
349
368
|
| `click` | `<selector>`, `--double`, `--right`, `--wait <ms>`, `--json` | yes | Click a DOM element |
|
|
350
|
-
| `type` | `<selector> <text>`, `--clear`, `--json` | yes | Type text into an input |
|
|
369
|
+
| `type` | `<selector> <text>`, `--clear`, `--verify-timeout <ms>`, `--json` | yes | Type text into an input (native setter, verified write) |
|
|
351
370
|
| `scroll` | `--selector <css>`, `--by <px>`, `--to-top`, `--to-bottom`, `--into-view`, `--json` | yes | Scroll window or element |
|
|
352
371
|
| `focus` | `<selector>`, `--json` | yes | Focus a DOM element |
|
|
353
372
|
| `navigate` | `<target>`, `--json` | yes | Navigate within the app |
|
|
354
|
-
| `select` | `<selector> [value]`, `--toggle`, `--json` | yes | Select dropdown or toggle checkbox |
|
|
373
|
+
| `select` | `<selector> [value]`, `--toggle`, `--verify-timeout <ms>`, `--json` | yes | Select dropdown or toggle checkbox (native setter; `--toggle` via native `click()`; verified write) |
|
|
355
374
|
| `invoke` | `<command> [args-json]`, `--json` | yes | Invoke a Tauri IPC command |
|
|
356
375
|
| `probe` | `--pid <n>`, `--json` | optional | Discover targets and bridge health |
|
|
357
376
|
| `capture` | `-o <dir>`, `-s <css>`, `--window-id <id>`, `--logs-duration <ms>`, `--json` | yes | Full debug evidence bundle |
|
|
@@ -365,9 +384,9 @@ tauri-agent-tools eval "document.title" --window-label overlay --json
|
|
|
365
384
|
| `forensics` | `--config <path>`, `--identifier <id>`, `-o <dir>`, `--since <dur>`, `--json` | no | One-shot forensic bundle (works on dead apps) |
|
|
366
385
|
| `logs` | `--config <path>`, `--identifier <id>`, `--log-dir <path>`, `--log-file <path>`, `--level <lvl>`, `--source <re>`, `--filter <re>`, `--correlate`, `--follow`, `--interval <ms>`, `--no-bridge`, `--pretty` | optional | Merge on-disk log files + bridge ring buffer into one timestamp-ordered stream; `--follow` tails the bridge via v0.8 cursor reads (drain-polling fallback on older bridges) |
|
|
367
386
|
| `process-tree` | `--deep`, `--pid <n>`, `--json` | optional | Tauri PID + sidecars (bridge /process); `--deep` walks the full OS descendant tree without the bridge |
|
|
368
|
-
| `capabilities audit` | `--json` | yes
|
|
369
|
-
| `webview attach` | `--print-url`, `--open`, `--json` | yes
|
|
370
|
-
| `health` | `--json` | yes
|
|
387
|
+
| `capabilities audit` | `--json` | yes; v0.7+ for full output | Live Devtron-style audit of declared Tauri capabilities |
|
|
388
|
+
| `webview attach` | `--print-url`, `--open`, `--json` | yes; v0.7+ for full output | Print webview inspector URL or platform hint |
|
|
389
|
+
| `health` | `--json` | yes; v0.7+ for full output | Uptime + webview/sidecar liveness (exit non-zero if unhealthy) |
|
|
371
390
|
| `diagnose` | `--config <path>`, `-o <dir>`, `--since <dur>`, `--no-bridge`, `--json` | optional | Best-effort super-bundle (forensics + live bridge enrichment) |
|
|
372
391
|
| `bundle` | `--config <path>`, `-o <dir>`, `--with-capture`, `--no-archive`, `--json` | optional | Shareable incident bundle: logs + deep process tree + app-paths + forensics → redacted dir + .tar.gz |
|
|
373
392
|
|
|
@@ -381,7 +400,7 @@ All bridge-dependent commands support these flags:
|
|
|
381
400
|
|
|
382
401
|
## Important Notes
|
|
383
402
|
|
|
384
|
-
- **
|
|
403
|
+
- **Evaluation can modify app state.** `eval` runs unrestricted JavaScript. Monitors, `capture`, and `check --no-errors` install temporary instrumentation and clean it up when they stop; force-killing the CLI cannot run cleanup.
|
|
385
404
|
- **Interaction commands are debug-only.** They only work with the dev bridge (debug builds).
|
|
386
405
|
- **Use `--json`** for structured, parseable output in automation.
|
|
387
406
|
- **Always use `--duration`** with `ipc-monitor`, `console-monitor`, `rust-logs`, and `mutations`.
|
|
@@ -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.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
tags: [tauri, rust, bridge, setup, integration, multi-window, process-tree, capabilities, devtools, health]
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ The bridge runs **only in debug builds** and is stripped from release builds aut
|
|
|
13
13
|
|
|
14
14
|
## Re-copying for v0.8 (optional enrichment — not required)
|
|
15
15
|
|
|
16
|
-
> **Upgrading from v0.7:** Bridge v0.8 adds cursor-mode `/logs` reads (non-draining, long-polling) that power `logs --follow` and let multiple log consumers coexist. It is a **drop-in re-copy** of `dev_bridge.rs` — no `main.rs` changes this time. Without it, `logs --follow` emits a one-time note and degrades to drain polling.
|
|
16
|
+
> **Upgrading from v0.7:** Bridge v0.8 adds cursor-mode `/logs` reads (non-draining, long-polling) that power `logs`, `rust-logs`, and `capture` (including `logs --follow`) and let multiple log consumers coexist. It is a **drop-in re-copy** of `dev_bridge.rs` — no `main.rs` changes this time. Without it, `logs --follow` emits a one-time note and degrades to drain polling.
|
|
17
17
|
|
|
18
18
|
## Re-copying for v0.7 (optional enrichment — not required)
|
|
19
19
|
|
|
@@ -149,7 +149,8 @@ Use `probe` to discover available windows:
|
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
151
|
tauri-agent-tools probe --json
|
|
152
|
-
# → { "
|
|
152
|
+
# → { "target": { "pid": 12345, "port": 9876, "windowLabel": "main",
|
|
153
|
+
# "describe": { "windows": ["main", "overlay", "settings"] }, ... }, ... }
|
|
153
154
|
```
|
|
154
155
|
|
|
155
156
|
## Optional: Sidecar Log Capture + Process Visibility
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tauri-debug-quickstart
|
|
3
3
|
description: First-30-seconds triage for a broken Tauri desktop app. Pick the right command for the symptom you're seeing, with one-line escalations to deeper skills.
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
tags: [tauri, debugging, triage, quickstart, decision-tree, logs, process-tree, bundle, forensics, diagnose]
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -82,3 +82,5 @@ This guidance assumes the agent is inspecting a Tauri 2 desktop app on macOS or
|
|
|
82
82
|
- **The dev bridge requires `cfg!(debug_assertions)`** — release builds strip it, so bridge-dependent commands won't work against signed/notarized release artifacts. Use bridge-free commands (`forensics`, `app-paths`, `os-logs`, `config inspect`, `sidecar tap`) for those.
|
|
83
83
|
|
|
84
84
|
For deeper how-tos see the [`tauri-agent-tools`](../tauri-agent-tools/SKILL.md) skill. For bridge integration setup (Rust side), see [`tauri-bridge-setup`](../tauri-bridge-setup/SKILL.md).
|
|
85
|
+
|
|
86
|
+
For bridge-free collection even when a live target exists, pass `diagnose --no-bridge`. `probe --json` identifies the selected PID, port, and window label. Inspect `partial` and warnings in captures/bundles before assuming collection completed; interrupted `check --no-errors` fails. Bundle redaction failures prevent publication, and images require review before sharing.
|
package/AGENTS.md
CHANGED
|
@@ -16,7 +16,7 @@ This package includes three [Agent Skills](https://agentskills.io):
|
|
|
16
16
|
|
|
17
17
|
**Install:** `npm install -g tauri-agent-tools`
|
|
18
18
|
|
|
19
|
-
**
|
|
19
|
+
**DOM, screenshot, and storage inspection read app state.** `eval` can modify app state. Monitors install temporary instrumentation. Interaction commands (click, type, scroll, etc.) are debug-only — they only work with the dev bridge.
|
|
20
20
|
|
|
21
21
|
**Standalone commands** (no bridge needed):
|
|
22
22
|
`list-windows`, `info`, `screenshot --title`, `wait --title`, `diff`
|
|
@@ -27,7 +27,7 @@ This package includes three [Agent Skills](https://agentskills.io):
|
|
|
27
27
|
**Bridge-required commands** (Tauri app must have dev bridge running):
|
|
28
28
|
`dom`, `eval`, `screenshot --selector`, `wait --selector/--eval`, `ipc-monitor`, `console-monitor`, `rust-logs`, `storage`, `page-state`, `mutations`, `snapshot`, `click`, `type`, `scroll`, `focus`, `navigate`, `select`, `invoke`, `capture`, `check`, `store-inspect`
|
|
29
29
|
|
|
30
|
-
**Bridge-extending diagnostics** (
|
|
30
|
+
**Bridge-extending diagnostics** (use bridge v0.7+ for full output; degrade gracefully against older/vendored bridges, or pass `--strict` to fail):
|
|
31
31
|
`process-tree`, `capabilities audit`, `webview attach`, `health`
|
|
32
32
|
|
|
33
33
|
**Super-commands** (best-effort, compose the above):
|
|
@@ -40,8 +40,12 @@ This package includes three [Agent Skills](https://agentskills.io):
|
|
|
40
40
|
|
|
41
41
|
**Bridge auto-discovery:** The CLI finds the running bridge via token files in `/tmp/tauri-dev-bridge-*.token`. No manual configuration needed.
|
|
42
42
|
|
|
43
|
-
**Structured output:** Use `--json`
|
|
43
|
+
**Structured output:** Use `--json` where supported for machine-readable output. Fatal JSON errors go to stderr; command results stay on stdout.
|
|
44
44
|
|
|
45
45
|
**Monitors:** Always pass `--duration <ms>` to `ipc-monitor`, `console-monitor`, `rust-logs`, and `mutations` to avoid indefinite execution.
|
|
46
46
|
|
|
47
47
|
**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.
|
|
48
|
+
|
|
49
|
+
**Automation:** `wait` requires exactly one condition, and `check` requires at least one assertion. An interrupted `check --no-errors` fails. `capture` reports incomplete evidence with `partial` and `warnings`. Console/IPC/mutation collectors keep independent bounded sessions; Rust log readers use independent cursors on bridge v0.8+.
|
|
50
|
+
|
|
51
|
+
**Release checks:** Run `npm run lint`, `npm test`, `cargo test --locked --manifest-path examples/tauri-bridge/Cargo.toml`, `zensical build`, and `npm run check:package`. The example lockfile is tracked; Rust build outputs are excluded from npm.
|
package/README.md
CHANGED
|
@@ -49,6 +49,12 @@ npm install -g tauri-agent-tools
|
|
|
49
49
|
- **Linux Wayland/Hyprland:** `hyprctl` (included with Hyprland), `grim`, `imagemagick`
|
|
50
50
|
- **macOS:** `imagemagick` (`brew install imagemagick`) — all other tools are built-in. Grant Screen Recording permission in System Settings → Privacy & Security → Screen Recording.
|
|
51
51
|
|
|
52
|
+
Dependencies are checked for the requested operation. `list-windows`, `info`, and `wait --title` only need the platform's window inspection tool. Full-window PNG capture on macOS and Wayland does not require ImageMagick; cropping, resizing, image comparison, and X11 capture do. Bridge-only commands need no screenshot tools.
|
|
53
|
+
|
|
54
|
+
`--title` uses a regular expression on X11 and a substring on macOS, Sway, and Hyprland. Quote patterns containing spaces. `--window-id` selects a window directly; `--pid` selects an app bridge, and `--window-label` selects its webview. `probe --json` reports the selected PID, port, and label and notes ambiguous discovery.
|
|
55
|
+
|
|
56
|
+
Commands that accept `--json` keep results on stdout and report fatal errors on stderr as `{"error":{"code":"…","message":"…","hint":"…"}}`, with a nonzero exit status. Monitors emit NDJSON; progress and warnings go to stderr. Failed `check` assertions and `diff` thresholds retain their structured result on stdout and exit 1.
|
|
57
|
+
|
|
52
58
|
## Quick Start
|
|
53
59
|
|
|
54
60
|
### 1. Add the bridge to your Tauri app
|
|
@@ -92,7 +98,7 @@ Capture a screenshot of a window or DOM element.
|
|
|
92
98
|
| Option | Description |
|
|
93
99
|
|--------|-------------|
|
|
94
100
|
| `-s, --selector <css>` | CSS selector — screenshot just this element (requires bridge) |
|
|
95
|
-
| `-t, --title <
|
|
101
|
+
| `-t, --title <pattern>` | Window title (X11: regex; macOS/Wayland: substring); quote titles with spaces |
|
|
96
102
|
| `-w, --window-id <id>` | Platform window id (from `list-windows`) — overrides `--title` |
|
|
97
103
|
| `-o, --output <path>` | Output file path (default: auto-named) |
|
|
98
104
|
| `--format <png\|jpg>` | Output format (default: png) |
|
|
@@ -129,17 +135,20 @@ tauri-agent-tools eval --file script.js
|
|
|
129
135
|
|--------|-------------|
|
|
130
136
|
| `<js-expression>` | Inline JavaScript to evaluate |
|
|
131
137
|
| `--file <path>` | Load JavaScript from a file instead |
|
|
138
|
+
| `--json` | Output `{ "result": value }`; awaits promises and reports evaluation errors |
|
|
132
139
|
| `--window-label <label>` | Target a specific webview window (default: main) |
|
|
133
140
|
|
|
134
141
|
### `wait`
|
|
135
142
|
|
|
136
143
|
Wait for a condition to be met.
|
|
137
144
|
|
|
145
|
+
Choose exactly one of `--selector`, `--eval`, or `--title`. Evaluation uses JavaScript truthiness: `false`, `0`, and `null` keep waiting, while the string `"false"` is truthy. A thrown expression fails immediately. Timeouts and polling intervals must be positive integers.
|
|
146
|
+
|
|
138
147
|
| Option | Description |
|
|
139
148
|
|--------|-------------|
|
|
140
149
|
| `-s, --selector <css>` | Wait for CSS selector to match |
|
|
141
150
|
| `-e, --eval <js>` | Wait for JS expression to be truthy |
|
|
142
|
-
| `-t, --title <
|
|
151
|
+
| `-t, --title <pattern>` | Wait for window with title (no bridge) |
|
|
143
152
|
| `--timeout <ms>` | Maximum wait time (default: 10000) |
|
|
144
153
|
| `--interval <ms>` | Polling interval (default: 500) |
|
|
145
154
|
|
|
@@ -163,7 +172,7 @@ List all visible windows, marking Tauri apps.
|
|
|
163
172
|
|
|
164
173
|
### `ipc-monitor`
|
|
165
174
|
|
|
166
|
-
Monitor Tauri IPC calls in real-time
|
|
175
|
+
Monitor Tauri IPC calls in real-time. Monkey-patches Tauri's invoke API (`window.__TAURI_INTERNALS__.invoke`, falling back to `window.__TAURI__.core.invoke`) to capture calls, then polls and restores on exit.
|
|
167
176
|
|
|
168
177
|
| Option | Description |
|
|
169
178
|
|--------|-------------|
|
|
@@ -176,6 +185,8 @@ Monitor Tauri IPC calls in real-time (read-only). Monkey-patches Tauri's invoke
|
|
|
176
185
|
|
|
177
186
|
Monitor console output (log/warn/error/info/debug) in real-time. Monkey-patches console methods to capture entries, then polls and restores on exit.
|
|
178
187
|
|
|
188
|
+
Always set `--duration <ms>` for automated runs. IPC, console, and mutation collectors have independent sessions with 1,000-entry buffers and report overflow on stderr. They collect a final batch before cleanup, including when duration is shorter than the polling interval. Circular values and BigInts are serialized safely. Cleanup also runs on SIGINT/SIGTERM; force-killing the CLI or losing the webview can prevent restoration.
|
|
189
|
+
|
|
179
190
|
| Option | Description |
|
|
180
191
|
|--------|-------------|
|
|
181
192
|
| `--level <level>` | Filter by level (log, warn, error, info, debug) |
|
|
@@ -234,7 +245,7 @@ Capture screenshot + DOM tree + page state + storage in one shot. Writes multipl
|
|
|
234
245
|
|--------|-------------|
|
|
235
246
|
| `-o, --output <prefix>` | Output path prefix (e.g. `/tmp/debug`) |
|
|
236
247
|
| `-s, --selector <css>` | CSS selector to screenshot (full window if omitted) |
|
|
237
|
-
| `-t, --title <
|
|
248
|
+
| `-t, --title <pattern>` | Window title (X11: regex; macOS/Wayland: substring); quote titles with spaces (default: auto-discover) |
|
|
238
249
|
| `-w, --window-id <id>` | Platform window id (from `list-windows`) — overrides `--title` |
|
|
239
250
|
| `--dom-depth <number>` | DOM tree depth (default: 3) |
|
|
240
251
|
| `--eval <js>` | Additional JS to eval and save |
|
|
@@ -258,14 +269,16 @@ Monitor Rust backend logs and sidecar output in real-time. Unlike `console-monit
|
|
|
258
269
|
|
|
259
270
|
Interaction commands dispatch DOM events inside the webview. They require the dev bridge (debug builds only).
|
|
260
271
|
|
|
272
|
+
`type` and `select` write through the element's native prototype `value` setter — React's per-instance value tracker turns a plain `el.value = …` into a no-op — and dispatch bubbling `input`/`change` events, so React, Vue, and Svelte controlled inputs update their state; `select --toggle` performs a native `click()`. Both then re-read the element: a value the app rolled back fails with `Value reverted` (`Checked state reverted` for `--toggle`; exit 1 with the reason and a `hint` on stderr, and the failure object with `verification: "reverted"` on stdout — with `--json` for `type`, always for `select`) — treat that as the app's answer, not a tooling error — while a value the app reformatted is a success reported with `verification: "transformed"`. `--verify-timeout <ms>` (default 500) tunes the re-read deadline for apps that apply values asynchronously.
|
|
273
|
+
|
|
261
274
|
| Command | Description |
|
|
262
275
|
|---------|-------------|
|
|
263
276
|
| `click <selector>` | Click a DOM element (`--double`, `--right`, `--wait <ms>`) |
|
|
264
|
-
| `type <selector> <text>` | Type text into an input (`--clear` to empty first) |
|
|
277
|
+
| `type <selector> <text>` | Type text into an input via the native value setter, then verify the write (`--clear` to empty first, `--verify-timeout <ms>`) |
|
|
265
278
|
| `scroll` | Scroll window or element (`--by <px>`, `--to-top`, `--to-bottom`, `--into-view`) |
|
|
266
279
|
| `focus <selector>` | Focus a DOM element |
|
|
267
280
|
| `navigate <target>` | Navigate within the app (route path or URL) |
|
|
268
|
-
| `select <selector> [value]` | Select dropdown value or toggle checkbox (`--toggle
|
|
281
|
+
| `select <selector> [value]` | Select a dropdown value or toggle a checkbox via native `click()`, then verify the write (`--toggle`, `--verify-timeout <ms>`) |
|
|
269
282
|
| `invoke <command> [args-json]` | Invoke a Tauri IPC command |
|
|
270
283
|
|
|
271
284
|
### Workflow Commands
|
|
@@ -277,6 +290,8 @@ Interaction commands dispatch DOM events inside the webview. They require the de
|
|
|
277
290
|
| `check` | Structured assertions (`--selector`, `--text`, `--eval`, `--no-errors`) — exits 0/1 |
|
|
278
291
|
| `store-inspect` | Inspect reactive store state (Pinia, Vue devtools, custom hooks) |
|
|
279
292
|
|
|
293
|
+
`check` requires at least one assertion. `--no-errors` observes for `--duration` (default 3000 ms) and fails if interrupted or if collection is incomplete. `capture` records interruptions and missing artifacts as `partial: true` with warnings; available evidence is preserved. `click --wait` polls in the CLI before dispatching once. Conflicting click types and scroll actions are rejected.
|
|
294
|
+
|
|
280
295
|
`capture`'s pipeline is also callable as a library: `captureToDir(bridge, adapter, opts)` returns the `CaptureManifest`. Deep-import it from `tauri-agent-tools/dist/commands/capture.js` — there is no package-root library entry point (the root is the CLI).
|
|
281
296
|
|
|
282
297
|
### Targeting Flags
|
|
@@ -304,9 +319,9 @@ tauri-agent-tools diagnose --config ./src-tauri -o ./diagnose-out
|
|
|
304
319
|
|
|
305
320
|
See [`docs/troubleshooting/decision-tree.md`](docs/troubleshooting/decision-tree.md) for the full symptom → command flowchart.
|
|
306
321
|
|
|
307
|
-
## Bridge-extending diagnostics
|
|
322
|
+
## Bridge-extending diagnostics
|
|
308
323
|
|
|
309
|
-
|
|
324
|
+
These commands feature-detect via `GET /version` and degrade with a note against older bridges. `process-tree` can use an OS fallback when a PID is available. Use `--strict` to require the richer endpoint and fail with an upgrade error.
|
|
310
325
|
|
|
311
326
|
```bash
|
|
312
327
|
# Tauri PID + registered sidecars (--deep walks the full OS descendant tree, no bridge needed)
|
|
@@ -324,7 +339,7 @@ tauri-agent-tools webview attach --open
|
|
|
324
339
|
tauri-agent-tools health --json
|
|
325
340
|
```
|
|
326
341
|
|
|
327
|
-
> **
|
|
342
|
+
> **Optional enrichment for integrators upgrading from v0.6:** To enable the richer endpoints, re-copy `examples/tauri-bridge/src/dev_bridge.rs` into your app. `start_bridge` now returns a third tuple element (`SidecarRegistry`); pass it to `spawn_sidecar_monitored` so sidecars show up in `process-tree`/`health`. See `.agents/skills/tauri-bridge-setup/SKILL.md` for the full upgrade walkthrough.
|
|
328
343
|
|
|
329
344
|
## Bridge-free diagnostics (new in 0.7)
|
|
330
345
|
|
|
@@ -346,7 +361,7 @@ tauri-agent-tools os-logs --level error --source main --duration 30000
|
|
|
346
361
|
# Wrap a sidecar, frame its stdout as NDJSON, validate against a JSON Schema
|
|
347
362
|
tauri-agent-tools sidecar tap --schema ./schema.json --record /tmp/run.ndjson -- node my-sidecar.js
|
|
348
363
|
# Replay the recording deterministically — to stdout or into a fresh sidecar's stdin
|
|
349
|
-
tauri-agent-tools sidecar replay /tmp/run.ndjson --to-exec node my-sidecar.js --rate 100
|
|
364
|
+
tauri-agent-tools sidecar replay /tmp/run.ndjson --to-exec "node my-sidecar.js" --rate 100
|
|
350
365
|
tauri-agent-tools sidecar replay /tmp/ipc-tap.ndjson --tap-format --dir out # (new in 0.9) unwrap {dir,ts,line} tap rows, replay one direction
|
|
351
366
|
|
|
352
367
|
# Forensic bundle for post-crash analysis (composes the above; works on dead apps)
|
|
@@ -380,7 +395,13 @@ tauri-agent-tools bundle --config ./src-tauri -o ./incident --since 10m
|
|
|
380
395
|
tauri-agent-tools bundle --with-capture # also snapshot the UI (needs live bridge)
|
|
381
396
|
```
|
|
382
397
|
|
|
383
|
-
`logs` works with no bridge (it reads the on-disk log files); a running bridge
|
|
398
|
+
`logs` works with no bridge (it reads the on-disk log files); a running bridge adds the live ring buffer. `logs`, `rust-logs`, and `capture` use independent cursors on bridge v0.8+, so one consumer does not drain another's entries. Older bridges fall back to draining with a warning. `logs --follow` requires a bridge; `diagnose --no-bridge` skips bridge requests even if a target is supplied.
|
|
399
|
+
|
|
400
|
+
`bundle` collects into a private temporary directory, redacts text and structured storage credentials, sanitizes its summaries, and scans for remaining secrets before publishing. A redaction failure exits nonzero and prevents publication of the new directory and archive. Missing optional sources are reported as failed phases with `partial: true`; captures also record `partial` and `warnings` in their manifest. Images remain unredacted and are listed as warnings for review before sharing.
|
|
401
|
+
|
|
402
|
+
The archive contains only artifacts generated by that run. Existing unrelated output files are preserved and excluded from the archive; artifact symlinks are rejected. If archive creation or publication fails, the directory remains available and its summary reports `archive: null`. `--no-archive` intentionally creates only the directory. Automatic redaction cannot guarantee removal of every secret; review the output before sharing it.
|
|
403
|
+
|
|
404
|
+
For `sidecar replay --to-exec`, quote the whole command, for example `--to-exec "node my-sidecar.js"`. The value is split on spaces; shell syntax and arguments containing spaces are not supported.
|
|
384
405
|
|
|
385
406
|
## How It Works
|
|
386
407
|
|
|
@@ -412,12 +433,12 @@ The crop accounts for window decoration (title bar, borders) by comparing `windo
|
|
|
412
433
|
|
|
413
434
|
## Design Decisions
|
|
414
435
|
|
|
415
|
-
### Inspection
|
|
436
|
+
### Inspection, evaluation, and interaction
|
|
416
437
|
|
|
417
|
-
|
|
438
|
+
Commands such as screenshot, DOM inspection, and storage inspection read app state. `eval` executes arbitrary JavaScript and can modify the app; the bridge does not enforce read-only evaluation. IPC and console monitors, `capture`, and `check --no-errors` temporarily wrap app APIs; mutations installs an observer. Each collector restores its own instrumentation on completion, error, SIGINT, or SIGTERM when the webview is reachable. Interaction commands (click, type, scroll, focus, navigate, select, invoke) use eval-based DOM event dispatch and **only work with the dev bridge** (debug builds). Native input injection (xdotool, Accessibility API) is deliberately avoided:
|
|
418
439
|
|
|
419
440
|
- **Native input is system-wide and risky.** X11 injection operates globally, not per-window — it can grab the cursor and require a hard reboot.
|
|
420
|
-
- **Eval-based dispatch
|
|
441
|
+
- **Eval-based dispatch targets the selected webview.** Application event handlers and invoked Tauri commands still run normally, including any backend work they perform.
|
|
421
442
|
- **Debug-only by design.** The bridge is compiled out of release builds (`cfg!(debug_assertions)`), so interaction commands cannot run against production apps.
|
|
422
443
|
|
|
423
444
|
### Why no MCP server mode
|
package/dist/bridge/client.d.ts
CHANGED
package/dist/bridge/client.js
CHANGED
|
@@ -13,6 +13,7 @@ const ENDPOINT_MIN_VERSION = {
|
|
|
13
13
|
};
|
|
14
14
|
export class BridgeClient {
|
|
15
15
|
baseUrl;
|
|
16
|
+
port;
|
|
16
17
|
token;
|
|
17
18
|
windowLabel;
|
|
18
19
|
/** Cached `/version` response. Populated by `requireEndpoint` on first call. */
|
|
@@ -20,6 +21,7 @@ export class BridgeClient {
|
|
|
20
21
|
/** Set when `/version` is unreachable so we don't retry it for every call. */
|
|
21
22
|
versionUnreachable = false;
|
|
22
23
|
constructor(config, windowLabel) {
|
|
24
|
+
this.port = config.port;
|
|
23
25
|
this.baseUrl = `http://127.0.0.1:${config.port}`;
|
|
24
26
|
this.token = config.token;
|
|
25
27
|
this.windowLabel = windowLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/bridge/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;GAIG;AACH,MAAM,oBAAoB,GAA2B;IACnD,UAAU,EAAE,OAAO;IACnB,eAAe,EAAE,OAAO;IACxB,WAAW,EAAE,OAAO;IACpB,SAAS,EAAE,OAAO;CACnB,CAAC;AAmBF,MAAM,OAAO,YAAY;IACf,OAAO,CAAS;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/bridge/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;GAIG;AACH,MAAM,oBAAoB,GAA2B;IACnD,UAAU,EAAE,OAAO;IACnB,eAAe,EAAE,OAAO;IACxB,WAAW,EAAE,OAAO;IACpB,SAAS,EAAE,OAAO;CACnB,CAAC;AAmBF,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;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3C,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;SACrC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,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,QAAQ,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BridgeClient } from './client.js';
|
|
2
|
+
/** Keep evaluation errors distinct from strings beginning with "ERROR:".
|
|
3
|
+
* The envelope is JSON text, so it works with both legacy stringifying bridges
|
|
4
|
+
* and bridges that preserve native JSON values. Truthiness is computed before
|
|
5
|
+
* serialization ("false" and false must remain different).
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildEvaluationScript(expression: string): string;
|
|
8
|
+
export declare function evaluateExpression(bridge: Pick<BridgeClient, 'eval'>, expression: string, timeout?: number): Promise<{
|
|
9
|
+
value: unknown;
|
|
10
|
+
truthy: boolean;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CliError } from '../errors.js';
|
|
3
|
+
const EvaluationSchema = z.discriminatedUnion('ok', [
|
|
4
|
+
z.object({ ok: z.literal(true), value: z.unknown(), truthy: z.boolean() }),
|
|
5
|
+
z.object({ ok: z.literal(false), error: z.string() }),
|
|
6
|
+
]);
|
|
7
|
+
/** Keep evaluation errors distinct from strings beginning with "ERROR:".
|
|
8
|
+
* The envelope is JSON text, so it works with both legacy stringifying bridges
|
|
9
|
+
* and bridges that preserve native JSON values. Truthiness is computed before
|
|
10
|
+
* serialization ("false" and false must remain different).
|
|
11
|
+
*/
|
|
12
|
+
export function buildEvaluationScript(expression) {
|
|
13
|
+
return `(async () => {
|
|
14
|
+
try {
|
|
15
|
+
const value = await (0, eval)(${JSON.stringify(expression)});
|
|
16
|
+
const kind = typeof value;
|
|
17
|
+
const encoded = kind === 'undefined' ? null
|
|
18
|
+
: ['bigint', 'symbol', 'function'].includes(kind) || (kind === 'number' && !Number.isFinite(value))
|
|
19
|
+
? String(value) : value;
|
|
20
|
+
return JSON.stringify({ ok: true, value: encoded, truthy: !!value });
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return JSON.stringify({ ok: false, error: error && error.message ? String(error.message) : String(error) });
|
|
23
|
+
}
|
|
24
|
+
})()`;
|
|
25
|
+
}
|
|
26
|
+
export async function evaluateExpression(bridge, expression, timeout = 5000) {
|
|
27
|
+
const raw = await bridge.eval(buildEvaluationScript(expression), timeout);
|
|
28
|
+
const result = EvaluationSchema.parse(typeof raw === 'string' ? JSON.parse(raw) : raw);
|
|
29
|
+
if (!result.ok)
|
|
30
|
+
throw new CliError('EVAL_FAILED', result.error, 'Check the expression or selector in the selected webview.');
|
|
31
|
+
return { value: result.value, truthy: result.truthy };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=evaluate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/bridge/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc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declare const LOG_CURSOR_UNAVAILABLE_NOTE = "bridge <0.8 has no log cursor; using drain polling (entries may be lost between polls)";
|
|
3
|
+
export interface LogCursor {
|
|
4
|
+
cursor: number;
|
|
5
|
+
drainFallback: boolean;
|
|
6
|
+
warnedDrainFallback: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function newLogCursor(): LogCursor;
|
|
9
|
+
interface LogClient {
|
|
10
|
+
fetchLogs(arg?: number | {
|
|
11
|
+
cursor?: number;
|
|
12
|
+
waitMs?: number;
|
|
13
|
+
limit?: number;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}): Promise<RustLogEntry[] | {
|
|
16
|
+
entries: RustLogEntry[];
|
|
17
|
+
cursor?: number;
|
|
18
|
+
dropped?: number;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export declare function readRustLogs(client: LogClient, state?: LogCursor, options?: {
|
|
22
|
+
waitMs?: number;
|
|
23
|
+
limit?: number;
|
|
24
|
+
intervalMs?: number;
|
|
25
|
+
warn?: (message: string) => void;
|
|
26
|
+
}): Promise<RustLogEntry[]>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const LOG_CURSOR_UNAVAILABLE_NOTE = 'bridge <0.8 has no log cursor; using drain polling (entries may be lost between polls)';
|
|
2
|
+
export function newLogCursor() {
|
|
3
|
+
return { cursor: 0, drainFallback: false, warnedDrainFallback: false };
|
|
4
|
+
}
|
|
5
|
+
export async function readRustLogs(client, state = newLogCursor(), options = {}) {
|
|
6
|
+
const warn = options.warn ?? console.error;
|
|
7
|
+
const response = state.drainFallback
|
|
8
|
+
? await client.fetchLogs(Math.max(options.intervalMs ?? 2000, 2000))
|
|
9
|
+
: await client.fetchLogs({ cursor: state.cursor, waitMs: options.waitMs ?? 0,
|
|
10
|
+
limit: options.limit ?? 1000, timeoutMs: Math.max(5000, (options.waitMs ?? 0) + 1000) });
|
|
11
|
+
const batch = Array.isArray(response) ? { entries: response } : response;
|
|
12
|
+
if (batch.cursor === undefined) {
|
|
13
|
+
state.drainFallback = true;
|
|
14
|
+
if (!state.warnedDrainFallback) {
|
|
15
|
+
state.warnedDrainFallback = true;
|
|
16
|
+
warn(`note: ${LOG_CURSOR_UNAVAILABLE_NOTE}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
state.cursor = batch.cursor;
|
|
21
|
+
if (batch.dropped)
|
|
22
|
+
warn(`warning: bridge log cursor dropped ${batch.dropped} evicted entries`);
|
|
23
|
+
}
|
|
24
|
+
return batch.entries;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=logReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logReader.js","sourceRoot":"","sources":["../../src/bridge/logReader.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GACtC,wFAAwF,CAAC;AAQ3F,MAAM,UAAU,YAAY;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;AACzE,CAAC;AAOD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAiB,EACjB,QAAmB,YAAY,EAAE,EACjC,UAAsG,EAAE;IAExG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC;IAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa;QAClC,CAAC,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI,EAAE,IAAI,CAAC,CAAC;QACpE,CAAC,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;YAC1E,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7F,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzE,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;YAC/B,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,SAAS,2BAA2B,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,KAAK,CAAC,OAAO;YAAE,IAAI,CAAC,sCAAsC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BridgeClient } from './client.js';
|
|
2
|
+
export interface ObserverScripts {
|
|
3
|
+
patch: string;
|
|
4
|
+
drain: string;
|
|
5
|
+
cleanup: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function consoleObserver(id?: string): ObserverScripts;
|
|
8
|
+
export declare function ipcObserver(id?: string): ObserverScripts;
|
|
9
|
+
export declare function mutationObserver(selector: string, attributes: boolean, id?: string): ObserverScripts;
|
|
10
|
+
export declare function readObserver(bridge: Pick<BridgeClient, 'eval'>, scripts: ObserverScripts, warn?: (message: string) => void): Promise<unknown[]>;
|
|
11
|
+
export declare function closeObserver(bridge: Pick<BridgeClient, 'eval'>, scripts: ObserverScripts, warn?: (message: string) => void): Promise<void>;
|