@weavetab/mcp 2.5.0-beta.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.md +48 -0
- package/ARCHITECTURE.md +590 -0
- package/LICENSE +631 -0
- package/README.md +909 -0
- package/SECURITY.md +196 -0
- package/TROUBLESHOOTING.md +365 -0
- package/dist/anticaptcha/detector.d.ts +49 -0
- package/dist/anticaptcha/detector.js +465 -0
- package/dist/anticaptcha/integration.d.ts +36 -0
- package/dist/anticaptcha/integration.js +123 -0
- package/dist/anticaptcha/solver.d.ts +27 -0
- package/dist/anticaptcha/solver.js +552 -0
- package/dist/audit/logger.d.ts +13 -0
- package/dist/audit/logger.js +177 -0
- package/dist/audit/telemetry.d.ts +36 -0
- package/dist/audit/telemetry.js +162 -0
- package/dist/cdp/bridge.d.ts +16 -0
- package/dist/cdp/bridge.js +826 -0
- package/dist/cdp/confirm.d.ts +26 -0
- package/dist/cdp/confirm.js +79 -0
- package/dist/cdp/connector.d.ts +37 -0
- package/dist/cdp/connector.js +661 -0
- package/dist/cdp/extension.d.ts +36 -0
- package/dist/cdp/extension.js +118 -0
- package/dist/cdp/finder.d.ts +1 -0
- package/dist/cdp/finder.js +2 -0
- package/dist/cdp/helpers.d.ts +11 -0
- package/dist/cdp/helpers.js +195 -0
- package/dist/cdp/label_cache.d.ts +12 -0
- package/dist/cdp/label_cache.js +51 -0
- package/dist/cdp/lock.d.ts +33 -0
- package/dist/cdp/lock.js +206 -0
- package/dist/cdp/omni_broker.d.ts +17 -0
- package/dist/cdp/omni_broker.js +119 -0
- package/dist/cdp/profiles.d.ts +1 -0
- package/dist/cdp/profiles.js +87 -0
- package/dist/cdp/pruner.d.ts +41 -0
- package/dist/cdp/pruner.js +263 -0
- package/dist/cdp/ref_cache.d.ts +101 -0
- package/dist/cdp/ref_cache.js +234 -0
- package/dist/cdp/retry.d.ts +5 -0
- package/dist/cdp/retry.js +39 -0
- package/dist/cdp/retry_enhanced.d.ts +44 -0
- package/dist/cdp/retry_enhanced.js +102 -0
- package/dist/cdp/security.d.ts +50 -0
- package/dist/cdp/security.js +237 -0
- package/dist/cdp/verify.d.ts +39 -0
- package/dist/cdp/verify.js +143 -0
- package/dist/cdp/walker.d.ts +91 -0
- package/dist/cdp/walker.js +896 -0
- package/dist/cdp/walker.test.d.ts +2 -0
- package/dist/cdp/walker.test.js +172 -0
- package/dist/cdp/websocket_transport.d.ts +15 -0
- package/dist/cdp/websocket_transport.js +118 -0
- package/dist/cli/plugin.d.ts +9 -0
- package/dist/cli/plugin.js +1134 -0
- package/dist/cli/updater.d.ts +1 -0
- package/dist/cli/updater.js +72 -0
- package/dist/config/loader.d.ts +120 -0
- package/dist/config/loader.js +704 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1248 -0
- package/dist/intelligence/hints.d.ts +11 -0
- package/dist/intelligence/hints.js +39 -0
- package/dist/intelligence/intent.d.ts +33 -0
- package/dist/intelligence/intent.js +171 -0
- package/dist/intelligence/sessionMemory.d.ts +66 -0
- package/dist/intelligence/sessionMemory.js +284 -0
- package/dist/intelligence/sessionMemory.test.d.ts +2 -0
- package/dist/intelligence/sessionMemory.test.js +62 -0
- package/dist/intelligence/trail.d.ts +64 -0
- package/dist/intelligence/trail.js +233 -0
- package/dist/intelligence/trail.test.d.ts +2 -0
- package/dist/intelligence/trail.test.js +110 -0
- package/dist/intelligence/vision.d.ts +24 -0
- package/dist/intelligence/vision.js +151 -0
- package/dist/lifecycle/mission_manager.d.ts +16 -0
- package/dist/lifecycle/mission_manager.js +44 -0
- package/dist/overlay/bubble.d.ts +16 -0
- package/dist/overlay/bubble.js +37 -0
- package/dist/overlay/ghost.d.ts +35 -0
- package/dist/overlay/ghost.js +508 -0
- package/dist/overlay/injector.d.ts +22 -0
- package/dist/overlay/injector.js +198 -0
- package/dist/plugin/interface.d.ts +134 -0
- package/dist/plugin/interface.js +1 -0
- package/dist/plugin/loader.d.ts +18 -0
- package/dist/plugin/loader.js +155 -0
- package/dist/plugin/registry.d.ts +50 -0
- package/dist/plugin/registry.js +234 -0
- package/dist/security/blacklist.d.ts +24 -0
- package/dist/security/blacklist.js +80 -0
- package/dist/security/filter.d.ts +2 -0
- package/dist/security/filter.js +20 -0
- package/dist/security/guard.d.ts +8 -0
- package/dist/security/guard.js +35 -0
- package/dist/security/ratelimit.d.ts +11 -0
- package/dist/security/ratelimit.js +57 -0
- package/dist/security/secrets.d.ts +75 -0
- package/dist/security/secrets.js +365 -0
- package/dist/sensors/actionability.d.ts +81 -0
- package/dist/sensors/actionability.js +303 -0
- package/dist/sensors/guard.d.ts +25 -0
- package/dist/sensors/guard.js +168 -0
- package/dist/sensors/mutations.d.ts +23 -0
- package/dist/sensors/mutations.js +93 -0
- package/dist/sensors/network.d.ts +67 -0
- package/dist/sensors/network.js +193 -0
- package/dist/sensors/operation_monitor.d.ts +80 -0
- package/dist/sensors/operation_monitor.js +203 -0
- package/dist/sensors/pacing.d.ts +44 -0
- package/dist/sensors/pacing.js +111 -0
- package/dist/sensors/thoughts.d.ts +2 -0
- package/dist/sensors/thoughts.js +59 -0
- package/dist/sensors/wait.d.ts +12 -0
- package/dist/sensors/wait.js +44 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +1687 -0
- package/dist/state/agent.d.ts +36 -0
- package/dist/state/agent.js +101 -0
- package/dist/state/cache.d.ts +16 -0
- package/dist/state/cache.js +92 -0
- package/dist/state/cache.test.d.ts +2 -0
- package/dist/state/cache.test.js +76 -0
- package/dist/state/delta.d.ts +71 -0
- package/dist/state/delta.js +234 -0
- package/dist/state/delta.test.d.ts +2 -0
- package/dist/state/delta.test.js +279 -0
- package/dist/state/groups.d.ts +15 -0
- package/dist/state/groups.js +80 -0
- package/dist/state/session.d.ts +30 -0
- package/dist/state/session.js +155 -0
- package/dist/tools/accessibility.d.ts +14 -0
- package/dist/tools/accessibility.js +32 -0
- package/dist/tools/ask.d.ts +14 -0
- package/dist/tools/ask.js +49 -0
- package/dist/tools/automation.d.ts +36 -0
- package/dist/tools/automation.js +218 -0
- package/dist/tools/browser_detect.d.ts +13 -0
- package/dist/tools/browser_detect.js +73 -0
- package/dist/tools/burst.d.ts +35 -0
- package/dist/tools/burst.js +344 -0
- package/dist/tools/canvas.d.ts +25 -0
- package/dist/tools/canvas.js +132 -0
- package/dist/tools/captcha.d.ts +38 -0
- package/dist/tools/captcha.js +209 -0
- package/dist/tools/click.d.ts +36 -0
- package/dist/tools/click.js +561 -0
- package/dist/tools/click_and_wait.d.ts +33 -0
- package/dist/tools/click_and_wait.js +149 -0
- package/dist/tools/clipboard.d.ts +29 -0
- package/dist/tools/clipboard.js +279 -0
- package/dist/tools/console.d.ts +21 -0
- package/dist/tools/console.js +107 -0
- package/dist/tools/cookies.d.ts +67 -0
- package/dist/tools/cookies.js +121 -0
- package/dist/tools/design_extract.d.ts +109 -0
- package/dist/tools/design_extract.js +641 -0
- package/dist/tools/dialog.d.ts +24 -0
- package/dist/tools/dialog.js +109 -0
- package/dist/tools/drag.d.ts +15 -0
- package/dist/tools/drag.js +29 -0
- package/dist/tools/emulation.d.ts +33 -0
- package/dist/tools/emulation.js +69 -0
- package/dist/tools/eval.d.ts +20 -0
- package/dist/tools/eval.js +92 -0
- package/dist/tools/fill.d.ts +41 -0
- package/dist/tools/fill.js +667 -0
- package/dist/tools/find.d.ts +30 -0
- package/dist/tools/find.js +60 -0
- package/dist/tools/geo.d.ts +19 -0
- package/dist/tools/geo.js +29 -0
- package/dist/tools/github/analyze.d.ts +4 -0
- package/dist/tools/github/analyze.js +113 -0
- package/dist/tools/github/cache.d.ts +21 -0
- package/dist/tools/github/cache.js +28 -0
- package/dist/tools/github/index.d.ts +4 -0
- package/dist/tools/github/index.js +4 -0
- package/dist/tools/github/issues.d.ts +9 -0
- package/dist/tools/github/issues.js +88 -0
- package/dist/tools/github/pr.d.ts +5 -0
- package/dist/tools/github/pr.js +88 -0
- package/dist/tools/github/rateLimiter.d.ts +4 -0
- package/dist/tools/github/rateLimiter.js +46 -0
- package/dist/tools/github/read.d.ts +34 -0
- package/dist/tools/github/read.js +74 -0
- package/dist/tools/github/repoContext.d.ts +20 -0
- package/dist/tools/github/repoContext.js +129 -0
- package/dist/tools/highlight.d.ts +20 -0
- package/dist/tools/highlight.js +140 -0
- package/dist/tools/hover.d.ts +19 -0
- package/dist/tools/hover.js +57 -0
- package/dist/tools/inspect.d.ts +17 -0
- package/dist/tools/inspect.js +125 -0
- package/dist/tools/integration.test.d.ts +2 -0
- package/dist/tools/integration.test.js +96 -0
- package/dist/tools/key.d.ts +25 -0
- package/dist/tools/key.js +173 -0
- package/dist/tools/macro_compiler.d.ts +7 -0
- package/dist/tools/macro_compiler.js +82 -0
- package/dist/tools/mouse.d.ts +21 -0
- package/dist/tools/mouse.js +62 -0
- package/dist/tools/navigate.d.ts +16 -0
- package/dist/tools/navigate.js +188 -0
- package/dist/tools/network_intercept.d.ts +17 -0
- package/dist/tools/network_intercept.js +151 -0
- package/dist/tools/office/index.d.ts +9 -0
- package/dist/tools/office/index.js +7 -0
- package/dist/tools/office/list.d.ts +15 -0
- package/dist/tools/office/list.js +41 -0
- package/dist/tools/office/parse.d.ts +20 -0
- package/dist/tools/office/parse.js +172 -0
- package/dist/tools/pdf.d.ts +22 -0
- package/dist/tools/pdf.js +42 -0
- package/dist/tools/performance.d.ts +12 -0
- package/dist/tools/performance.js +47 -0
- package/dist/tools/performance_test.d.ts +70 -0
- package/dist/tools/performance_test.js +128 -0
- package/dist/tools/plan.d.ts +39 -0
- package/dist/tools/plan.js +161 -0
- package/dist/tools/pointer.d.ts +35 -0
- package/dist/tools/pointer.js +522 -0
- package/dist/tools/read.d.ts +30 -0
- package/dist/tools/read.js +488 -0
- package/dist/tools/recording.d.ts +45 -0
- package/dist/tools/recording.js +124 -0
- package/dist/tools/response.d.ts +129 -0
- package/dist/tools/response.js +5 -0
- package/dist/tools/scrape.d.ts +24 -0
- package/dist/tools/scrape.js +140 -0
- package/dist/tools/screenshot.d.ts +40 -0
- package/dist/tools/screenshot.js +79 -0
- package/dist/tools/scroll.d.ts +23 -0
- package/dist/tools/scroll.js +196 -0
- package/dist/tools/select.d.ts +13 -0
- package/dist/tools/select.js +217 -0
- package/dist/tools/snapshot.d.ts +27 -0
- package/dist/tools/snapshot.js +99 -0
- package/dist/tools/storage.d.ts +18 -0
- package/dist/tools/storage.js +29 -0
- package/dist/tools/tabs.d.ts +77 -0
- package/dist/tools/tabs.js +342 -0
- package/dist/tools/thought.d.ts +16 -0
- package/dist/tools/thought.js +79 -0
- package/dist/tools/type.d.ts +65 -0
- package/dist/tools/type.js +1061 -0
- package/dist/tools/type_secret.d.ts +23 -0
- package/dist/tools/type_secret.js +229 -0
- package/dist/tools/upload.d.ts +19 -0
- package/dist/tools/upload.js +103 -0
- package/dist/tools/video_compiler.d.ts +24 -0
- package/dist/tools/video_compiler.js +199 -0
- package/dist/tools/viewport.d.ts +44 -0
- package/dist/tools/viewport.js +230 -0
- package/dist/tools/wait.d.ts +19 -0
- package/dist/tools/wait.js +202 -0
- package/dist/tools/wait_for.d.ts +23 -0
- package/dist/tools/wait_for.js +30 -0
- package/dist/tools/windows.d.ts +22 -0
- package/dist/tools/windows.js +57 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +12 -0
- package/docs/DEV_MODE.md +68 -0
- package/docs/DOCUMENTATION.md +532 -0
- package/docs/PLUGINS.md +538 -0
- package/docs/TOOLS.md +104 -0
- package/docs/dev_plugin.md +310 -0
- package/ext-dist/background.js +467 -0
- package/ext-dist/content.js +3089 -0
- package/ext-dist/dashboard.html +583 -0
- package/ext-dist/hud/hud.js +73 -0
- package/ext-dist/hud/index.html +20 -0
- package/ext-dist/manifest.json +77 -0
- package/ext-dist/sidepanel/sidepanel.js +25 -0
- package/ext-dist/sidepanel.html +547 -0
- package/ext-dist/styles.css +218 -0
- package/icon.png +0 -0
- package/mcp.json +796 -0
- package/package.json +113 -0
- package/server.json +23 -0
- package/smithery.yaml +11 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Weavetab Plugin Developer Guide: Build from Scratch
|
|
2
|
+
|
|
3
|
+
Welcome to the **Weavetab Plugin Developer Guide**. This comprehensive guide teaches you how to build, test, validate, and publish an enterprise-grade Model Context Protocol (MCP) plugin for the **Weavetab** browser automation runtime.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Architecture Overview
|
|
8
|
+
|
|
9
|
+
Weavetab plugins extend the capabilities of AI coding assistants (like Antigravity, Claude, Gemini, Cursor) by exposing specialized browser automation tools, DOM inspection scripts, and API connectors.
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
flowchart LR
|
|
13
|
+
AI["AI Agent\n(Claude / Gemini / Antigravity)"] <-->|MCP Protocol| WT["Weavetab MCP Runtime"]
|
|
14
|
+
WT <-->|Dynamic Plugins| P["Your Plugin\n(@org/my-plugin)"]
|
|
15
|
+
P <-->|CDP Session| Chrome["Active Chrome Tab\n(DOM / Telemetry)"]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Key Plugin Capabilities:
|
|
19
|
+
1. **Expose MCP Tools**: Define custom tools with TypeScript parameter schemas.
|
|
20
|
+
2. **Execute In-Browser JavaScript**: Evaluate live DOM scripts via Chrome DevTools Protocol (CDP).
|
|
21
|
+
3. **Automate User Actions**: Click elements, inspect stylesheets, extract structured data, or interact with web apps.
|
|
22
|
+
4. **Zero Configuration**: Zero-friction distribution via standard NPM packages.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. Quickstart: 3-Minute Plugin Creation
|
|
27
|
+
|
|
28
|
+
The fastest way to start is with the interactive Weavetab CLI wizard:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1. Initialize a new plugin directory
|
|
32
|
+
mkdir my-tab-plugin && cd my-tab-plugin
|
|
33
|
+
|
|
34
|
+
# 2. Run the interactive scaffolding wizard
|
|
35
|
+
npx weavetab init
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The CLI wizard will prompt you for:
|
|
39
|
+
- **Package Identifier**: e.g., `@myorg/wt-plugin` or `wt-plugin`
|
|
40
|
+
- **Display Name**: e.g., `Tab Inspector`
|
|
41
|
+
- **Description**: A short summary of your plugin's capabilities
|
|
42
|
+
- **Author Handle / URL**: Your name, GitHub handle (e.g. `username`), or NPM profile
|
|
43
|
+
- **Author Role**: Any custom title $\ge 3$ characters (e.g. `Creator`, `Maintainer`, `Lead Architect`)
|
|
44
|
+
- **Template Architecture**:
|
|
45
|
+
- `CDP Browser Automation`: Evaluates DOM scripts and automates browser actions
|
|
46
|
+
- `External API Connector`: Exposes specialized MCP data tools
|
|
47
|
+
- `Minimal Starter`: Clean, barebones TypeScript scaffold
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 3. Project File Tree Breakdown
|
|
52
|
+
|
|
53
|
+
After running `weavetab init`, your project contains a production-ready structure:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
my-tab-plugin/
|
|
57
|
+
├── src/
|
|
58
|
+
│ └── index.ts # Plugin logic and MCP tool definitions
|
|
59
|
+
├── images/
|
|
60
|
+
│ ├── logo.svg # Plugin logo (displayed in marketplace)
|
|
61
|
+
│ └── banner.svg # Marketplace header banner
|
|
62
|
+
├── test/
|
|
63
|
+
│ └── plugin.test.js # Unit test suite
|
|
64
|
+
├── package.json # Standard NPM package manifest
|
|
65
|
+
├── tsconfig.json # Strict TypeScript compiler configuration
|
|
66
|
+
├── weavetab.json # Weavetab MCP security manifest
|
|
67
|
+
└── README.md # Documentation with live tools table
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 4. Understanding `weavetab.json`
|
|
73
|
+
|
|
74
|
+
The `weavetab.json` file serves as the plugin's metadata, capability specification, and security contract.
|
|
75
|
+
|
|
76
|
+
### Example Manifest:
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"$schema": "https://weavetab.dev/schema/plugin.json",
|
|
80
|
+
"name": "Tab Inspector",
|
|
81
|
+
"version": "1.0.0",
|
|
82
|
+
"description": "Inspects live DOM telemetry and active tab metadata.",
|
|
83
|
+
"authors": [
|
|
84
|
+
{
|
|
85
|
+
"name": "Alex River",
|
|
86
|
+
"role": "Lead Architect",
|
|
87
|
+
"url": "https://github.com/alexriver"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"logo": "images/logo.svg",
|
|
91
|
+
"banner": "images/banner.svg",
|
|
92
|
+
"license": "MIT",
|
|
93
|
+
"tags": ["Automation", "Developer Tools", "MCP", "CDP"],
|
|
94
|
+
"compatibility": {
|
|
95
|
+
"weavetab": "^2.5.0",
|
|
96
|
+
"node": ">=18.0.0"
|
|
97
|
+
},
|
|
98
|
+
"permissions": {
|
|
99
|
+
"network": {
|
|
100
|
+
"domains": ["*"],
|
|
101
|
+
"reason": "Required to inspect web tabs and telemetry."
|
|
102
|
+
},
|
|
103
|
+
"cdp": {
|
|
104
|
+
"evaluate": true,
|
|
105
|
+
"click": true,
|
|
106
|
+
"reason": "Evaluates DOM scripts and queries tab metadata via Chrome DevTools Protocol."
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"tools": [
|
|
110
|
+
{
|
|
111
|
+
"name": "inspect_tab",
|
|
112
|
+
"description": "Inspects live DOM telemetry and active tab properties.",
|
|
113
|
+
"inputSchema": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"properties": {
|
|
116
|
+
"query": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"description": "Optional CSS selector or keyword filter."
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Manifest Fields Reference:
|
|
128
|
+
|
|
129
|
+
| Field | Type | Rules & Validation | Description |
|
|
130
|
+
| :--- | :--- | :--- | :--- |
|
|
131
|
+
| `name` | `string` | Required, non-empty | Human-readable plugin name. |
|
|
132
|
+
| `version` | `string` | Required, SemVer format | Semantic version (e.g. `1.0.0`). |
|
|
133
|
+
| `description` | `string` | Recommended $\ge 10$ chars | Overview shown on the registry. |
|
|
134
|
+
| `authors` | `array` | At least 1 author | List of maintainers and creators. |
|
|
135
|
+
| `authors[].name` | `string` | Required ($\ge 2$ chars) | Name or handle. |
|
|
136
|
+
| `authors[].role` | `string` | Custom ($\ge 3$ chars) | Any title (e.g. `Creator`, `Maintainer`, `Core Contributor`). |
|
|
137
|
+
| `authors[].url` | `string` | Optional (HTTP/HTTPS) | Profile URL (GitHub or NPM handle for auto avatar). |
|
|
138
|
+
| `authors[].avatar` | `string` | Optional | Custom image fallback if profile URL is omitted. |
|
|
139
|
+
| `compatibility` | `object` | `weavetab` and `node` | Environment runtime semver range. |
|
|
140
|
+
| `permissions` | `object` | Requires `reason` | Security declarations explaining access needs. |
|
|
141
|
+
| `tools` | `array` | Alphanumeric tool names | List of exposed MCP tools. |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 5. Writing MCP Tools in TypeScript (`src/index.ts`)
|
|
146
|
+
|
|
147
|
+
Inside `src/index.ts`, define your tools and export the `plugin` object:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
export interface WeavetabSession {
|
|
151
|
+
evaluate<T = any>(script: string): Promise<T>;
|
|
152
|
+
click?(selector: string): Promise<any>;
|
|
153
|
+
navigate?(url: string): Promise<any>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface PluginToolArgs {
|
|
157
|
+
selector?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface WeavetabPluginTool {
|
|
161
|
+
name: string;
|
|
162
|
+
description: string;
|
|
163
|
+
schema?: Record<string, any>;
|
|
164
|
+
handler: (args: PluginToolArgs, session?: WeavetabSession, config?: any) => Promise<any>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface WeavetabPluginDefinition {
|
|
168
|
+
name: string;
|
|
169
|
+
version: string;
|
|
170
|
+
description: string;
|
|
171
|
+
tools: WeavetabPluginTool[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const plugin: WeavetabPluginDefinition = {
|
|
175
|
+
name: "tab-inspector",
|
|
176
|
+
version: "1.0.0",
|
|
177
|
+
description: "Inspects live DOM telemetry and active tab metadata.",
|
|
178
|
+
tools: [
|
|
179
|
+
{
|
|
180
|
+
name: "inspect_elements",
|
|
181
|
+
description: "Extracts title, URL, and matching DOM elements from the active tab.",
|
|
182
|
+
schema: {
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
selector: {
|
|
186
|
+
type: "string",
|
|
187
|
+
description: "Optional CSS selector to query elements on the page."
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
handler: async (args: PluginToolArgs, session?: WeavetabSession) => {
|
|
192
|
+
if (!session || typeof session.evaluate !== "function") {
|
|
193
|
+
return {
|
|
194
|
+
status: "error",
|
|
195
|
+
error: "No active Chrome DevTools Protocol (CDP) session attached."
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
const result = await session.evaluate(`
|
|
201
|
+
(() => {
|
|
202
|
+
const targetSelector = ${JSON.stringify(args?.selector || "body")};
|
|
203
|
+
const elements = Array.from(document.querySelectorAll(targetSelector)).slice(0, 10);
|
|
204
|
+
return {
|
|
205
|
+
title: document.title,
|
|
206
|
+
url: window.location.href,
|
|
207
|
+
matches: elements.map(el => ({
|
|
208
|
+
tag: el.tagName.toLowerCase(),
|
|
209
|
+
id: el.id || null,
|
|
210
|
+
className: el.className || null,
|
|
211
|
+
text: el.textContent?.trim().substring(0, 100) || ""
|
|
212
|
+
}))
|
|
213
|
+
};
|
|
214
|
+
})()
|
|
215
|
+
`);
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
status: "success",
|
|
219
|
+
data: result
|
|
220
|
+
};
|
|
221
|
+
} catch (err: any) {
|
|
222
|
+
return {
|
|
223
|
+
status: "error",
|
|
224
|
+
error: err.message || String(err)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export default plugin;
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 6. Building & Syncing: `npx weavetab build`
|
|
238
|
+
|
|
239
|
+
Whenever you write or modify tool code, run:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
npx weavetab build
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### What `weavetab build` does:
|
|
246
|
+
1. **TypeScript Compilation**: Compiles `src/` to `dist/index.js` using `tsc`.
|
|
247
|
+
2. **Dynamic Code Introspection**: Reads your exported tools and extracts names, descriptions, and parameter schemas.
|
|
248
|
+
3. **Auto-Manifest Synchronization**: Automatically updates `weavetab.json` with any newly added tools and synced `package.json` versions.
|
|
249
|
+
4. **Validation & Security Audit**:
|
|
250
|
+
- Validates that tool names match `^[a-zA-Z0-9_-]+$`.
|
|
251
|
+
- Ensures author roles are at least 3 characters.
|
|
252
|
+
- Validates SemVer version formatting.
|
|
253
|
+
- Checks that referenced logo and banner files exist on disk.
|
|
254
|
+
- Verifies that permission justifications (`reason`) are provided.
|
|
255
|
+
|
|
256
|
+
### Example Build Output:
|
|
257
|
+
```text
|
|
258
|
+
✔ Built TypeScript source files to dist/.
|
|
259
|
+
✔ Discovered 1 MCP tool(s).
|
|
260
|
+
|
|
261
|
+
╭────────────────────── WEAVETAB PLUGIN BUILD COMPLETED ──────────────────────╮
|
|
262
|
+
│ │
|
|
263
|
+
│ Package: tab-inspector (v1.0.0) │
|
|
264
|
+
│ Entrypoint: dist/index.js │
|
|
265
|
+
│ Permissions: CDP (Browser Automation), Network (*) │
|
|
266
|
+
│ Manifest: weavetab.json (Synced & Validated) │
|
|
267
|
+
│ │
|
|
268
|
+
│ Exposed MCP Tools: │
|
|
269
|
+
│ • inspect_elements - Extracts title, URL, and matching DOM elements │
|
|
270
|
+
│ │
|
|
271
|
+
│ Ready to publish to NPM: │
|
|
272
|
+
│ npm publish --access public │
|
|
273
|
+
╰─────────────────────────────────────────────────────────────────────────────╯
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## 7. Testing Your Plugin
|
|
279
|
+
|
|
280
|
+
Run the included Node.js test suite to verify your tool exports:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
npm test
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
The test runner ensures your entrypoint loads cleanly, exports valid MCP tool signatures, and contains the required properties.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## 8. Publishing & Marketplace Distribution
|
|
291
|
+
|
|
292
|
+
### 1. Publish to NPM
|
|
293
|
+
Weavetab plugins are standard NPM packages:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
npm publish --access public
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### 2. Immediate Community Availability
|
|
300
|
+
Once published to NPM, anyone using Weavetab can install your plugin immediately:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
npx weavetab add <your-package-name>
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### 3. Submitting for Verification (Optional)
|
|
307
|
+
To obtain the **`✔ [Verified]`** badge on the official Weavetab registry:
|
|
308
|
+
1. Open a Pull Request to [weavetab/registry](https://github.com/weavetab/registry).
|
|
309
|
+
2. Add your package name to `verified.json`.
|
|
310
|
+
3. Once merged, your plugin displays the verified badge in both the CLI and online marketplace!
|