@weavetab/skills 1.0.3 → 2.5.0-beta.5

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 (79) hide show
  1. package/README.md +108 -60
  2. package/ROUTER.md +43 -0
  3. package/bin/cli.js +232 -132
  4. package/browser/dom-strategy.md +119 -0
  5. package/browser/form-automation.md +87 -0
  6. package/browser/interaction-pipeline.md +216 -0
  7. package/browser/tab-and-window.md +136 -0
  8. package/desktop/desktop-targeting.md +85 -0
  9. package/desktop/electron-discovery.md +115 -0
  10. package/developer/github-forensics.md +74 -0
  11. package/dist/bundled/weavetab-all.md +1910 -0
  12. package/dist/bundled/weavetab-browser.md +501 -0
  13. package/dist/bundled/weavetab-desktop.md +176 -0
  14. package/dist/bundled/weavetab-developer.md +67 -0
  15. package/dist/bundled/weavetab-documents.md +142 -0
  16. package/dist/bundled/weavetab-memory.md +359 -0
  17. package/dist/bundled/weavetab-network-and-perf.md +223 -0
  18. package/dist/bundled/weavetab-plugins.md +83 -0
  19. package/dist/bundled/weavetab-resilience.md +216 -0
  20. package/dist/bundled/weavetab-security.md +87 -0
  21. package/dist/granular/browser_dom-strategy.md +119 -0
  22. package/dist/granular/browser_form-automation.md +87 -0
  23. package/dist/granular/browser_interaction-pipeline.md +216 -0
  24. package/dist/granular/browser_tab-and-window.md +136 -0
  25. package/dist/granular/desktop_desktop-targeting.md +85 -0
  26. package/dist/granular/desktop_electron-discovery.md +115 -0
  27. package/dist/granular/developer_github-forensics.md +74 -0
  28. package/dist/granular/documents_canvas-and-visual-capture.md +103 -0
  29. package/dist/granular/documents_office-document-ingestion.md +63 -0
  30. package/dist/granular/memory_selector-memory-system.md +127 -0
  31. package/dist/granular/memory_session-trail.md +95 -0
  32. package/dist/granular/memory_site-learning.md +180 -0
  33. package/dist/granular/network-and-perf_device-and-environment.md +87 -0
  34. package/dist/granular/network-and-perf_network-intercept-and-mock.md +84 -0
  35. package/dist/granular/network-and-perf_performance-and-vitals.md +84 -0
  36. package/dist/granular/plugins_hooks-and-overrides.md +35 -0
  37. package/dist/granular/plugins_plugin-runtime.md +63 -0
  38. package/dist/granular/resilience_loop-breaker.md +67 -0
  39. package/dist/granular/resilience_session-time-travel.md +131 -0
  40. package/dist/granular/resilience_stale-ref-recovery.md +53 -0
  41. package/dist/granular/security_rbac-and-policies.md +47 -0
  42. package/dist/granular/security_secret-containment-protocol.md +59 -0
  43. package/documents/canvas-and-visual-capture.md +103 -0
  44. package/documents/office-document-ingestion.md +63 -0
  45. package/evals/evaluator.js +146 -0
  46. package/evals/scenarios.json +239 -0
  47. package/memory/selector-memory-system.md +127 -0
  48. package/memory/session-trail.md +95 -0
  49. package/memory/site-learning.md +180 -0
  50. package/network-and-perf/device-and-environment.md +87 -0
  51. package/network-and-perf/network-intercept-and-mock.md +84 -0
  52. package/network-and-perf/performance-and-vitals.md +84 -0
  53. package/package.json +31 -9
  54. package/plugins/hooks-and-overrides.md +35 -0
  55. package/plugins/plugin-runtime.md +63 -0
  56. package/resilience/loop-breaker.md +67 -0
  57. package/resilience/session-time-travel.md +131 -0
  58. package/resilience/stale-ref-recovery.md +53 -0
  59. package/security/rbac-and-policies.md +47 -0
  60. package/security/secret-containment-protocol.md +59 -0
  61. package/skills.json +321 -203
  62. package/src/api.js +239 -128
  63. package/advanced/README.md +0 -2
  64. package/automation/README.md +0 -2
  65. package/general/captcha-evasion.md +0 -13
  66. package/general/context-awareness.md +0 -13
  67. package/general/cookie-consent.md +0 -13
  68. package/general/data-extraction.md +0 -13
  69. package/general/dynamic-interaction.md +0 -13
  70. package/general/error-recovery.md +0 -13
  71. package/general/file-upload.md +0 -13
  72. package/general/form-filling.md +0 -16
  73. package/general/guardrails.md +0 -13
  74. package/general/iframe-handling.md +0 -13
  75. package/general/infinite-scroll.md +0 -13
  76. package/general/login-flow.md +0 -16
  77. package/general/multi-tab-management.md +0 -13
  78. package/general/spa-navigation.md +0 -13
  79. package/general/table-scraping.md +0 -13
@@ -0,0 +1,87 @@
1
+ ---
2
+ id: device-and-environment
3
+ domain: network-and-perf
4
+ triggers:
5
+ - "emulate device"
6
+ - "mobile view"
7
+ - "throttle network"
8
+ - "geolocation override"
9
+ - "user agent"
10
+ - "responsive testing"
11
+ tools:
12
+ - "browser_emulate"
13
+ weavetab: ">=2.5.0-beta.5"
14
+ ---
15
+
16
+ # Device Emulation & Environment Simulation
17
+
18
+ Auditing mobile responsive layouts, testing geographic restrictions, and simulating degraded network conditions can all be accomplished with `browser_emulate`.
19
+
20
+ ---
21
+
22
+ ## 1. Device Presets & Viewport Simulation
23
+
24
+ Switch from desktop to realistic mobile hardware profiles:
25
+
26
+ ```json
27
+ {
28
+ "device": "iPhone 15 Pro",
29
+ "orientation": "portrait"
30
+ }
31
+ ```
32
+
33
+ Or configure custom screen geometries:
34
+
35
+ ```json
36
+ {
37
+ "viewport": {
38
+ "width": 393,
39
+ "height": 852,
40
+ "deviceScaleFactor": 3,
41
+ "isMobile": true,
42
+ "hasTouch": true
43
+ }
44
+ }
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 2. Network Throttling Simulation
50
+
51
+ Verify how web applications degrade under poor connectivity:
52
+
53
+ ```json
54
+ {
55
+ "network": {
56
+ "offline": false,
57
+ "downloadThroughput": 1024 * 500, // 500 kb/s (Slow 3G)
58
+ "uploadThroughput": 1024 * 250,
59
+ "latency": 400 // ms
60
+ }
61
+ }
62
+ ```
63
+
64
+ ---
65
+
66
+ ## 3. Geolocation & Timezone Overrides
67
+
68
+ Bypass localized IP redirects or verify localized content rendering:
69
+
70
+ ```json
71
+ {
72
+ "geolocation": {
73
+ "latitude": 37.7749,
74
+ "longitude": -122.4194,
75
+ "accuracy": 100
76
+ },
77
+ "timezoneId": "America/Los_Angeles",
78
+ "locale": "en-US"
79
+ }
80
+ ```
81
+
82
+ To reset all overrides back to default host system parameters:
83
+ ```json
84
+ {
85
+ "reset": true
86
+ }
87
+ ```
@@ -0,0 +1,84 @@
1
+ ---
2
+ id: network-intercept-and-mock
3
+ domain: network-and-perf
4
+ triggers:
5
+ - "mock api"
6
+ - "intercept network"
7
+ - "stub request"
8
+ - "inspect tls"
9
+ - "ssl certificate"
10
+ - "network waterfall"
11
+ tools:
12
+ - "browser_network_intercept"
13
+ weavetab: ">=2.5.0-beta.5"
14
+ ---
15
+
16
+ # Network Interception, Mocking & TLS Forensics
17
+
18
+ Autonomous testing and debugging often require simulating backend error states (e.g. 500 Internal Server Error, 429 Rate Limit), stubbing third-party analytics, or verifying TLS/SSL certificates.
19
+
20
+ `browser_network_intercept` provides fine-grained CDP request and response modification.
21
+
22
+ ---
23
+
24
+ ## 1. Mocking API Responses
25
+
26
+ Intercept outgoing HTTP requests matching a URL pattern and return custom mock data:
27
+
28
+ ```json
29
+ {
30
+ "pattern": "*/api/v1/user/profile",
31
+ "response": {
32
+ "status": 200,
33
+ "headers": {
34
+ "Content-Type": "application/json"
35
+ },
36
+ "body": "{\"id\": \"usr_test\", \"role\": \"admin\", \"credits\": 9999}"
37
+ }
38
+ }
39
+ ```
40
+
41
+ ---
42
+
43
+ ## 2. Blocking Unnecessary Traffic & Trackers
44
+
45
+ Accelerate page loads and eliminate token bloat by aborting non-essential requests:
46
+
47
+ ```json
48
+ {
49
+ "pattern": "*google-analytics.com*",
50
+ "action": "abort",
51
+ "errorReason": "BlockedByClient"
52
+ }
53
+ ```
54
+
55
+ ---
56
+
57
+ ## 3. TLS / SSL Forensics & Timing Waterfalls
58
+
59
+ Extract cryptographic handshake metadata, cipher suites, expiration dates, and microsecond network waterfalls (DNS lookup, TCP connect, SSL handshake, TTFB):
60
+
61
+ ```json
62
+ {
63
+ "action": "auditTls",
64
+ "url": "https://weavetab.dev"
65
+ }
66
+ ```
67
+
68
+ ### Response Example:
69
+ ```json
70
+ {
71
+ "security": {
72
+ "protocol": "TLS 1.3",
73
+ "cipher": "AES_128_GCM",
74
+ "issuer": "Let's Encrypt",
75
+ "validTo": "2026-11-15T00:00:00.000Z"
76
+ },
77
+ "waterfall": {
78
+ "dnsMs": 1.4,
79
+ "tcpMs": 3.2,
80
+ "sslMs": 4.1,
81
+ "ttfbMs": 12.8
82
+ }
83
+ }
84
+ ```
@@ -0,0 +1,84 @@
1
+ ---
2
+ id: performance-and-vitals
3
+ domain: network-and-perf
4
+ triggers:
5
+ - "measure performance"
6
+ - "core web vitals"
7
+ - "lcp"
8
+ - "cls"
9
+ - "fcp"
10
+ - "wait condition"
11
+ - "page slow"
12
+ tools:
13
+ - "browser_performance"
14
+ - "browser_wait"
15
+ weavetab: ">=2.5.0-beta.5"
16
+ ---
17
+
18
+ # Performance Forensics & Core Web Vitals
19
+
20
+ Optimizing agent execution and auditing client performance requires objective metrics rather than arbitrary sleep timers.
21
+
22
+ ---
23
+
24
+ ## 1. Core Web Vitals Auditing (`browser_performance`)
25
+
26
+ Retrieve Google Core Web Vitals, memory consumption, and frame rendering bottlenecks directly from the Chromium engine:
27
+
28
+ ```json
29
+ {
30
+ "metrics": ["vitals", "memory", "navigationTiming"]
31
+ }
32
+ ```
33
+
34
+ ### Response Example:
35
+ ```json
36
+ {
37
+ "vitals": {
38
+ "fcp": 320,
39
+ "lcp": 780,
40
+ "cls": 0.012,
41
+ "fid": 8,
42
+ "inp": 45
43
+ },
44
+ "memory": {
45
+ "jsHeapUsedSizeMb": 42.1,
46
+ "jsHeapTotalSizeMb": 68.4
47
+ }
48
+ }
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 2. Deterministic Synchronization (`browser_wait`)
54
+
55
+ > [!WARNING]
56
+ > NEVER call arbitrary fixed sleep timers (e.g. `sleep 5000`). Fixed sleeps waste user time and still fail when network latency spikes.
57
+
58
+ Always synchronize with deterministic browser conditions:
59
+
60
+ ### Wait for Network Idle:
61
+ ```json
62
+ {
63
+ "condition": "network_idle",
64
+ "timeout": 10000
65
+ }
66
+ ```
67
+
68
+ ### Wait for DOM Mutation Stability:
69
+ ```json
70
+ {
71
+ "condition": "dom_stable",
72
+ "duration": 500,
73
+ "timeout": 10000
74
+ }
75
+ ```
76
+
77
+ ### Wait for a Specific Element to Appear:
78
+ ```json
79
+ {
80
+ "condition": "element_visible",
81
+ "selector": "[data-testid=\"checkout-complete\"]",
82
+ "timeout": 15000
83
+ }
84
+ ```
package/package.json CHANGED
@@ -1,15 +1,28 @@
1
1
  {
2
2
  "name": "@weavetab/skills",
3
- "version": "1.0.3",
4
- "description": "Supercharge your AI Agents with Weavetab MCP Skills. Native drop-in skills for Antigravity, Cursor, Cline, and more.",
5
- "author": "fy2ne",
3
+ "version": "2.5.0-beta.5",
4
+ "description": "Supercharge your AI Agents with Weavetab MCP Skills. Domain-driven agent intelligence for Antigravity, Cursor, Cline, Windsurf, and more.",
5
+ "author": {
6
+ "name": "fy2ne",
7
+ "email": "hello@fy2ne.me",
8
+ "url": "https://fy2ne.me"
9
+ },
6
10
  "license": "MIT",
7
11
  "files": [
8
12
  "bin",
9
- "general",
10
- "automation",
11
- "advanced",
12
13
  "src",
14
+ "dist",
15
+ "ROUTER.md",
16
+ "browser",
17
+ "desktop",
18
+ "memory",
19
+ "resilience",
20
+ "security",
21
+ "plugins",
22
+ "network-and-perf",
23
+ "documents",
24
+ "developer",
25
+ "evals",
13
26
  "skills.json"
14
27
  ],
15
28
  "repository": {
@@ -23,6 +36,8 @@
23
36
  "keywords": [
24
37
  "weavetab",
25
38
  "weavetab-mcp",
39
+ "weavetab-skills",
40
+ "weavetab-plugins",
26
41
  "mcp",
27
42
  "ai-agent",
28
43
  "cursor",
@@ -30,10 +45,16 @@
30
45
  "antigravity",
31
46
  "browser-automation",
32
47
  "agent-skills",
33
- "openclaw"
48
+ "openclaw",
49
+ "plugins",
50
+ "skills",
51
+ "agentic"
34
52
  ],
53
+ "peerDependencies": {
54
+ "@weavetab/mcp": "2.5.0-beta.5"
55
+ },
35
56
  "peerDependenciesMeta": {
36
- "weavetab": {
57
+ "@weavetab/mcp": {
37
58
  "optional": true
38
59
  }
39
60
  },
@@ -42,7 +63,8 @@
42
63
  "skills": "bin/cli.js"
43
64
  },
44
65
  "scripts": {
45
- "build": "node scripts/build.js"
66
+ "build": "node scripts/build.js",
67
+ "test": "node evals/evaluator.js"
46
68
  },
47
69
  "dependencies": {
48
70
  "@inquirer/prompts": "^7.3.1",
@@ -0,0 +1,35 @@
1
+ ---
2
+ id: hooks-and-overrides
3
+ domain: plugins
4
+ triggers:
5
+ - "plugin hooks"
6
+ - "before tool call"
7
+ - "after tool call"
8
+ - "telemetry interception"
9
+ - "sdk hooks"
10
+ tools: []
11
+ weavetab: ">=2.5.0-beta.5"
12
+ ---
13
+
14
+ # Plugin Hooks & Lifecycle Overrides
15
+
16
+ Plugins built with `@weavetab/sdk` register lifecycle hooks that run before and after tool executions. Understanding these hooks helps agents interpret metadata and custom tool responses.
17
+
18
+ ---
19
+
20
+ ## 1. Supported Plugin Hooks
21
+
22
+ 1. **`beforeToolCall(toolName, args)`**:
23
+ - Validates arguments against custom enterprise schemas.
24
+ - Injects tenant IDs, authentication headers, or proxy routing.
25
+ 2. **`afterToolCall(toolName, result, durationMs)`**:
26
+ - Emits OpenTelemetry metrics and timing waterfalls to external APM platforms.
27
+ - Enriches return objects with contextual metadata.
28
+ 3. **`onNavigate(url, targetId)`**:
29
+ - Triggers automated cookie injection or session setup upon page navigation.
30
+
31
+ ---
32
+
33
+ ## 2. Agent Operational Awareness
34
+
35
+ When plugins are active, tool return payloads may include an optional `_pluginMetadata` object containing trace IDs, custom metrics, or security audit timestamps. Agents should treat this object as informational telemetry.
@@ -0,0 +1,63 @@
1
+ ---
2
+ id: plugin-runtime
3
+ domain: plugins
4
+ triggers:
5
+ - "what plugins are installed"
6
+ - "weavetab plugin"
7
+ - "extend mcp"
8
+ - "plugin tools"
9
+ - "plugin permissions"
10
+ tools: []
11
+ weavetab: ">=2.5.0-beta.5"
12
+ ---
13
+
14
+ # Plugin Runtime: Weavetab Plugin Architecture
15
+
16
+ Weavetab features an extensible plugin architecture powered by `@weavetab/sdk`. All installed plugins are loaded automatically at server startup — their tools appear directly in the MCP tool list alongside built-in tools. Agents never need to discover or activate plugins manually.
17
+
18
+ ---
19
+
20
+ ## 1. How Plugin Tools Appear
21
+
22
+ Plugin tools are first-class MCP tools. If `@weavetab/plugin-recaptcha-solver` is installed, `captcha_solve_token` appears in the tool list immediately on startup — no discovery step needed.
23
+
24
+ There are **no** `list_plugins` or `load_plugin` tools. Managing plugins is a CLI operation:
25
+
26
+ ```bash
27
+ # Install a plugin (restart required)
28
+ weavetab plugin add @weavetab/plugin-youtube
29
+
30
+ # Remove a plugin
31
+ weavetab plugin rm @weavetab/plugin-youtube
32
+
33
+ # List installed plugins
34
+ weavetab plugin list
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 2. Plugin Permission Model
40
+
41
+ Every plugin declares what it can do in `weavetab.json`. The runtime enforces this at load time:
42
+
43
+ | Permission | What it gates |
44
+ |---|---|
45
+ | `tools.add: true` | Plugin can register new MCP tools |
46
+ | `tools.override: ["browser_navigate"]` | Plugin can wrap/replace that built-in tool |
47
+ | `tools.remove: ["browser_pdf"]` | Plugin can disable that built-in tool |
48
+ | `hooks.onBeforeAction: true` | Plugin can intercept all tool calls before execution |
49
+ | `hooks.onAfterAction: true` | Plugin can inspect/transform all tool results |
50
+
51
+ Plugins that attempt to exceed their declared permissions are blocked with a stderr warning — they do not crash.
52
+
53
+ ---
54
+
55
+ ## 3. Trust Tiers
56
+
57
+ | Tier | Badge | Condition |
58
+ |---|---|---|
59
+ | Official | `✚ [Official]` | `@weavetab/plugin-*` packages |
60
+ | Verified | `✔ [Verified]` | Listed in the Weavetab verified registry |
61
+ | Unverified | `⚠ [Unverified]` | Unknown community package |
62
+
63
+ Unverified plugins are loaded but their permissions are logged visibly at startup for user review.
@@ -0,0 +1,67 @@
1
+ ---
2
+ id: loop-breaker
3
+ domain: resilience
4
+ triggers:
5
+ - "loop detected"
6
+ - "stuck in loop"
7
+ - "reset loop counter"
8
+ - "captcha detected"
9
+ - "hcaptcha"
10
+ - "recaptcha"
11
+ tools:
12
+ - "browser_map"
13
+ - "browser_console"
14
+ - "browser_captcha"
15
+ weavetab: ">=2.5.0-beta.5"
16
+ ---
17
+
18
+ # Loop Breaker & CAPTCHA Escalation Protocol
19
+
20
+ Agents can get trapped in repetitive click loops when a button does not advance the state (e.g. failing silent validation, unhandled reCAPTCHA challenges, or modals swallowing events). Weavetab actively monitors repetitive patterns and provides circuit breakers.
21
+
22
+ ---
23
+
24
+ ## 1. Loop Detection & Strike Reset (`browser_map`)
25
+
26
+ Weavetab tracks the sequence of identical or near-identical tool invocations. If an agent calls `browser_click` or `browser_type` on the same selector or ref repeatedly without URL or major DOM mutations, the server raises a `STUCK_LOOP_WARNING`.
27
+
28
+ ### How to Break the Loop:
29
+ 1. **Analyze Why the Action Failed**: Check `browser_console` for JavaScript errors:
30
+ ```json
31
+ { "action": "read" }
32
+ ```
33
+ Or use `browser_map` to see if a validation banner or unhandled modal appeared.
34
+ 2. **Reset the Circuit Breaker**:
35
+ - Re-map with `force: true` to bypass the map skip guard, refresh the DOM view, and automatically clear loop strikes:
36
+ ```json
37
+ { "force": true }
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 2. CAPTCHA Handling Protocol (`browser_captcha`)
43
+
44
+ When an automated flow is blocked by Cloudflare Turnstile, Google reCAPTCHA, or hCaptcha, do NOT repeatedly click random coordinates.
45
+
46
+ Invoke `browser_captcha` to analyze and manage the challenge:
47
+
48
+ ```json
49
+ {
50
+ "action": "detect"
51
+ }
52
+ ```
53
+
54
+ ### Response Example:
55
+ ```json
56
+ {
57
+ "detected": true,
58
+ "type": "turnstile",
59
+ "provider": "cloudflare",
60
+ "interactive": true,
61
+ "ref": "w:99"
62
+ }
63
+ ```
64
+
65
+ ### Action Strategy:
66
+ 1. If the challenge is interactive and requires human intervention (e.g. image classification), inform the user cleanly or request human bypass.
67
+ 2. If the challenge is a simple checkbox Turnstile widget, pass `"action": "solve"` or click the detected widget ref with `browser_click`.
@@ -0,0 +1,131 @@
1
+ ---
2
+ id: session-time-travel
3
+ domain: resilience
4
+ triggers:
5
+ - "time travel"
6
+ - "browser checkpoint"
7
+ - "rollback session"
8
+ - "save state"
9
+ - "restore cookies"
10
+ tools:
11
+ - "browser_checkpoint"
12
+ - "browser_cookies"
13
+ - "browser_storage"
14
+ weavetab: ">=2.5.0-beta.5"
15
+ ---
16
+
17
+ # Session Time-Travel & Instant State Rollback
18
+
19
+ In complex multi-step workflows (e.g. checkout funnels, multi-page configuration wizards, onboarding questionnaires), an error at Step 7 traditionally forces an agent to reload the root URL, re-authenticate, and waste 10+ turns repeating steps.
20
+
21
+ `browser_checkpoint` enables instantaneous time-travel by snapshotting and restoring complete browser session state.
22
+
23
+ ---
24
+
25
+ ## 1. What a Checkpoint Captures
26
+
27
+ A single named checkpoint atomically preserves:
28
+ - **Cookies**: Full domain cookies including `HttpOnly`, `Secure`, and `SameSite` flags.
29
+ - **Web Storage**: Entire `localStorage` and `sessionStorage` key-value maps.
30
+ - **Navigation State**: Exact page URL, scroll positions (`x`, `y`), and page title.
31
+
32
+ ---
33
+
34
+ ## 2. Checkpoint Operations
35
+
36
+ ### A. Saving a Checkpoint (`save`)
37
+ Create a checkpoint right before undertaking risky, branching, or destructive actions:
38
+
39
+ ```json
40
+ {
41
+ "action": "save",
42
+ "name": "pre_checkout_authenticated"
43
+ }
44
+ ```
45
+
46
+ ### B. Restoring a Checkpoint (`restore`)
47
+ If a downstream step errors out, times out, or hits an invalid state, roll back immediately:
48
+
49
+ ```json
50
+ {
51
+ "action": "restore",
52
+ "name": "pre_checkout_authenticated"
53
+ }
54
+ ```
55
+ *Latency: ~15ms*. The page navigates back to the checkpoint URL with cookies and storage atomically injected.
56
+
57
+ ### C. Listing Checkpoints (`list`)
58
+ Inspect all active checkpoints for the current page target:
59
+
60
+ ```json
61
+ {
62
+ "action": "list"
63
+ }
64
+ ```
65
+
66
+ ### D. Cleaning Up (`delete`)
67
+ Free memory once a workflow has concluded:
68
+
69
+ ```json
70
+ {
71
+ "action": "delete",
72
+ "name": "pre_checkout_authenticated"
73
+ }
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 3. High-Leverage Agent Pattern
79
+
80
+ ```
81
+ 1. Authenticate to Target Portal
82
+ 2. browser_checkpoint({ action: "save", name: "auth_ready" })
83
+ 3. Attempt automated action sequence (e.g. form filling or testing)
84
+ 4. IF error occurs:
85
+ browser_checkpoint({ action: "restore", name: "auth_ready" })
86
+ -> Agent is immediately back at authenticated state without re-login!
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 4. Fine-Grained Cookie Management (`browser_cookies`)
92
+
93
+ Inspect, set, or delete individual browser session cookies without restoring an entire checkpoint:
94
+
95
+ ```json
96
+ {
97
+ "action": "get",
98
+ "urls": ["https://example.com"]
99
+ }
100
+ ```
101
+
102
+ Or inject an authentication cookie:
103
+ ```json
104
+ {
105
+ "action": "set",
106
+ "cookies": [
107
+ {
108
+ "name": "session_token",
109
+ "value": "xyz123",
110
+ "domain": "example.com",
111
+ "httpOnly": true,
112
+ "secure": true
113
+ }
114
+ ]
115
+ }
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 5. Web Storage Inspection & Injection (`browser_storage`)
121
+
122
+ Query or clear `localStorage` and `sessionStorage` keys:
123
+
124
+ ```json
125
+ {
126
+ "storageType": "localStorage",
127
+ "action": "get",
128
+ "key": "authToken"
129
+ }
130
+ ```
131
+
@@ -0,0 +1,53 @@
1
+ ---
2
+ id: stale-ref-recovery
3
+ domain: resilience
4
+ triggers:
5
+ - "stale element reference"
6
+ - "detached from dom"
7
+ - "spa re-render"
8
+ - "react hydration"
9
+ - "element not found"
10
+ tools:
11
+ - "browser_find"
12
+ - "browser_map"
13
+ - "browser_click"
14
+ weavetab: ">=2.5.0-beta.5"
15
+ ---
16
+
17
+ # Stale Ref Recovery & SPA Hydration Resilience
18
+
19
+ In modern Single Page Applications (built with React, Next.js, Vue, Nuxt, Svelte), DOM nodes are frequently destroyed and recreated during client-side hydration or reactive state updates. This often causes `STALE_ELEMENT_REFERENCE` or `NODE_DETACHED` errors when an agent attempts an action.
20
+
21
+ ---
22
+
23
+ ## 1. The 4-Tier Auto-Recovery Chain
24
+
25
+ When a tool receives a stale or missing `ref`, Weavetab does not immediately fail. It activates an internal 4-tier recovery chain:
26
+
27
+ ```
28
+ [Action on w:14 Fails / Stale]
29
+ │
30
+ ▼
31
+ [Tier 1: Stored Selector] ──▶ Re-queries cached stable selector (data-testid, id)
32
+ │ (if not found)
33
+ ▼
34
+ [Tier 2: Exact Label Match] ──▶ Queries element with identical visible text & tag
35
+ │ (if not found)
36
+ ▼
37
+ [Tier 3: Semantic Role Match] ──▶ Queries nearest sibling with matching ARIA role
38
+ │ (if not found)
39
+ ▼
40
+ [Tier 4: Fuzzy Match] ──▶ Re-anchors to highest-confidence visual candidate
41
+ ```
42
+
43
+ If the recovery chain succeeds, the action executes seamlessly and the return payload notifies the agent that the handle was refreshed.
44
+
45
+ ---
46
+
47
+ ## 2. Agent Reactive Behavior
48
+
49
+ If an action returns `ERROR: STALE_ELEMENT_REFERENCE` because all 4 recovery tiers were exhausted:
50
+
51
+ 1. **Do NOT Repeat the Identical Call**: Retrying the exact same stale `ref` (`w:14`) will fail again.
52
+ 2. **Execute a Fast Targeted Lookup**: Run `browser_find` with the text of the button or input field.
53
+ 3. **Execute the Action on the New Handle**: Use the updated handle returned by `browser_find`.