@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.
Files changed (281) hide show
  1. package/AGENTS.md +48 -0
  2. package/ARCHITECTURE.md +590 -0
  3. package/LICENSE +631 -0
  4. package/README.md +909 -0
  5. package/SECURITY.md +196 -0
  6. package/TROUBLESHOOTING.md +365 -0
  7. package/dist/anticaptcha/detector.d.ts +49 -0
  8. package/dist/anticaptcha/detector.js +465 -0
  9. package/dist/anticaptcha/integration.d.ts +36 -0
  10. package/dist/anticaptcha/integration.js +123 -0
  11. package/dist/anticaptcha/solver.d.ts +27 -0
  12. package/dist/anticaptcha/solver.js +552 -0
  13. package/dist/audit/logger.d.ts +13 -0
  14. package/dist/audit/logger.js +177 -0
  15. package/dist/audit/telemetry.d.ts +36 -0
  16. package/dist/audit/telemetry.js +162 -0
  17. package/dist/cdp/bridge.d.ts +16 -0
  18. package/dist/cdp/bridge.js +826 -0
  19. package/dist/cdp/confirm.d.ts +26 -0
  20. package/dist/cdp/confirm.js +79 -0
  21. package/dist/cdp/connector.d.ts +37 -0
  22. package/dist/cdp/connector.js +661 -0
  23. package/dist/cdp/extension.d.ts +36 -0
  24. package/dist/cdp/extension.js +118 -0
  25. package/dist/cdp/finder.d.ts +1 -0
  26. package/dist/cdp/finder.js +2 -0
  27. package/dist/cdp/helpers.d.ts +11 -0
  28. package/dist/cdp/helpers.js +195 -0
  29. package/dist/cdp/label_cache.d.ts +12 -0
  30. package/dist/cdp/label_cache.js +51 -0
  31. package/dist/cdp/lock.d.ts +33 -0
  32. package/dist/cdp/lock.js +206 -0
  33. package/dist/cdp/omni_broker.d.ts +17 -0
  34. package/dist/cdp/omni_broker.js +119 -0
  35. package/dist/cdp/profiles.d.ts +1 -0
  36. package/dist/cdp/profiles.js +87 -0
  37. package/dist/cdp/pruner.d.ts +41 -0
  38. package/dist/cdp/pruner.js +263 -0
  39. package/dist/cdp/ref_cache.d.ts +101 -0
  40. package/dist/cdp/ref_cache.js +234 -0
  41. package/dist/cdp/retry.d.ts +5 -0
  42. package/dist/cdp/retry.js +39 -0
  43. package/dist/cdp/retry_enhanced.d.ts +44 -0
  44. package/dist/cdp/retry_enhanced.js +102 -0
  45. package/dist/cdp/security.d.ts +50 -0
  46. package/dist/cdp/security.js +237 -0
  47. package/dist/cdp/verify.d.ts +39 -0
  48. package/dist/cdp/verify.js +143 -0
  49. package/dist/cdp/walker.d.ts +91 -0
  50. package/dist/cdp/walker.js +896 -0
  51. package/dist/cdp/walker.test.d.ts +2 -0
  52. package/dist/cdp/walker.test.js +172 -0
  53. package/dist/cdp/websocket_transport.d.ts +15 -0
  54. package/dist/cdp/websocket_transport.js +118 -0
  55. package/dist/cli/plugin.d.ts +9 -0
  56. package/dist/cli/plugin.js +1134 -0
  57. package/dist/cli/updater.d.ts +1 -0
  58. package/dist/cli/updater.js +72 -0
  59. package/dist/config/loader.d.ts +120 -0
  60. package/dist/config/loader.js +704 -0
  61. package/dist/index.d.ts +2 -0
  62. package/dist/index.js +1248 -0
  63. package/dist/intelligence/hints.d.ts +11 -0
  64. package/dist/intelligence/hints.js +39 -0
  65. package/dist/intelligence/intent.d.ts +33 -0
  66. package/dist/intelligence/intent.js +171 -0
  67. package/dist/intelligence/sessionMemory.d.ts +66 -0
  68. package/dist/intelligence/sessionMemory.js +284 -0
  69. package/dist/intelligence/sessionMemory.test.d.ts +2 -0
  70. package/dist/intelligence/sessionMemory.test.js +62 -0
  71. package/dist/intelligence/trail.d.ts +64 -0
  72. package/dist/intelligence/trail.js +233 -0
  73. package/dist/intelligence/trail.test.d.ts +2 -0
  74. package/dist/intelligence/trail.test.js +110 -0
  75. package/dist/intelligence/vision.d.ts +24 -0
  76. package/dist/intelligence/vision.js +151 -0
  77. package/dist/lifecycle/mission_manager.d.ts +16 -0
  78. package/dist/lifecycle/mission_manager.js +44 -0
  79. package/dist/overlay/bubble.d.ts +16 -0
  80. package/dist/overlay/bubble.js +37 -0
  81. package/dist/overlay/ghost.d.ts +35 -0
  82. package/dist/overlay/ghost.js +508 -0
  83. package/dist/overlay/injector.d.ts +22 -0
  84. package/dist/overlay/injector.js +198 -0
  85. package/dist/plugin/interface.d.ts +134 -0
  86. package/dist/plugin/interface.js +1 -0
  87. package/dist/plugin/loader.d.ts +18 -0
  88. package/dist/plugin/loader.js +155 -0
  89. package/dist/plugin/registry.d.ts +50 -0
  90. package/dist/plugin/registry.js +234 -0
  91. package/dist/security/blacklist.d.ts +24 -0
  92. package/dist/security/blacklist.js +80 -0
  93. package/dist/security/filter.d.ts +2 -0
  94. package/dist/security/filter.js +20 -0
  95. package/dist/security/guard.d.ts +8 -0
  96. package/dist/security/guard.js +35 -0
  97. package/dist/security/ratelimit.d.ts +11 -0
  98. package/dist/security/ratelimit.js +57 -0
  99. package/dist/security/secrets.d.ts +75 -0
  100. package/dist/security/secrets.js +365 -0
  101. package/dist/sensors/actionability.d.ts +81 -0
  102. package/dist/sensors/actionability.js +303 -0
  103. package/dist/sensors/guard.d.ts +25 -0
  104. package/dist/sensors/guard.js +168 -0
  105. package/dist/sensors/mutations.d.ts +23 -0
  106. package/dist/sensors/mutations.js +93 -0
  107. package/dist/sensors/network.d.ts +67 -0
  108. package/dist/sensors/network.js +193 -0
  109. package/dist/sensors/operation_monitor.d.ts +80 -0
  110. package/dist/sensors/operation_monitor.js +203 -0
  111. package/dist/sensors/pacing.d.ts +44 -0
  112. package/dist/sensors/pacing.js +111 -0
  113. package/dist/sensors/thoughts.d.ts +2 -0
  114. package/dist/sensors/thoughts.js +59 -0
  115. package/dist/sensors/wait.d.ts +12 -0
  116. package/dist/sensors/wait.js +44 -0
  117. package/dist/server.d.ts +7 -0
  118. package/dist/server.js +1687 -0
  119. package/dist/state/agent.d.ts +36 -0
  120. package/dist/state/agent.js +101 -0
  121. package/dist/state/cache.d.ts +16 -0
  122. package/dist/state/cache.js +92 -0
  123. package/dist/state/cache.test.d.ts +2 -0
  124. package/dist/state/cache.test.js +76 -0
  125. package/dist/state/delta.d.ts +71 -0
  126. package/dist/state/delta.js +234 -0
  127. package/dist/state/delta.test.d.ts +2 -0
  128. package/dist/state/delta.test.js +279 -0
  129. package/dist/state/groups.d.ts +15 -0
  130. package/dist/state/groups.js +80 -0
  131. package/dist/state/session.d.ts +30 -0
  132. package/dist/state/session.js +155 -0
  133. package/dist/tools/accessibility.d.ts +14 -0
  134. package/dist/tools/accessibility.js +32 -0
  135. package/dist/tools/ask.d.ts +14 -0
  136. package/dist/tools/ask.js +49 -0
  137. package/dist/tools/automation.d.ts +36 -0
  138. package/dist/tools/automation.js +218 -0
  139. package/dist/tools/browser_detect.d.ts +13 -0
  140. package/dist/tools/browser_detect.js +73 -0
  141. package/dist/tools/burst.d.ts +35 -0
  142. package/dist/tools/burst.js +344 -0
  143. package/dist/tools/canvas.d.ts +25 -0
  144. package/dist/tools/canvas.js +132 -0
  145. package/dist/tools/captcha.d.ts +38 -0
  146. package/dist/tools/captcha.js +209 -0
  147. package/dist/tools/click.d.ts +36 -0
  148. package/dist/tools/click.js +561 -0
  149. package/dist/tools/click_and_wait.d.ts +33 -0
  150. package/dist/tools/click_and_wait.js +149 -0
  151. package/dist/tools/clipboard.d.ts +29 -0
  152. package/dist/tools/clipboard.js +279 -0
  153. package/dist/tools/console.d.ts +21 -0
  154. package/dist/tools/console.js +107 -0
  155. package/dist/tools/cookies.d.ts +67 -0
  156. package/dist/tools/cookies.js +121 -0
  157. package/dist/tools/design_extract.d.ts +109 -0
  158. package/dist/tools/design_extract.js +641 -0
  159. package/dist/tools/dialog.d.ts +24 -0
  160. package/dist/tools/dialog.js +109 -0
  161. package/dist/tools/drag.d.ts +15 -0
  162. package/dist/tools/drag.js +29 -0
  163. package/dist/tools/emulation.d.ts +33 -0
  164. package/dist/tools/emulation.js +69 -0
  165. package/dist/tools/eval.d.ts +20 -0
  166. package/dist/tools/eval.js +92 -0
  167. package/dist/tools/fill.d.ts +41 -0
  168. package/dist/tools/fill.js +667 -0
  169. package/dist/tools/find.d.ts +30 -0
  170. package/dist/tools/find.js +60 -0
  171. package/dist/tools/geo.d.ts +19 -0
  172. package/dist/tools/geo.js +29 -0
  173. package/dist/tools/github/analyze.d.ts +4 -0
  174. package/dist/tools/github/analyze.js +113 -0
  175. package/dist/tools/github/cache.d.ts +21 -0
  176. package/dist/tools/github/cache.js +28 -0
  177. package/dist/tools/github/index.d.ts +4 -0
  178. package/dist/tools/github/index.js +4 -0
  179. package/dist/tools/github/issues.d.ts +9 -0
  180. package/dist/tools/github/issues.js +88 -0
  181. package/dist/tools/github/pr.d.ts +5 -0
  182. package/dist/tools/github/pr.js +88 -0
  183. package/dist/tools/github/rateLimiter.d.ts +4 -0
  184. package/dist/tools/github/rateLimiter.js +46 -0
  185. package/dist/tools/github/read.d.ts +34 -0
  186. package/dist/tools/github/read.js +74 -0
  187. package/dist/tools/github/repoContext.d.ts +20 -0
  188. package/dist/tools/github/repoContext.js +129 -0
  189. package/dist/tools/highlight.d.ts +20 -0
  190. package/dist/tools/highlight.js +140 -0
  191. package/dist/tools/hover.d.ts +19 -0
  192. package/dist/tools/hover.js +57 -0
  193. package/dist/tools/inspect.d.ts +17 -0
  194. package/dist/tools/inspect.js +125 -0
  195. package/dist/tools/integration.test.d.ts +2 -0
  196. package/dist/tools/integration.test.js +96 -0
  197. package/dist/tools/key.d.ts +25 -0
  198. package/dist/tools/key.js +173 -0
  199. package/dist/tools/macro_compiler.d.ts +7 -0
  200. package/dist/tools/macro_compiler.js +82 -0
  201. package/dist/tools/mouse.d.ts +21 -0
  202. package/dist/tools/mouse.js +62 -0
  203. package/dist/tools/navigate.d.ts +16 -0
  204. package/dist/tools/navigate.js +188 -0
  205. package/dist/tools/network_intercept.d.ts +17 -0
  206. package/dist/tools/network_intercept.js +151 -0
  207. package/dist/tools/office/index.d.ts +9 -0
  208. package/dist/tools/office/index.js +7 -0
  209. package/dist/tools/office/list.d.ts +15 -0
  210. package/dist/tools/office/list.js +41 -0
  211. package/dist/tools/office/parse.d.ts +20 -0
  212. package/dist/tools/office/parse.js +172 -0
  213. package/dist/tools/pdf.d.ts +22 -0
  214. package/dist/tools/pdf.js +42 -0
  215. package/dist/tools/performance.d.ts +12 -0
  216. package/dist/tools/performance.js +47 -0
  217. package/dist/tools/performance_test.d.ts +70 -0
  218. package/dist/tools/performance_test.js +128 -0
  219. package/dist/tools/plan.d.ts +39 -0
  220. package/dist/tools/plan.js +161 -0
  221. package/dist/tools/pointer.d.ts +35 -0
  222. package/dist/tools/pointer.js +522 -0
  223. package/dist/tools/read.d.ts +30 -0
  224. package/dist/tools/read.js +488 -0
  225. package/dist/tools/recording.d.ts +45 -0
  226. package/dist/tools/recording.js +124 -0
  227. package/dist/tools/response.d.ts +129 -0
  228. package/dist/tools/response.js +5 -0
  229. package/dist/tools/scrape.d.ts +24 -0
  230. package/dist/tools/scrape.js +140 -0
  231. package/dist/tools/screenshot.d.ts +40 -0
  232. package/dist/tools/screenshot.js +79 -0
  233. package/dist/tools/scroll.d.ts +23 -0
  234. package/dist/tools/scroll.js +196 -0
  235. package/dist/tools/select.d.ts +13 -0
  236. package/dist/tools/select.js +217 -0
  237. package/dist/tools/snapshot.d.ts +27 -0
  238. package/dist/tools/snapshot.js +99 -0
  239. package/dist/tools/storage.d.ts +18 -0
  240. package/dist/tools/storage.js +29 -0
  241. package/dist/tools/tabs.d.ts +77 -0
  242. package/dist/tools/tabs.js +342 -0
  243. package/dist/tools/thought.d.ts +16 -0
  244. package/dist/tools/thought.js +79 -0
  245. package/dist/tools/type.d.ts +65 -0
  246. package/dist/tools/type.js +1061 -0
  247. package/dist/tools/type_secret.d.ts +23 -0
  248. package/dist/tools/type_secret.js +229 -0
  249. package/dist/tools/upload.d.ts +19 -0
  250. package/dist/tools/upload.js +103 -0
  251. package/dist/tools/video_compiler.d.ts +24 -0
  252. package/dist/tools/video_compiler.js +199 -0
  253. package/dist/tools/viewport.d.ts +44 -0
  254. package/dist/tools/viewport.js +230 -0
  255. package/dist/tools/wait.d.ts +19 -0
  256. package/dist/tools/wait.js +202 -0
  257. package/dist/tools/wait_for.d.ts +23 -0
  258. package/dist/tools/wait_for.js +30 -0
  259. package/dist/tools/windows.d.ts +22 -0
  260. package/dist/tools/windows.js +57 -0
  261. package/dist/ui/index.d.ts +1 -0
  262. package/dist/ui/index.js +12 -0
  263. package/docs/DEV_MODE.md +68 -0
  264. package/docs/DOCUMENTATION.md +532 -0
  265. package/docs/PLUGINS.md +538 -0
  266. package/docs/TOOLS.md +104 -0
  267. package/docs/dev_plugin.md +310 -0
  268. package/ext-dist/background.js +467 -0
  269. package/ext-dist/content.js +3089 -0
  270. package/ext-dist/dashboard.html +583 -0
  271. package/ext-dist/hud/hud.js +73 -0
  272. package/ext-dist/hud/index.html +20 -0
  273. package/ext-dist/manifest.json +77 -0
  274. package/ext-dist/sidepanel/sidepanel.js +25 -0
  275. package/ext-dist/sidepanel.html +547 -0
  276. package/ext-dist/styles.css +218 -0
  277. package/icon.png +0 -0
  278. package/mcp.json +796 -0
  279. package/package.json +113 -0
  280. package/server.json +23 -0
  281. package/smithery.yaml +11 -0
@@ -0,0 +1,198 @@
1
+ import { logDebug } from "../audit/logger.js";
2
+ import { getConfigVisuals, getConfigDevMode } from "../config/loader.js";
3
+ // ─── Minimal Overlay Script ───────────────────────────────────────────────────
4
+ export function getMinimalOverlayScript() {
5
+ return `(function(){
6
+ 'use strict';
7
+
8
+ // ── Persistent shadow container ────────────────────────────────────────────
9
+ var __wt_sr = null;
10
+ function ec() {
11
+ if (__wt_sr && __wt_sr.host && __wt_sr.host.isConnected) return __wt_sr;
12
+ var h = document.getElementById('Weavetab-root');
13
+ if (h && h.shadowRoot) { __wt_sr = h.shadowRoot; return __wt_sr; }
14
+ if (!h) {
15
+ var root = document.body || document.head || document.documentElement;
16
+ if (root) {
17
+ h = document.createElement('weavetab-host');
18
+ h.id = 'Weavetab-root';
19
+ h.setAttribute('data-wt-ignore', '');
20
+ h.style.cssText = 'all:initial !important;position:fixed !important;left:0 !important;top:0 !important;width:0 !important;height:0 !important;z-index:2147483647 !important;pointer-events:none !important;touch-action:none !important;background:transparent !important;opacity:1 !important;transform:none !important;filter:none !important;';
21
+ root.appendChild(h);
22
+ } else {
23
+ return null;
24
+ }
25
+ }
26
+ __wt_sr = h.shadowRoot || h.attachShadow({ mode: 'open' });
27
+ return __wt_sr;
28
+ }
29
+
30
+ // ── Install ─────────────────────────────────────────────────────────────────
31
+ window.__wt_install_minimal = function() {
32
+ var s = ec();
33
+ if (!s) return false;
34
+ var $ = function(id) { return s.getElementById(id) || document.getElementById(id); };
35
+
36
+ // Cleanup old UI elements (pre-overlay-rewrite)
37
+ var oldEls = ['wt-chat-icon','wt-chat-tooltip','wt-shadow-host','Weavetab-tactical-overlay','wt-ghost-cursor','wt-ghost-bubble','wt-ask-panel','wt-cur-canvas'];
38
+ for (var oi = 0; oi < oldEls.length; oi++) { var oe = document.getElementById(oldEls[oi]); if (oe) oe.remove(); }
39
+
40
+ // SPA navigation
41
+ if (!window.__wt_nav_installed) {
42
+ window.__wt_nav_installed = true;
43
+ var em = function(type, url) {
44
+ window.__wt_nav_event = { type: type, url: url, ts: Date.now() };
45
+ document.dispatchEvent(new CustomEvent('__wt_navigation', { detail: { type: type, url: url } }));
46
+ };
47
+ var ps = history.pushState.bind(history);
48
+ var rs = history.replaceState.bind(history);
49
+ history.pushState = function() { ps.apply(history, arguments); em('pushState', arguments.length > 2 ? arguments[2] : null); };
50
+ history.replaceState = function() { rs.apply(history, arguments); em('replaceState', arguments.length > 2 ? arguments[2] : null); };
51
+ window.addEventListener('popstate', function() { em('popstate', location.href); });
52
+ document.addEventListener('NavigationEnd', function() { em('angular', location.href); });
53
+ }
54
+
55
+ // ── Mission plan dashboard ──────────────────────────────────────────────
56
+ window.__wt_plan_comments = window.__wt_plan_comments || [];
57
+ window.__wt_plan = function(action, goal, tasks) {
58
+ window.postMessage({ type: '__WT_PLAN', action: action, goal: goal, tasks: tasks }, '*');
59
+ };
60
+
61
+ // The message listeners below are guarded so they are registered exactly once
62
+ // per page, even when __wt_install_minimal() is called repeatedly (e.g. SPAs
63
+ // with frequent navigations).
64
+ if (!window.__wt_msg_installed) {
65
+ window.__wt_msg_installed = true;
66
+ window.addEventListener("message", function(e) {
67
+ if (e.data && e.data.type === "__WT_PLAN_COMMENT") {
68
+ window.__wt_plan_comments.push({ taskId: Number(e.data.taskId), comment: e.data.comment, time: Date.now() });
69
+ }
70
+ });
71
+
72
+ window.__wt_chat_queue = window.__wt_chat_queue || [];
73
+ window.addEventListener("message", function(e) {
74
+ if (e.data && e.data.type === "__WT_FEEDBACK") {
75
+ window.__wt_chat_queue.push(e.data.text);
76
+ }
77
+ });
78
+ }
79
+
80
+ window.__wt_setConfig = function(c) {
81
+ if (c && c.devMode) window.__wt_devMode = true;
82
+ if (c && c.visuals !== undefined) window.__wt_showVisuals = !!c.visuals;
83
+ };
84
+
85
+ window.__wt_status = function() { return JSON.stringify({ rootInjected: true }); };
86
+
87
+ // ── Fallback relay (works w/out extension) ───────────────────────
88
+ // Cursor + HUD handled by content.js (extension). This is a no-op relay.
89
+ window.__wt_fallback_handle = function(e) {
90
+ if (window.__Weavetab && window.__Weavetab.version) return;
91
+ };
92
+ window.addEventListener('Weavetab-msg-in', window.__wt_fallback_handle);
93
+
94
+ return true;
95
+ };
96
+
97
+ try {
98
+ if (document.readyState === 'loading') {
99
+ document.addEventListener('DOMContentLoaded', window.__wt_install_minimal);
100
+ } else {
101
+ window.__wt_install_minimal();
102
+ }
103
+ } catch(e) { logDebug('[Weavetab] Overlay init error:', e?.message || e); }
104
+ })();`;
105
+ }
106
+ // ─── Script reinstall expression ─────────────────────────────────────────────
107
+ export const INSTALL_EXPR = `if(window.__wt_install_minimal)window.__wt_install_minimal();`;
108
+ // ─── CDP helpers ──────────────────────────────────────────────────────────────
109
+ async function evalInPage(session, expression) {
110
+ try {
111
+ const result = await session.Runtime.evaluate({
112
+ expression,
113
+ returnByValue: true,
114
+ awaitPromise: false,
115
+ });
116
+ if (result?.exceptionDetails) {
117
+ const ed = result.exceptionDetails;
118
+ logDebug("[Weavetab] Overlay eval error:", ed.text, ed.lineNumber ? `line ${ed.lineNumber}` : '', ed.columnNumber ? `col ${ed.columnNumber}` : '', ed.exception?.description || ed.exception?.value || '');
119
+ if (ed.exception?.description?.includes('TypeError') || ed.exception?.description?.includes('ReferenceError')) {
120
+ logDebug("[Weavetab] Full exception:", ed.exception.description);
121
+ }
122
+ return false;
123
+ }
124
+ return true;
125
+ }
126
+ catch (e) {
127
+ logDebug("[Weavetab] Overlay eval failed:", e instanceof Error ? e.message : e);
128
+ return false;
129
+ }
130
+ }
131
+ function buildConfigExpr(config) {
132
+ const msg = { type: 'Weavetab_CONFIG', devMode: getConfigDevMode(config) };
133
+ return `
134
+ if(window.__wt_setConfig)window.__wt_setConfig(${JSON.stringify({
135
+ ...config,
136
+ visuals: getConfigVisuals(config) !== false,
137
+ })});
138
+ window.postMessage({type:'Weavetab-msg-in',data:${JSON.stringify(msg)}},'*');
139
+ `;
140
+ }
141
+ // ─── Public surface ───────────────────────────────────────────────────────────
142
+ export async function ensureVisualLayer(session, config, client) {
143
+ try {
144
+ // CSP Bypass removed for security reasons
145
+ const minimal = getMinimalOverlayScript();
146
+ if (!client?.overlayScriptId) {
147
+ try {
148
+ const reg = await session.Page.addScriptToEvaluateOnNewDocument({ source: minimal });
149
+ if (client && reg?.identifier) {
150
+ client.overlayScriptId = reg.identifier;
151
+ logDebug(`[Weavetab] [OK] Overlay script registered with ID: ${reg.identifier}`);
152
+ }
153
+ }
154
+ catch (regErr) {
155
+ logDebug(`[Weavetab] [!] Failed to register overlay script: ${regErr}`);
156
+ }
157
+ }
158
+ await evalInPage(session, minimal);
159
+ await evalInPage(session, buildConfigExpr(config));
160
+ if (client)
161
+ client.overlayInstalled = true;
162
+ // Verify overlay was actually injected
163
+ try {
164
+ const { result: checkResult } = await session.Runtime.evaluate({
165
+ expression: `!!document.getElementById('Weavetab-root')`,
166
+ returnByValue: true
167
+ });
168
+ if (checkResult?.value) {
169
+ logDebug(`[Weavetab] [OK] Minimal overlay injected successfully`);
170
+ }
171
+ else {
172
+ logDebug(`[Weavetab] [!] Minimal overlay injection failed - element not found`);
173
+ }
174
+ }
175
+ catch (checkErr) {
176
+ logDebug(`[Weavetab] [!] Could not verify overlay injection: ${checkErr}`);
177
+ }
178
+ }
179
+ catch (overlayErr) {
180
+ logDebug(`[Weavetab] [!] ensureVisualLayer failed: ${overlayErr}`);
181
+ throw overlayErr;
182
+ }
183
+ }
184
+ export async function setupOverlay(session, config) {
185
+ await ensureVisualLayer(session, config);
186
+ }
187
+ export async function setFaviconState(_session, _state) {
188
+ // Handled robustly via extension content.js
189
+ }
190
+ export async function removeTitleBadge(_session) {
191
+ // No-op: title dot prefix removed in favor of favicon indicators
192
+ }
193
+ export async function hideCursor(session) {
194
+ // Cursor lives in content.js — handled via Weavetab_STATE messages
195
+ }
196
+ export async function setCursorState(session, state) {
197
+ await setFaviconState(session, state);
198
+ }
@@ -0,0 +1,134 @@
1
+ import type { z } from "zod";
2
+ import type CDP from "chrome-remote-interface";
3
+ import type { Config } from "../config/loader.js";
4
+ export interface WeavetabToolDefinition {
5
+ name: string;
6
+ description: string;
7
+ schema: Record<string, z.ZodType<any>>;
8
+ handler: (args: Record<string, any>, session: CDP.Client, config: Config) => Promise<Record<string, any>>;
9
+ }
10
+ export interface WeavetabToolOverride {
11
+ /** The name of the built-in tool to override / wrap (e.g. "browser_eval") */
12
+ name: string;
13
+ /** Optional new description (defaults to existing description if omitted) */
14
+ description?: string;
15
+ /** Optional new schema (defaults to existing schema if omitted) */
16
+ schema?: Record<string, z.ZodType<any>>;
17
+ /**
18
+ * New handler. Can optionally call `originalHandler` to wrap or augment behavior.
19
+ */
20
+ handler: (args: Record<string, any>, session: CDP.Client, config: Config, originalHandler?: (args: Record<string, any>, session: CDP.Client, config: Config) => Promise<any>) => Promise<Record<string, any>>;
21
+ }
22
+ export interface WeavetabManifestTool {
23
+ name: string;
24
+ description: string;
25
+ inputSchema?: Record<string, any>;
26
+ }
27
+ export interface WeavetabManifestPermissions {
28
+ network?: {
29
+ domains?: string[];
30
+ intercept?: boolean;
31
+ reason?: string;
32
+ };
33
+ cdp?: {
34
+ evaluate?: boolean;
35
+ navigate?: boolean;
36
+ click?: boolean;
37
+ input?: boolean;
38
+ screenshot?: boolean;
39
+ reason?: string;
40
+ [key: string]: any;
41
+ };
42
+ fs?: {
43
+ read?: string[];
44
+ write?: string[];
45
+ reason?: string;
46
+ };
47
+ tools?: {
48
+ /** List of built-in tool names this plugin is permitted to override */
49
+ override?: string[];
50
+ /** List of built-in tool names this plugin is permitted to remove */
51
+ remove?: string[];
52
+ reason?: string;
53
+ };
54
+ }
55
+ export interface WeavetabManifestAuthor {
56
+ name: string;
57
+ role?: string;
58
+ avatar?: string;
59
+ url?: string;
60
+ }
61
+ export interface WeavetabManifestLinks {
62
+ github?: string;
63
+ npm?: string;
64
+ docs?: string;
65
+ issues?: string;
66
+ homepage?: string;
67
+ }
68
+ export interface WeavetabCompatibility {
69
+ weavetab?: string;
70
+ node?: string;
71
+ }
72
+ export interface WeavetabManifest {
73
+ /** Schema identifier */
74
+ $schema?: string;
75
+ /** Human-readable display name */
76
+ name: string;
77
+ /** Semantic version string */
78
+ version: string;
79
+ /** Short summary of what this plugin provides */
80
+ description?: string;
81
+ /** Single author or multiple authors with roles */
82
+ author?: string | WeavetabManifestAuthor | (string | WeavetabManifestAuthor)[];
83
+ /** Array of authors */
84
+ authors?: (string | WeavetabManifestAuthor)[];
85
+ /** Path to plugin logo (e.g. "images/logo.svg" or "images/logo.png") */
86
+ logo?: string;
87
+ /** Path to plugin header banner (e.g. "images/banner.png" or "images/banner.webp") */
88
+ banner?: string;
89
+ /** Path to README markdown file (default: "README.md") */
90
+ readme?: string;
91
+ /** Category tags */
92
+ tags?: string[];
93
+ /** External links */
94
+ links?: WeavetabManifestLinks;
95
+ /** Runtime compatibility requirements */
96
+ compatibility?: WeavetabCompatibility;
97
+ /** Tools exposed by this plugin to the MCP server */
98
+ tools?: WeavetabManifestTool[];
99
+ /** Required permissions with security rationale */
100
+ permissions?: WeavetabManifestPermissions;
101
+ /** Open source license */
102
+ license?: string;
103
+ }
104
+ export interface WeavetabPluginTool<TArgs = any> {
105
+ name: string;
106
+ description: string;
107
+ schema?: Record<string, any> | Record<string, z.ZodType<any>>;
108
+ inputSchema?: Record<string, any>;
109
+ handler: (args: TArgs, session?: any, config?: any) => Promise<any>;
110
+ }
111
+ export interface WeavetabPluginDefinition {
112
+ name: string;
113
+ version: string;
114
+ description?: string;
115
+ tools?: WeavetabPluginTool[];
116
+ overrides?: WeavetabToolOverride[];
117
+ removeTools?: string[];
118
+ onLoad?: () => Promise<void>;
119
+ onUnload?: () => Promise<void>;
120
+ }
121
+ export interface WeavetabPlugin {
122
+ name: string;
123
+ version: string;
124
+ description?: string;
125
+ /** Add new tools */
126
+ tools?: WeavetabToolDefinition[];
127
+ /** Override or wrap existing tools */
128
+ overrides?: WeavetabToolOverride[];
129
+ /** Built-in tools to remove or disable */
130
+ removeTools?: string[];
131
+ manifest?: WeavetabManifest;
132
+ onLoad?: () => Promise<void>;
133
+ onUnload?: () => Promise<void>;
134
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { WeavetabPlugin, WeavetabManifest } from "./interface.js";
2
+ export interface InstalledPluginInfo {
3
+ packageName: string;
4
+ dir: string;
5
+ manifest: WeavetabManifest;
6
+ pkgJson?: Record<string, any>;
7
+ hasValidManifest: boolean;
8
+ }
9
+ /**
10
+ * Reads the manifest (weavetab.json) and package.json for an installed package
11
+ * without executing its runtime code (safe for listing/inspection).
12
+ */
13
+ export declare function inspectInstalledPackage(pkgDir: string): InstalledPluginInfo | null;
14
+ /**
15
+ * Scan node_modules and return metadata for all installed Weavetab plugins.
16
+ */
17
+ export declare function listInstalledPlugins(pluginDir?: string): InstalledPluginInfo[];
18
+ export declare function discoverPlugins(pluginDir?: string): WeavetabPlugin[];
@@ -0,0 +1,155 @@
1
+ import { readdirSync, existsSync, readFileSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { join, basename } from "node:path";
4
+ const require = createRequire(import.meta.url);
5
+ /**
6
+ * Reads the manifest (weavetab.json) and package.json for an installed package
7
+ * without executing its runtime code (safe for listing/inspection).
8
+ */
9
+ export function inspectInstalledPackage(pkgDir) {
10
+ const manifestPath = join(pkgDir, "weavetab.json");
11
+ if (!existsSync(manifestPath))
12
+ return null;
13
+ try {
14
+ const rawManifest = readFileSync(manifestPath, "utf-8");
15
+ const manifest = JSON.parse(rawManifest);
16
+ let pkgJson;
17
+ const pkgPath = join(pkgDir, "package.json");
18
+ if (existsSync(pkgPath)) {
19
+ try {
20
+ pkgJson = JSON.parse(readFileSync(pkgPath, "utf-8"));
21
+ }
22
+ catch { /* malformed package.json */ }
23
+ }
24
+ const packageName = pkgJson?.name || manifest.name || basename(pkgDir);
25
+ return {
26
+ packageName,
27
+ dir: pkgDir,
28
+ manifest,
29
+ pkgJson,
30
+ hasValidManifest: true,
31
+ };
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ /**
38
+ * Scan node_modules and return metadata for all installed Weavetab plugins.
39
+ */
40
+ export function listInstalledPlugins(pluginDir) {
41
+ const results = [];
42
+ try {
43
+ const modulesDir = pluginDir || join(process.cwd(), "node_modules");
44
+ if (!existsSync(modulesDir))
45
+ return results;
46
+ const entries = readdirSync(modulesDir, { withFileTypes: true });
47
+ for (const entry of entries) {
48
+ if (!entry.isDirectory())
49
+ continue;
50
+ if (entry.name.startsWith("@")) {
51
+ // Scoped packages (@weavetab/plugin-xyz, @scope/xyz)
52
+ const scopeDir = join(modulesDir, entry.name);
53
+ try {
54
+ const scopeEntries = readdirSync(scopeDir, { withFileTypes: true });
55
+ for (const scopeEntry of scopeEntries) {
56
+ if (!scopeEntry.isDirectory())
57
+ continue;
58
+ const info = inspectInstalledPackage(join(scopeDir, scopeEntry.name));
59
+ if (info)
60
+ results.push(info);
61
+ }
62
+ }
63
+ catch { /* scope dir unreadable */ }
64
+ }
65
+ else {
66
+ // Top-level packages (any name)
67
+ const info = inspectInstalledPackage(join(modulesDir, entry.name));
68
+ if (info)
69
+ results.push(info);
70
+ }
71
+ }
72
+ }
73
+ catch { /* ignore filesystem errors */ }
74
+ return results;
75
+ }
76
+ /**
77
+ * Attempt to load a single package as a Weavetab plugin for MCP server execution.
78
+ * The presence of weavetab.json is the ONLY requirement — no name check needed.
79
+ * This gives developers complete freedom to name their packages anything.
80
+ */
81
+ function tryLoadPlugin(pkgDir) {
82
+ const manifestPath = join(pkgDir, "weavetab.json");
83
+ if (!existsSync(manifestPath))
84
+ return null;
85
+ try {
86
+ const rawManifest = readFileSync(manifestPath, "utf-8");
87
+ const manifest = JSON.parse(rawManifest);
88
+ let pkg = {};
89
+ const pkgPath = join(pkgDir, "package.json");
90
+ if (existsSync(pkgPath)) {
91
+ pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
92
+ }
93
+ const pluginMain = pkg.main || "index.js";
94
+ const pluginModule = require(join(pkgDir, pluginMain));
95
+ const plugin = pluginModule.default || pluginModule.plugin || pluginModule;
96
+ if (plugin &&
97
+ (Array.isArray(plugin.tools) ||
98
+ Array.isArray(plugin.overrides) ||
99
+ Array.isArray(plugin.removeTools) ||
100
+ Boolean(manifest.permissions?.tools))) {
101
+ plugin.name = plugin.name || manifest.name || pkg.name || basename(pkgDir);
102
+ plugin.version = plugin.version || manifest.version || pkg.version || "1.0.0";
103
+ plugin.description = plugin.description || manifest.description || pkg.description || "";
104
+ plugin.manifest = manifest;
105
+ plugin.tools = Array.isArray(plugin.tools) ? plugin.tools : [];
106
+ plugin.overrides = Array.isArray(plugin.overrides) ? plugin.overrides : [];
107
+ plugin.removeTools = Array.isArray(plugin.removeTools)
108
+ ? plugin.removeTools
109
+ : manifest.permissions?.tools?.remove || [];
110
+ return plugin;
111
+ }
112
+ }
113
+ catch {
114
+ // Not a valid plugin — skip silently
115
+ }
116
+ return null;
117
+ }
118
+ export function discoverPlugins(pluginDir) {
119
+ const plugins = [];
120
+ try {
121
+ const modulesDir = pluginDir || join(process.cwd(), "node_modules");
122
+ if (!existsSync(modulesDir))
123
+ return plugins;
124
+ const entries = readdirSync(modulesDir, { withFileTypes: true });
125
+ for (const entry of entries) {
126
+ if (!entry.isDirectory())
127
+ continue;
128
+ if (entry.name.startsWith("@")) {
129
+ // Scoped package directory (e.g. @weavetab, @microsoft, @mycompany)
130
+ const scopeDir = join(modulesDir, entry.name);
131
+ try {
132
+ const scopeEntries = readdirSync(scopeDir, { withFileTypes: true });
133
+ for (const scopeEntry of scopeEntries) {
134
+ if (!scopeEntry.isDirectory())
135
+ continue;
136
+ const plugin = tryLoadPlugin(join(scopeDir, scopeEntry.name));
137
+ if (plugin)
138
+ plugins.push(plugin);
139
+ }
140
+ }
141
+ catch { /* scope dir unreadable */ }
142
+ }
143
+ else {
144
+ // Top-level package — any name works: wt-github, my-cool-plugin, etc.
145
+ const plugin = tryLoadPlugin(join(modulesDir, entry.name));
146
+ if (plugin)
147
+ plugins.push(plugin);
148
+ }
149
+ }
150
+ }
151
+ catch {
152
+ // node_modules may not exist or be inaccessible
153
+ }
154
+ return plugins;
155
+ }
@@ -0,0 +1,50 @@
1
+ export type PluginTrustTier = "official" | "verified" | "unverified";
2
+ export interface PluginTrustInfo {
3
+ tier: PluginTrustTier;
4
+ /** Terminal badge string for startup logs & CLI */
5
+ badge: string;
6
+ /** Human-readable label (e.g. Official, Verified, Unverified) */
7
+ label: string;
8
+ /** Description or tooltip text */
9
+ tooltip: string;
10
+ }
11
+ export interface PluginCandidate {
12
+ packageName: string;
13
+ tier: PluginTrustTier;
14
+ label: string;
15
+ badge: string;
16
+ tooltip: string;
17
+ isOfficialShortcut: boolean;
18
+ version?: string;
19
+ description?: string;
20
+ }
21
+ export declare const OFFICIAL_PLUGIN_PREFIX = "@weavetab/plugin-";
22
+ export declare const REGISTRY_URL = "https://raw.githubusercontent.com/weavetab/registry/main/verified.json";
23
+ /**
24
+ * Returns the set of verified package names.
25
+ * - Tries local registry/verified.json first (dev/test mode).
26
+ * - Falls back to GitHub remote.
27
+ * - Falls back to empty set on any failure (fail open — just shows unverified).
28
+ */
29
+ export declare function getVerifiedPackages(): Promise<Set<string>>;
30
+ /**
31
+ * Clear in-memory verified packages cache (useful for tests or forced refresh).
32
+ */
33
+ export declare function invalidateRegistryCache(): void;
34
+ /**
35
+ * Determine the trust tier for a plugin based on its package name and the
36
+ * verified registry.
37
+ */
38
+ export declare function resolvePluginTrust(packageName: string, verifiedPackages: Set<string>): PluginTrustInfo;
39
+ /**
40
+ * Checks if a package exists on the npm registry via a fast HEAD request.
41
+ */
42
+ export declare function checkNpmPackageExists(pkgName: string): Promise<boolean>;
43
+ /**
44
+ * Resolves potential package candidates for an input name.
45
+ * - If name is already explicitly scoped (starts with @), resolves directly.
46
+ * - If short name is provided (e.g. "n8n-wt"), checks both:
47
+ * 1. Official shortcut: @weavetab/plugin-<name>
48
+ * 2. Community package: <name>
49
+ */
50
+ export declare function resolvePluginCandidates(inputName: string, verifiedPackages: Set<string>): Promise<PluginCandidate[]>;