browser-automation-skill 0.71.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 (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +144 -0
  3. package/SECURITY.md +39 -0
  4. package/SKILL.md +206 -0
  5. package/bin/cli.mjs +55 -0
  6. package/install.sh +143 -0
  7. package/package.json +54 -0
  8. package/references/adapter-candidates.md +40 -0
  9. package/references/browser-mcp-cheatsheet.md +132 -0
  10. package/references/browser-stats-cheatsheet.md +155 -0
  11. package/references/chrome-devtools-mcp-cheatsheet.md +232 -0
  12. package/references/midscene-integration.md +359 -0
  13. package/references/obscura-cheatsheet.md +103 -0
  14. package/references/playwright-cli-cheatsheet.md +64 -0
  15. package/references/playwright-lib-cheatsheet.md +90 -0
  16. package/references/recipes/add-a-tool-adapter.md +134 -0
  17. package/references/recipes/agent-workflows/README.md +37 -0
  18. package/references/recipes/agent-workflows/cache-driven-bulk-operation.md +110 -0
  19. package/references/recipes/agent-workflows/flow-record-and-replay.md +102 -0
  20. package/references/recipes/agent-workflows/incremental-pattern-discovery.md +125 -0
  21. package/references/recipes/agent-workflows/login-then-scrape.md +100 -0
  22. package/references/recipes/anti-patterns-tool-extension.md +182 -0
  23. package/references/recipes/body-bytes-not-body.md +139 -0
  24. package/references/recipes/cache-write-security.md +210 -0
  25. package/references/recipes/fingerprint-rescue.md +154 -0
  26. package/references/recipes/model-routing.md +143 -0
  27. package/references/recipes/path-security.md +138 -0
  28. package/references/recipes/privacy-canary.md +96 -0
  29. package/references/recipes/visual-rescue-hook.md +182 -0
  30. package/references/stats-prices.json +42 -0
  31. package/references/stats-schema.json +77 -0
  32. package/references/tool-versions.md +8 -0
  33. package/scripts/browser-add-site.sh +113 -0
  34. package/scripts/browser-assert.sh +106 -0
  35. package/scripts/browser-audit.sh +68 -0
  36. package/scripts/browser-baseline.sh +135 -0
  37. package/scripts/browser-click.sh +100 -0
  38. package/scripts/browser-creds-add.sh +254 -0
  39. package/scripts/browser-creds-list.sh +67 -0
  40. package/scripts/browser-creds-migrate.sh +122 -0
  41. package/scripts/browser-creds-remove.sh +69 -0
  42. package/scripts/browser-creds-rotate-totp.sh +109 -0
  43. package/scripts/browser-creds-show.sh +82 -0
  44. package/scripts/browser-creds-totp.sh +94 -0
  45. package/scripts/browser-do.sh +630 -0
  46. package/scripts/browser-doctor.sh +365 -0
  47. package/scripts/browser-drag.sh +90 -0
  48. package/scripts/browser-extract.sh +192 -0
  49. package/scripts/browser-fill.sh +142 -0
  50. package/scripts/browser-flow.sh +316 -0
  51. package/scripts/browser-history.sh +187 -0
  52. package/scripts/browser-hover.sh +92 -0
  53. package/scripts/browser-inspect.sh +188 -0
  54. package/scripts/browser-list-sessions.sh +78 -0
  55. package/scripts/browser-list-sites.sh +42 -0
  56. package/scripts/browser-login.sh +279 -0
  57. package/scripts/browser-mcp.sh +65 -0
  58. package/scripts/browser-migrate.sh +195 -0
  59. package/scripts/browser-open.sh +134 -0
  60. package/scripts/browser-press.sh +80 -0
  61. package/scripts/browser-remove-session.sh +72 -0
  62. package/scripts/browser-remove-site.sh +68 -0
  63. package/scripts/browser-replay.sh +206 -0
  64. package/scripts/browser-route.sh +174 -0
  65. package/scripts/browser-select.sh +122 -0
  66. package/scripts/browser-show-session.sh +57 -0
  67. package/scripts/browser-show-site.sh +37 -0
  68. package/scripts/browser-snapshot.sh +176 -0
  69. package/scripts/browser-stats.sh +522 -0
  70. package/scripts/browser-tab-close.sh +112 -0
  71. package/scripts/browser-tab-list.sh +70 -0
  72. package/scripts/browser-tab-switch.sh +111 -0
  73. package/scripts/browser-upload.sh +132 -0
  74. package/scripts/browser-use.sh +60 -0
  75. package/scripts/browser-vlm.sh +707 -0
  76. package/scripts/browser-wait.sh +97 -0
  77. package/scripts/install-git-hooks.sh +16 -0
  78. package/scripts/lib/capture.sh +356 -0
  79. package/scripts/lib/common.sh +262 -0
  80. package/scripts/lib/credential.sh +237 -0
  81. package/scripts/lib/fingerprint-rescue.js +123 -0
  82. package/scripts/lib/flow.sh +448 -0
  83. package/scripts/lib/flow_record.sh +210 -0
  84. package/scripts/lib/mask.sh +49 -0
  85. package/scripts/lib/memory.sh +427 -0
  86. package/scripts/lib/migrate.sh +390 -0
  87. package/scripts/lib/migrators/README.md +23 -0
  88. package/scripts/lib/migrators/memory/v1_to_v2.sh +15 -0
  89. package/scripts/lib/migrators/recent_urls/README.md +13 -0
  90. package/scripts/lib/migrators/stats/README.md +24 -0
  91. package/scripts/lib/node/chrome-devtools-bridge.mjs +1812 -0
  92. package/scripts/lib/node/mcp-server.mjs +531 -0
  93. package/scripts/lib/node/mcp-tools.json +68 -0
  94. package/scripts/lib/node/playwright-driver.mjs +1104 -0
  95. package/scripts/lib/node/totp-core.mjs +52 -0
  96. package/scripts/lib/node/totp.mjs +52 -0
  97. package/scripts/lib/node/url-pattern-cluster.mjs +102 -0
  98. package/scripts/lib/node/url-pattern-resolver.mjs +77 -0
  99. package/scripts/lib/output.sh +79 -0
  100. package/scripts/lib/router.sh +342 -0
  101. package/scripts/lib/sanitize.sh +107 -0
  102. package/scripts/lib/secret/keychain.sh +91 -0
  103. package/scripts/lib/secret/libsecret.sh +74 -0
  104. package/scripts/lib/secret/plaintext.sh +75 -0
  105. package/scripts/lib/secret_backend_select.sh +57 -0
  106. package/scripts/lib/session.sh +153 -0
  107. package/scripts/lib/site.sh +126 -0
  108. package/scripts/lib/stats.sh +419 -0
  109. package/scripts/lib/tool/.gitkeep +0 -0
  110. package/scripts/lib/tool/chrome-devtools-mcp.sh +349 -0
  111. package/scripts/lib/tool/obscura.sh +249 -0
  112. package/scripts/lib/tool/playwright-cli.sh +155 -0
  113. package/scripts/lib/tool/playwright-lib.sh +106 -0
  114. package/scripts/lib/verb_helpers.sh +222 -0
  115. package/scripts/lib/visual-rescue-default.sh +145 -0
  116. package/scripts/regenerate-docs.sh +99 -0
  117. package/uninstall.sh +51 -0
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env bash
2
+ # scripts/browser-snapshot.sh — capture an accessibility snapshot via the
3
+ # routed adapter; result is eN-indexed per token-efficient-output spec §5.
4
+ # Usage: bash scripts/browser-snapshot.sh [--site NAME] [--tool NAME]
5
+ # [--dry-run] [--raw] [--depth N]
6
+ # [--capture]
7
+ #
8
+ # Phase 7 part 1-i: --capture writes adapter stdout to
9
+ # ${CAPTURES_DIR}/NNN/snapshot.json + meta.json. capture_id joins the summary.
10
+ # Snapshot is structurally safe (refs only, no headers/cookies) — sanitization
11
+ # arrives in 7-iii when console.json + network.har enter the picture.
12
+
13
+ set -euo pipefail
14
+ IFS=$'\n\t'
15
+
16
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ # shellcheck source=lib/common.sh
18
+ # shellcheck disable=SC1091
19
+ source "${SCRIPT_DIR}/lib/common.sh"
20
+ # shellcheck source=lib/output.sh
21
+ # shellcheck disable=SC1091
22
+ source "${SCRIPT_DIR}/lib/output.sh"
23
+ # shellcheck source=lib/router.sh
24
+ # shellcheck disable=SC1091
25
+ source "${SCRIPT_DIR}/lib/router.sh"
26
+ # shellcheck source=lib/verb_helpers.sh
27
+ # shellcheck disable=SC1091
28
+ source "${SCRIPT_DIR}/lib/verb_helpers.sh"
29
+ # shellcheck source=lib/capture.sh
30
+ # shellcheck disable=SC1091
31
+ source "${SCRIPT_DIR}/lib/capture.sh"
32
+ # shellcheck source=lib/stats.sh
33
+ # shellcheck disable=SC1091
34
+ source "${SCRIPT_DIR}/lib/stats.sh"
35
+
36
+ init_paths
37
+
38
+ SUMMARY_T0="$(now_ms)"; export SUMMARY_T0
39
+
40
+ parse_verb_globals "$@"
41
+
42
+ # Resolve site/session → BROWSER_SKILL_STORAGE_STATE (no-op if neither set).
43
+ # Router's rule_session_required reads the env var to prefer playwright-lib.
44
+ resolve_session_storage_state
45
+
46
+ # Strip --capture (verb-script-level; not for adapter dispatch). All other
47
+ # args pass through.
48
+ do_capture=0
49
+ verb_argv=()
50
+ i=0
51
+ while [ "${i}" -lt "${#REMAINING_ARGV[@]}" ]; do
52
+ case "${REMAINING_ARGV[i]}" in
53
+ --capture)
54
+ do_capture=1
55
+ i=$((i + 1))
56
+ ;;
57
+ *)
58
+ verb_argv+=("${REMAINING_ARGV[i]}")
59
+ i=$((i + 1))
60
+ ;;
61
+ esac
62
+ done
63
+
64
+ if [ "${ARG_DRY_RUN:-0}" = "1" ]; then
65
+ ok "dry-run: would snapshot"
66
+ if [ "${do_capture}" = "1" ]; then
67
+ emit_summary verb=snapshot tool=none why=dry-run status=ok dry_run=true capture=true
68
+ else
69
+ emit_summary verb=snapshot tool=none why=dry-run status=ok dry_run=true
70
+ fi
71
+ exit 0
72
+ fi
73
+
74
+ picked="$(pick_tool snapshot "${verb_argv[@]}")"
75
+ tool_name="${picked%%$'\t'*}"
76
+ why="${picked#*$'\t'}"
77
+
78
+ source_picked_adapter "${tool_name}"
79
+
80
+ # Open capture dir BEFORE adapter call so meta.json/in_progress lands even if
81
+ # the adapter crashes before producing output.
82
+ if [ "${do_capture}" = "1" ]; then
83
+ capture_start snapshot
84
+ fi
85
+
86
+ # invoke_with_retry wraps tool_snapshot in transparent retry-on-EXIT_SESSION_
87
+ # EXPIRED (phase-5 part 3-ii).
88
+ stats_t0="$(now_ms)"
89
+ set +e
90
+ adapter_out="$(invoke_with_retry snapshot "${verb_argv[@]}")"
91
+ adapter_rc=$?
92
+ set -e
93
+
94
+ # Phase 14 (Bundle #1): heavy snapshots → file ref per spec §3.2 ("refs_inline
95
+ # only when total length ≤ 2 KB. Above that threshold, fall back to
96
+ # snapshot_path"). Real telemetry (35 events) showed avg 1570B / max 4567B
97
+ # snapshot output — borderline-to-bloat. File-ref cuts repeat-snapshot cost on
98
+ # the same page from re-paying-the-tokens to one-Read-then-cache.
99
+ # Overrides:
100
+ # BROWSER_SKILL_SNAPSHOT_INLINE_BYTES threshold (default 2048)
101
+ # BROWSER_SKILL_SNAPSHOT_TEASER_BYTES truncated-body cap when over (default 512)
102
+ snapshot_threshold="${BROWSER_SKILL_SNAPSHOT_INLINE_BYTES:-2048}"
103
+ teaser_cap="${BROWSER_SKILL_SNAPSHOT_TEASER_BYTES:-512}"
104
+ snapshot_path=""
105
+ n_refs=0
106
+ adapter_out_bytes=${#adapter_out}
107
+ if [ "${adapter_rc}" -eq 0 ] \
108
+ && [ "${adapter_out_bytes}" -gt "${snapshot_threshold}" ]; then
109
+ snapshot_site="${ARG_SITE:-anon}"
110
+ if snapshot_path="$(capture_path snapshots "${snapshot_site}" yaml 2>/dev/null)"; then
111
+ if printf '%s' "${adapter_out}" > "${snapshot_path}" 2>/dev/null; then
112
+ chmod 600 "${snapshot_path}" 2>/dev/null || true
113
+ n_refs="$(printf '%s' "${adapter_out}" \
114
+ | grep -oE '\[ref=e[0-9]+\]' | wc -l | tr -d ' ')"
115
+ teaser_head="$(printf '%s' "${adapter_out}" | head -c "${teaser_cap}")"
116
+ adapter_out="${teaser_head}
117
+ ... (truncated; full snapshot at ${snapshot_path}; ${n_refs} refs)"
118
+ else
119
+ # File write failed — revert to inline so we never lose the snapshot.
120
+ warn "snapshot: failed to write ${snapshot_path}; falling back to inline"
121
+ snapshot_path=""
122
+ fi
123
+ else
124
+ warn "snapshot: capture_path rejected site='${snapshot_site}'; inline fallback"
125
+ snapshot_path=""
126
+ fi
127
+ fi
128
+
129
+ # Phase 12 part 1: per-action telemetry. Snapshots have no natural post-cond
130
+ # observed value beyond the snapshot body; observed=adapter_out supports
131
+ # element_value matchers (rare but supported). After Phase 14, adapter_out is
132
+ # already the teaser when redirected — telemetry naturally records the
133
+ # compressed payload (no second jsonl bloat).
134
+ BROWSER_STATS_OBSERVED="${adapter_out}" \
135
+ stats_run_adapter_emit \
136
+ "snapshot" "${tool_name}" "${stats_t0}" "${adapter_rc}" "${adapter_out}" "" \
137
+ -- "${verb_argv[@]}" || true
138
+
139
+ [ -n "${adapter_out}" ] && printf '%s\n' "${adapter_out}"
140
+
141
+ # Persist adapter stdout to snapshot.json before finalizing meta.json (so the
142
+ # inventory + total_bytes reflect the artifact). When snapshot_path was set
143
+ # above, write the FULL body (from the file we already created) so --capture
144
+ # still gets the unredacted YAML.
145
+ if [ "${do_capture}" = "1" ]; then
146
+ if [ -n "${snapshot_path}" ] && [ -f "${snapshot_path}" ]; then
147
+ cp "${snapshot_path}" "${CAPTURE_DIR}/snapshot.json"
148
+ chmod 600 "${CAPTURE_DIR}/snapshot.json"
149
+ elif [ -n "${adapter_out}" ]; then
150
+ printf '%s\n' "${adapter_out}" > "${CAPTURE_DIR}/snapshot.json"
151
+ chmod 600 "${CAPTURE_DIR}/snapshot.json"
152
+ fi
153
+ if [ "${adapter_rc}" -eq 0 ]; then
154
+ capture_finish ok
155
+ else
156
+ capture_finish error
157
+ fi
158
+ fi
159
+
160
+ # Build summary kv list (snapshot_path + n_refs only when redirected).
161
+ summary_extra=()
162
+ if [ -n "${snapshot_path}" ]; then
163
+ summary_extra+=("snapshot_path=${snapshot_path}" "n_refs=${n_refs}")
164
+ fi
165
+ if [ "${do_capture}" = "1" ]; then
166
+ summary_extra+=("capture_id=${CAPTURE_ID}")
167
+ fi
168
+
169
+ if [ "${adapter_rc}" -eq 0 ]; then
170
+ emit_summary verb=snapshot tool="${tool_name}" why="${why}" status=ok \
171
+ "${summary_extra[@]}"
172
+ exit 0
173
+ fi
174
+ emit_summary verb=snapshot tool="${tool_name}" why="${why}" status=error \
175
+ "${summary_extra[@]}"
176
+ exit "${adapter_rc}"