@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,36 @@
1
+ /**
2
+ * Weavetab — tools/automation.ts
3
+ * browser_automation: Persistent injected scripts that run independently inside the browser.
4
+ * The agent does NOT wait for results in a loop — scripts run at browser speed.
5
+ * Weavetab by fy2ne
6
+ *
7
+ * Design (anti-pattern #5 safe):
8
+ * - automationRegistry (server-side Map) is the SINGLE source of truth for script metadata.
9
+ * - Page-side uses closure state for loop lifecycle — no window.__wt_automations registry.
10
+ * - Stop signal uses a minimal window boolean per automation (same pattern as __wt_stop_requested in server.ts).
11
+ * - Result mailbox uses a window array per automation (single-purpose, not a registry map).
12
+ */
13
+ import CDP from "chrome-remote-interface";
14
+ import type { Config } from "../config/loader.js";
15
+ export interface AutomationOptions {
16
+ action: "start" | "stop" | "list" | "poll";
17
+ id?: string;
18
+ script?: string;
19
+ persistent?: boolean;
20
+ onResult?: "notify_agent" | "store" | "ignore";
21
+ }
22
+ interface AutomationScript {
23
+ id: string;
24
+ script: string;
25
+ persistent: boolean;
26
+ onResult: "notify_agent" | "store" | "ignore";
27
+ startedAt: string;
28
+ active: boolean;
29
+ }
30
+ export declare function browserAutomation(session: CDP.Client, options: AutomationOptions, _config: Config): Promise<{
31
+ success: boolean;
32
+ automations?: AutomationScript[];
33
+ results?: any[];
34
+ error?: string;
35
+ }>;
36
+ export {};
@@ -0,0 +1,218 @@
1
+ import { logAction } from "../audit/logger.js";
2
+ // Server-side registry — the ONLY source of truth for script metadata.
3
+ // Page must NOT hold agent state (anti-pattern #5).
4
+ const automationRegistry = new Map();
5
+ // Server-side result buffer for scripts with onResult="notify_agent".
6
+ // Harvested from page mailboxes by list/poll.
7
+ const resultQueue = [];
8
+ function stopSignalKey(id) {
9
+ return `__wt_auto_stop_${id}`;
10
+ }
11
+ function resultMailboxKey(id) {
12
+ return `__wt_auto_out_${id}`;
13
+ }
14
+ export async function browserAutomation(session, options, _config) {
15
+ const { action, id, script, persistent = false, onResult = "store" } = options;
16
+ if (action === "start") {
17
+ if (!id)
18
+ return { success: false, error: "browser_automation start requires an 'id'" };
19
+ if (!script)
20
+ return { success: false, error: "browser_automation start requires a 'script'" };
21
+ // Clear any previous stop signal for this id
22
+ await session.Runtime.evaluate({
23
+ expression: `(function() { delete window[${JSON.stringify(stopSignalKey(id))}]; delete window[${JSON.stringify(resultMailboxKey(id))}]; })()`,
24
+ returnByValue: true,
25
+ }).catch(() => { });
26
+ // Wrap the script in an IIFE using ONLY closure state for lifecycle.
27
+ // No window.__wt_automations map. Stop signal read from a window boolean.
28
+ // Results written to a window array per automation (mailbox, not registry).
29
+ const wrappedScript = `
30
+ (function() {
31
+ var _id = ${JSON.stringify(id)};
32
+ var _persistent = ${JSON.stringify(persistent)};
33
+ var _onResult = ${JSON.stringify(onResult)};
34
+ var _active = true;
35
+ var _resultMailbox = window[${JSON.stringify(resultMailboxKey(id))}];
36
+ var wt = {
37
+ query: function(sel) {
38
+ return document.querySelector(sel) || (window.__Weavetab_shadowQuery ? window.__Weavetab_shadowQuery(sel) : null);
39
+ },
40
+ click: function(sel) {
41
+ var el = this.query(sel);
42
+ if (el) el.click();
43
+ },
44
+ fill: function(sel, val) {
45
+ var el = this.query(sel);
46
+ if (el) {
47
+ el.value = val;
48
+ el.dispatchEvent(new Event('input', {bubbles:true}));
49
+ el.dispatchEvent(new Event('change', {bubbles:true}));
50
+ }
51
+ }
52
+ };
53
+
54
+ // Create result mailbox as a plain array on window — single-purpose, not a registry
55
+ if (!_resultMailbox) {
56
+ _resultMailbox = [];
57
+ Object.defineProperty(window, ${JSON.stringify(resultMailboxKey(id))}, {
58
+ value: _resultMailbox,
59
+ writable: true,
60
+ configurable: true,
61
+ enumerable: false
62
+ });
63
+ }
64
+
65
+ function _report(data) {
66
+ var safeData;
67
+ try { JSON.stringify(data); safeData = data; } catch(e) { safeData = String(data); }
68
+ _resultMailbox.push({ data: safeData, timestamp: new Date().toISOString() });
69
+ }
70
+
71
+ function _checkStop() {
72
+ return window[${JSON.stringify(stopSignalKey(id))}] === true;
73
+ }
74
+
75
+ function _run() {
76
+ if (!_active) return;
77
+ if (_checkStop()) { _active = false; return; }
78
+ (async function() { return eval(${JSON.stringify(script)}); })().then(function(r) {
79
+ if (r !== undefined && _onResult !== 'ignore') _report(r);
80
+ }).catch(function(e) {
81
+ if (_onResult !== 'ignore') _report({ error: e.message || String(e) });
82
+ }).finally(function() {
83
+ if (_persistent && _active) {
84
+ setTimeout(_run, 100);
85
+ }
86
+ });
87
+ }
88
+
89
+ if (_persistent) {
90
+ _run();
91
+ } else {
92
+ (async function() { return eval(${JSON.stringify(script)}); })().then(function(r) {
93
+ if (r !== undefined && _onResult !== 'ignore') _report(r);
94
+ window[${JSON.stringify(stopSignalKey(id))}] = true;
95
+ }).catch(function(e) {
96
+ if (_onResult !== 'ignore') _report({ error: e.message || String(e) });
97
+ window[${JSON.stringify(stopSignalKey(id))}] = true;
98
+ });
99
+ }
100
+ })();`;
101
+ const resp = await session.Runtime.evaluate({
102
+ expression: wrappedScript,
103
+ returnByValue: true,
104
+ awaitPromise: false,
105
+ });
106
+ if (resp.exceptionDetails) {
107
+ return {
108
+ success: false,
109
+ error: resp.exceptionDetails.exception?.description || resp.exceptionDetails.text,
110
+ };
111
+ }
112
+ if (persistent) {
113
+ try {
114
+ await session.Page.addScriptToEvaluateOnNewDocument({ source: wrappedScript });
115
+ }
116
+ catch (_e) {
117
+ // Fallback gracefully if Page domain isn't enabled
118
+ }
119
+ }
120
+ automationRegistry.set(id, {
121
+ id,
122
+ script,
123
+ persistent,
124
+ onResult,
125
+ startedAt: new Date().toISOString(),
126
+ active: true,
127
+ });
128
+ logAction("browser_automation", id, `started (persistent: ${persistent})`);
129
+ return { success: true, automations: [automationRegistry.get(id)] };
130
+ }
131
+ if (action === "stop") {
132
+ if (!id)
133
+ return { success: false, error: "browser_automation stop requires an 'id'" };
134
+ // Set stop signal boolean on window (single-purpose, same pattern as __wt_stop_requested)
135
+ // The running IIFE checks this flag on each iteration and exits when set.
136
+ await session.Runtime.evaluate({
137
+ expression: `(function() {
138
+ window[${JSON.stringify(stopSignalKey(id))}] = true;
139
+ // Also clear the result mailbox
140
+ delete window[${JSON.stringify(resultMailboxKey(id))}];
141
+ })()`,
142
+ returnByValue: true,
143
+ }).catch(() => { });
144
+ automationRegistry.delete(id);
145
+ logAction("browser_automation", id, "stopped");
146
+ return { success: true, automations: Array.from(automationRegistry.values()) };
147
+ }
148
+ if (action === "list") {
149
+ // Check active status by testing the stop signal
150
+ for (const [autoId] of automationRegistry) {
151
+ try {
152
+ const resp = await session.Runtime.evaluate({
153
+ expression: `(function() { return window[${JSON.stringify(stopSignalKey(autoId))}] === true; })()`,
154
+ returnByValue: true,
155
+ });
156
+ const entry = automationRegistry.get(autoId);
157
+ if (entry)
158
+ entry.active = resp.result?.value !== true;
159
+ }
160
+ catch {
161
+ const entry = automationRegistry.get(autoId);
162
+ if (entry)
163
+ entry.active = false;
164
+ }
165
+ }
166
+ // Collect pending results from all mailboxes
167
+ for (const [autoId] of automationRegistry) {
168
+ try {
169
+ const resp = await session.Runtime.evaluate({
170
+ expression: `(function() {
171
+ var mb = window[${JSON.stringify(resultMailboxKey(autoId))}];
172
+ if (!mb || mb.length === 0) return '[]';
173
+ var items = mb.splice(0, mb.length);
174
+ return JSON.stringify(items);
175
+ })()`,
176
+ returnByValue: true,
177
+ });
178
+ if (resp.result?.value) {
179
+ const items = JSON.parse(resp.result.value);
180
+ for (const item of items) {
181
+ resultQueue.push({ id: autoId, data: item.data, timestamp: item.timestamp });
182
+ }
183
+ }
184
+ }
185
+ catch { /* ignore */ }
186
+ }
187
+ return {
188
+ success: true,
189
+ automations: Array.from(automationRegistry.values()),
190
+ };
191
+ }
192
+ if (action === "poll") {
193
+ // Collect all pending results from mailboxes, then drain server queue
194
+ for (const [autoId] of automationRegistry) {
195
+ try {
196
+ const resp = await session.Runtime.evaluate({
197
+ expression: `(function() {
198
+ var mb = window[${JSON.stringify(resultMailboxKey(autoId))}];
199
+ if (!mb || mb.length === 0) return '[]';
200
+ var items = mb.splice(0, mb.length);
201
+ return JSON.stringify(items);
202
+ })()`,
203
+ returnByValue: true,
204
+ });
205
+ if (resp.result?.value) {
206
+ const items = JSON.parse(resp.result.value);
207
+ for (const item of items) {
208
+ resultQueue.push({ id: autoId, data: item.data, timestamp: item.timestamp });
209
+ }
210
+ }
211
+ }
212
+ catch { /* ignore */ }
213
+ }
214
+ const results = resultQueue.splice(0, resultQueue.length);
215
+ return { success: true, results };
216
+ }
217
+ return { success: false, error: `Unknown action: ${action}` };
218
+ }
@@ -0,0 +1,13 @@
1
+ import type { BrowserEngine } from "../config/loader.js";
2
+ export interface BrowserDetectResult {
3
+ available: {
4
+ engine: BrowserEngine;
5
+ name: string;
6
+ path: string;
7
+ }[];
8
+ current: BrowserEngine;
9
+ toolCoverage: Record<string, number>;
10
+ unsupportedTools: Record<string, string[]>;
11
+ }
12
+ export declare function detectBrowsers(currentEngine: BrowserEngine): BrowserDetectResult;
13
+ export declare function isToolSupported(engine: BrowserEngine, toolName: string): boolean;
@@ -0,0 +1,73 @@
1
+ import { findFirefox, probeAllBrowsers } from "../cdp/bridge.js";
2
+ // Phase 8c: Per-engine tool coverage map
3
+ // Firefox CDP is ~80% feature-complete; WebKit is ~60%
4
+ const ENGINE_COVERAGE = {
5
+ chromium: { coverage: 100, unsupported: [] },
6
+ firefox: {
7
+ coverage: 78,
8
+ unsupported: [
9
+ "browser_network_intercept",
10
+ "browser_viewport",
11
+ "browser_recording",
12
+ "browser_plan",
13
+ "browser_thought",
14
+ "browser_highlight",
15
+ "browser_inspect",
16
+ "browser_snapshot",
17
+ "browser_storage",
18
+ "browser_automation",
19
+ ],
20
+ },
21
+ webkit: {
22
+ coverage: 55,
23
+ unsupported: [
24
+ "browser_network_intercept",
25
+ "browser_viewport",
26
+ "browser_recording",
27
+ "browser_plan",
28
+ "browser_thought",
29
+ "browser_highlight",
30
+ "browser_inspect",
31
+ "browser_snapshot",
32
+ "browser_storage",
33
+ "browser_automation",
34
+ "browser_burst",
35
+ "browser_pointer",
36
+ "browser_select",
37
+ "browser_upload",
38
+ "browser_cookies",
39
+ "browser_canvas",
40
+ "browser_clipboard",
41
+ ],
42
+ },
43
+ };
44
+ export function detectBrowsers(currentEngine) {
45
+ const available = [];
46
+ // Detect Chromium-based browsers
47
+ const allBrowsers = probeAllBrowsers();
48
+ for (const b of allBrowsers) {
49
+ available.push({ engine: "chromium", name: b.name, path: b.path });
50
+ }
51
+ // Detect Firefox
52
+ const ff = findFirefox();
53
+ if (ff) {
54
+ available.push({ engine: "firefox", name: ff.name, path: ff.path });
55
+ }
56
+ // WebKit detection is best-effort (Safari Technology Preview)
57
+ // We do not auto-detect WebKit — only report if manually configured
58
+ const toolCoverage = {};
59
+ const unsupportedTools = {};
60
+ for (const engine of ["chromium", "firefox", "webkit"]) {
61
+ toolCoverage[engine] = ENGINE_COVERAGE[engine].coverage;
62
+ unsupportedTools[engine] = [...ENGINE_COVERAGE[engine].unsupported];
63
+ }
64
+ return {
65
+ available,
66
+ current: currentEngine,
67
+ toolCoverage,
68
+ unsupportedTools,
69
+ };
70
+ }
71
+ export function isToolSupported(engine, toolName) {
72
+ return !ENGINE_COVERAGE[engine]?.unsupported.includes(toolName);
73
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Weavetab — tools/burst.ts
3
+ * Executes multiple tool calls serially in one round-trip, with per-step delta checking.
4
+ * Weavetab by fy2ne
5
+ */
6
+ import CDP from "chrome-remote-interface";
7
+ import type { Config } from "../config/loader.js";
8
+ export interface BurstStep {
9
+ tool: "browser_click" | "browser_type" | "browser_go" | "browser_navigate" | "browser_key" | "browser_scroll" | "browser_wait" | "browser_map" | "browser_pointer" | "browser_eval" | "browser_select" | "browser_console" | "browser_find" | "browser_fill" | "browser_type_secret" | "browser_screenshot" | "browser_inspect" | "browser_storage" | "browser_cookies" | "browser_highlight" | "browser_scrape" | "browser_canvas" | "browser_performance" | "browser_snapshot" | "browser_pdf" | "browser_dialog" | "browser_upload" | "browser_viewport" | "browser_clipboard" | "browser_detect" | "browser_recording" | "browser_automation";
10
+ args: Record<string, unknown>;
11
+ }
12
+ /** Macro step types — expanded server-side into multiple primitive calls. */
13
+ export interface BurstMacroStep {
14
+ tool: "type_and_send" | "navigate_and_read" | "click_and_wait" | "scroll_and_read" | "fill_form" | "drag_and_drop" | "hover_and_read";
15
+ args: Record<string, unknown>;
16
+ }
17
+ export type AnyBurstStep = BurstStep | BurstMacroStep;
18
+ export interface BurstStepResult {
19
+ step: number;
20
+ tool: string;
21
+ success: boolean;
22
+ result?: unknown;
23
+ error?: string;
24
+ }
25
+ export interface BurstResult {
26
+ success: boolean;
27
+ steps_completed: number;
28
+ results: BurstStepResult[];
29
+ aborted: boolean;
30
+ abort_reason?: string;
31
+ }
32
+ export declare function browserBurst(session: CDP.Client, args: {
33
+ steps: AnyBurstStep[];
34
+ batch?: boolean;
35
+ }, config: Config): Promise<BurstResult>;