@aria-cli/tools 1.0.12 → 1.0.14

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 (233) hide show
  1. package/dist/index.js +378 -70
  2. package/dist/network-runtime/index.js +8 -12
  3. package/dist-cjs/index.js +400 -435
  4. package/dist-cjs/network-runtime/index.js +8 -172
  5. package/package.json +8 -6
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist/ask-user-interaction.js +0 -22
  8. package/dist/cache/web-cache.js +0 -66
  9. package/dist/definitions/arion.js +0 -104
  10. package/dist/definitions/browser/browser.js +0 -418
  11. package/dist/definitions/browser/index.js +0 -4
  12. package/dist/definitions/browser/pw-downloads.js +0 -114
  13. package/dist/definitions/browser/pw-interactions.js +0 -199
  14. package/dist/definitions/browser/pw-responses.js +0 -76
  15. package/dist/definitions/browser/pw-session.js +0 -310
  16. package/dist/definitions/browser/pw-shared.js +0 -66
  17. package/dist/definitions/browser/pw-snapshot.js +0 -301
  18. package/dist/definitions/browser/pw-state.js +0 -62
  19. package/dist/definitions/browser/types.js +0 -4
  20. package/dist/definitions/code-intelligence.js +0 -470
  21. package/dist/definitions/core.js +0 -109
  22. package/dist/definitions/delegation.js +0 -512
  23. package/dist/definitions/deploy.js +0 -65
  24. package/dist/definitions/filesystem.js +0 -196
  25. package/dist/definitions/frg.js +0 -63
  26. package/dist/definitions/index.js +0 -20
  27. package/dist/definitions/memory.js +0 -123
  28. package/dist/definitions/messaging.js +0 -625
  29. package/dist/definitions/meta.js +0 -349
  30. package/dist/definitions/network.js +0 -159
  31. package/dist/definitions/outlook.js +0 -277
  32. package/dist/definitions/patch/apply-patch.js +0 -184
  33. package/dist/definitions/patch/fuzzy-match.js +0 -166
  34. package/dist/definitions/patch/index.js +0 -1
  35. package/dist/definitions/patch/patch-parser.js +0 -207
  36. package/dist/definitions/patch/sandbox-paths.js +0 -105
  37. package/dist/definitions/process/index.js +0 -4
  38. package/dist/definitions/process/process-registry.js +0 -213
  39. package/dist/definitions/process/process.js +0 -386
  40. package/dist/definitions/process/pty-keys.js +0 -254
  41. package/dist/definitions/process/session-slug.js +0 -142
  42. package/dist/definitions/quip.js +0 -195
  43. package/dist/definitions/search.js +0 -60
  44. package/dist/definitions/session-history.js +0 -69
  45. package/dist/definitions/shell.js +0 -181
  46. package/dist/definitions/slack.js +0 -180
  47. package/dist/definitions/web.js +0 -109
  48. package/dist/executors/apply-patch.js +0 -901
  49. package/dist/executors/arion.js +0 -119
  50. package/dist/executors/code-intelligence.js +0 -882
  51. package/dist/executors/deploy.js +0 -848
  52. package/dist/executors/filesystem.js +0 -1122
  53. package/dist/executors/frg-freshness.js +0 -576
  54. package/dist/executors/frg.js +0 -298
  55. package/dist/executors/index.js +0 -46
  56. package/dist/executors/learning-meta.js +0 -1146
  57. package/dist/executors/lsp-client.js +0 -296
  58. package/dist/executors/memory.js +0 -750
  59. package/dist/executors/meta.js +0 -220
  60. package/dist/executors/process-registry.js +0 -465
  61. package/dist/executors/pty-session-store.js +0 -30
  62. package/dist/executors/pty.js +0 -271
  63. package/dist/executors/restart.js +0 -119
  64. package/dist/executors/search-freshness.js +0 -195
  65. package/dist/executors/search-types.js +0 -52
  66. package/dist/executors/search.js +0 -66
  67. package/dist/executors/self-diagnose.js +0 -398
  68. package/dist/executors/session-history.js +0 -283
  69. package/dist/executors/shell-safety.js +0 -473
  70. package/dist/executors/shell.js +0 -954
  71. package/dist/executors/utils.js +0 -33
  72. package/dist/executors/web.js +0 -542
  73. package/dist/extraction/content-extraction.js +0 -235
  74. package/dist/extraction/index.js +0 -4
  75. package/dist/headless-control-contract.js +0 -967
  76. package/dist/local-control-http-auth.js +0 -2
  77. package/dist/mcp/client.js +0 -181
  78. package/dist/mcp/connection.js +0 -480
  79. package/dist/mcp/index.js +0 -10
  80. package/dist/mcp/jsonrpc.js +0 -144
  81. package/dist/mcp/types.js +0 -7
  82. package/dist/network-control-adapter.js +0 -72
  83. package/dist/network-runtime/address-types.js +0 -165
  84. package/dist/network-runtime/db-owner-fencing.js +0 -69
  85. package/dist/network-runtime/delivery-receipts.js +0 -267
  86. package/dist/network-runtime/direct-endpoint-authority.js +0 -25
  87. package/dist/network-runtime/local-control-contract.js +0 -627
  88. package/dist/network-runtime/node-store-contract.js +0 -34
  89. package/dist/network-runtime/pair-route-contract.js +0 -77
  90. package/dist/network-runtime/peer-capabilities.js +0 -28
  91. package/dist/network-runtime/peer-principal-ref.js +0 -12
  92. package/dist/network-runtime/peer-state-machine.js +0 -121
  93. package/dist/network-runtime/protocol-schemas.js +0 -205
  94. package/dist/network-runtime/runtime-bootstrap-contract.js +0 -60
  95. package/dist/outlook/desktop-session.js +0 -279
  96. package/dist/policy.js +0 -149
  97. package/dist/providers/brave.js +0 -62
  98. package/dist/providers/duckduckgo.js +0 -176
  99. package/dist/providers/exa.js +0 -63
  100. package/dist/providers/firecrawl.js +0 -55
  101. package/dist/providers/index.js +0 -7
  102. package/dist/providers/jina.js +0 -49
  103. package/dist/providers/router.js +0 -96
  104. package/dist/providers/search-provider.js +0 -32
  105. package/dist/providers/tavily.js +0 -54
  106. package/dist/quip/desktop-session.js +0 -317
  107. package/dist/registry/index.js +0 -1
  108. package/dist/registry/registry.js +0 -756
  109. package/dist/runtime-socket-local-control-client.js +0 -330
  110. package/dist/security/dns-normalization.js +0 -19
  111. package/dist/security/dns-pinning.js +0 -123
  112. package/dist/security/external-content.js +0 -91
  113. package/dist/security/ssrf.js +0 -181
  114. package/dist/slack/desktop-session.js +0 -324
  115. package/dist/tool-factory.js +0 -47
  116. package/dist/types.js +0 -7
  117. package/dist/utils/retry.js +0 -132
  118. package/dist/utils/safe-parse-json.js +0 -160
  119. package/dist/utils/url.js +0 -19
  120. package/dist-cjs/.tsbuildinfo +0 -1
  121. package/dist-cjs/ask-user-interaction.js +0 -27
  122. package/dist-cjs/cache/web-cache.js +0 -70
  123. package/dist-cjs/definitions/arion.js +0 -107
  124. package/dist-cjs/definitions/browser/browser.js +0 -421
  125. package/dist-cjs/definitions/browser/index.js +0 -8
  126. package/dist-cjs/definitions/browser/pw-downloads.js +0 -117
  127. package/dist-cjs/definitions/browser/pw-interactions.js +0 -213
  128. package/dist-cjs/definitions/browser/pw-responses.js +0 -84
  129. package/dist-cjs/definitions/browser/pw-session.js +0 -326
  130. package/dist-cjs/definitions/browser/pw-shared.js +0 -72
  131. package/dist-cjs/definitions/browser/pw-snapshot.js +0 -307
  132. package/dist-cjs/definitions/browser/pw-state.js +0 -70
  133. package/dist-cjs/definitions/browser/types.js +0 -5
  134. package/dist-cjs/definitions/code-intelligence.js +0 -473
  135. package/dist-cjs/definitions/core.js +0 -133
  136. package/dist-cjs/definitions/delegation.js +0 -515
  137. package/dist-cjs/definitions/deploy.js +0 -68
  138. package/dist-cjs/definitions/filesystem.js +0 -199
  139. package/dist-cjs/definitions/frg.js +0 -66
  140. package/dist-cjs/definitions/index.js +0 -43
  141. package/dist-cjs/definitions/memory.js +0 -126
  142. package/dist-cjs/definitions/messaging.js +0 -631
  143. package/dist-cjs/definitions/meta.js +0 -352
  144. package/dist-cjs/definitions/network.js +0 -162
  145. package/dist-cjs/definitions/outlook.js +0 -280
  146. package/dist-cjs/definitions/patch/apply-patch.js +0 -191
  147. package/dist-cjs/definitions/patch/fuzzy-match.js +0 -172
  148. package/dist-cjs/definitions/patch/index.js +0 -5
  149. package/dist-cjs/definitions/patch/patch-parser.js +0 -215
  150. package/dist-cjs/definitions/patch/sandbox-paths.js +0 -113
  151. package/dist-cjs/definitions/process/index.js +0 -8
  152. package/dist-cjs/definitions/process/process-registry.js +0 -231
  153. package/dist-cjs/definitions/process/process.js +0 -389
  154. package/dist-cjs/definitions/process/pty-keys.js +0 -259
  155. package/dist-cjs/definitions/process/session-slug.js +0 -145
  156. package/dist-cjs/definitions/quip.js +0 -198
  157. package/dist-cjs/definitions/search.js +0 -63
  158. package/dist-cjs/definitions/session-history.js +0 -72
  159. package/dist-cjs/definitions/shell.js +0 -184
  160. package/dist-cjs/definitions/slack.js +0 -183
  161. package/dist-cjs/definitions/web.js +0 -112
  162. package/dist-cjs/executors/apply-patch.js +0 -938
  163. package/dist-cjs/executors/arion.js +0 -125
  164. package/dist-cjs/executors/code-intelligence.js +0 -925
  165. package/dist-cjs/executors/deploy.js +0 -869
  166. package/dist-cjs/executors/filesystem.js +0 -1167
  167. package/dist-cjs/executors/frg-freshness.js +0 -627
  168. package/dist-cjs/executors/frg.js +0 -334
  169. package/dist-cjs/executors/index.js +0 -143
  170. package/dist-cjs/executors/learning-meta.js +0 -1165
  171. package/dist-cjs/executors/lsp-client.js +0 -310
  172. package/dist-cjs/executors/memory.js +0 -796
  173. package/dist-cjs/executors/meta.js +0 -226
  174. package/dist-cjs/executors/process-registry.js +0 -469
  175. package/dist-cjs/executors/pty-session-store.js +0 -34
  176. package/dist-cjs/executors/pty.js +0 -312
  177. package/dist-cjs/executors/restart.js +0 -155
  178. package/dist-cjs/executors/search-freshness.js +0 -234
  179. package/dist-cjs/executors/search-types.js +0 -56
  180. package/dist-cjs/executors/search.js +0 -102
  181. package/dist-cjs/executors/self-diagnose.js +0 -434
  182. package/dist-cjs/executors/session-history.js +0 -320
  183. package/dist-cjs/executors/shell-safety.js +0 -478
  184. package/dist-cjs/executors/shell.js +0 -1001
  185. package/dist-cjs/executors/utils.js +0 -73
  186. package/dist-cjs/executors/web.js +0 -547
  187. package/dist-cjs/extraction/content-extraction.js +0 -243
  188. package/dist-cjs/extraction/index.js +0 -8
  189. package/dist-cjs/headless-control-contract.js +0 -972
  190. package/dist-cjs/local-control-http-auth.js +0 -5
  191. package/dist-cjs/mcp/client.js +0 -185
  192. package/dist-cjs/mcp/connection.js +0 -484
  193. package/dist-cjs/mcp/index.js +0 -30
  194. package/dist-cjs/mcp/jsonrpc.js +0 -148
  195. package/dist-cjs/mcp/types.js +0 -8
  196. package/dist-cjs/network-control-adapter.js +0 -77
  197. package/dist-cjs/network-runtime/address-types.js +0 -168
  198. package/dist-cjs/network-runtime/db-owner-fencing.js +0 -76
  199. package/dist-cjs/network-runtime/delivery-receipts.js +0 -276
  200. package/dist-cjs/network-runtime/direct-endpoint-authority.js +0 -29
  201. package/dist-cjs/network-runtime/local-control-contract.js +0 -633
  202. package/dist-cjs/network-runtime/node-store-contract.js +0 -38
  203. package/dist-cjs/network-runtime/pair-route-contract.js +0 -80
  204. package/dist-cjs/network-runtime/peer-capabilities.js +0 -37
  205. package/dist-cjs/network-runtime/peer-principal-ref.js +0 -15
  206. package/dist-cjs/network-runtime/peer-state-machine.js +0 -129
  207. package/dist-cjs/network-runtime/protocol-schemas.js +0 -212
  208. package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +0 -63
  209. package/dist-cjs/outlook/desktop-session.js +0 -318
  210. package/dist-cjs/policy.js +0 -155
  211. package/dist-cjs/providers/brave.js +0 -66
  212. package/dist-cjs/providers/duckduckgo.js +0 -180
  213. package/dist-cjs/providers/exa.js +0 -67
  214. package/dist-cjs/providers/firecrawl.js +0 -59
  215. package/dist-cjs/providers/index.js +0 -17
  216. package/dist-cjs/providers/jina.js +0 -53
  217. package/dist-cjs/providers/router.js +0 -100
  218. package/dist-cjs/providers/search-provider.js +0 -36
  219. package/dist-cjs/providers/tavily.js +0 -58
  220. package/dist-cjs/quip/desktop-session.js +0 -353
  221. package/dist-cjs/registry/index.js +0 -6
  222. package/dist-cjs/registry/registry.js +0 -761
  223. package/dist-cjs/runtime-socket-local-control-client.js +0 -367
  224. package/dist-cjs/security/dns-normalization.js +0 -22
  225. package/dist-cjs/security/dns-pinning.js +0 -160
  226. package/dist-cjs/security/external-content.js +0 -95
  227. package/dist-cjs/security/ssrf.js +0 -221
  228. package/dist-cjs/slack/desktop-session.js +0 -366
  229. package/dist-cjs/tool-factory.js +0 -50
  230. package/dist-cjs/types.js +0 -8
  231. package/dist-cjs/utils/retry.js +0 -169
  232. package/dist-cjs/utils/safe-parse-json.js +0 -164
  233. package/dist-cjs/utils/url.js +0 -23
@@ -1,418 +0,0 @@
1
- // Originally from OpenClaw (MIT License, Copyright 2025 Peter Steinberger)
2
- // https://github.com/openclaw/openclaw
3
- // Modified for ARIA — stripped OpenClaw runtime, rewired to ARIA Tool interface
4
- import { launchBrowser, closeBrowser, getSession, getRefs, setRefs, getConsoleMessages, getNetworkRequests, listTabs, newTab, selectTab, closeTab, } from "./pw-session.js";
5
- import { snapshotPage, navigatePage } from "./pw-snapshot.js";
6
- import { clickViaPlaywright, hoverViaPlaywright, dragViaPlaywright, typeViaPlaywright, selectOptionViaPlaywright, pressKeyViaPlaywright, evaluateViaPlaywright, takeScreenshot, scrollPage, waitForCondition, uploadFiles, } from "./pw-interactions.js";
7
- import { cookiesGet, cookiesSet, cookiesClear } from "./pw-state.js";
8
- import { filterConsoleMessages, filterNetworkRequests, formatConsoleMessages, formatNetworkRequests, } from "./pw-responses.js";
9
- // ── JSON Schema for the action parameter ──────────────────────────────
10
- const browserParameterSchema = {
11
- type: "object",
12
- properties: {
13
- action: {
14
- type: "string",
15
- enum: [
16
- "launch",
17
- "close",
18
- "navigate",
19
- "snapshot",
20
- "click",
21
- "type",
22
- "hover",
23
- "drag",
24
- "select_option",
25
- "press_key",
26
- "scroll",
27
- "evaluate",
28
- "screenshot",
29
- "get_console",
30
- "get_network",
31
- "wait",
32
- "tab_list",
33
- "tab_new",
34
- "tab_select",
35
- "tab_close",
36
- "cookies_get",
37
- "cookies_set",
38
- "cookies_clear",
39
- "upload",
40
- ],
41
- description: "The browser action to perform. 'launch' is optional; actions auto-start a session when needed. Use 'snapshot' to read page content, refs like [e1] with 'click'/'type'.",
42
- },
43
- // launch
44
- url: { type: "string", description: "URL to navigate to (for launch/navigate/tab_new)" },
45
- headless: {
46
- type: "boolean",
47
- description: "Run browser without visible window (default: true)",
48
- },
49
- // snapshot
50
- interactive: {
51
- type: "boolean",
52
- description: "Only show interactive elements in snapshot (buttons, links, inputs)",
53
- },
54
- // click/type/hover/drag/select_option/upload
55
- ref: {
56
- type: "string",
57
- description: "Element ref from snapshot (e.g. 'e1', 'e5')",
58
- },
59
- text: { type: "string", description: "Text to type (for 'type' action)" },
60
- submit: {
61
- type: "boolean",
62
- description: "Press Enter after typing (for 'type' action)",
63
- },
64
- slowly: {
65
- type: "boolean",
66
- description: "Type character by character instead of filling (for 'type' action)",
67
- },
68
- button: {
69
- type: "string",
70
- enum: ["left", "right", "middle"],
71
- description: "Mouse button (for 'click' action)",
72
- },
73
- modifiers: {
74
- type: "array",
75
- items: { type: "string" },
76
- description: "Keyboard modifiers (for 'click': Alt, Control, Meta, Shift)",
77
- },
78
- doubleClick: {
79
- type: "boolean",
80
- description: "Double-click instead of single click",
81
- },
82
- startRef: {
83
- type: "string",
84
- description: "Source element ref (for 'drag' action)",
85
- },
86
- endRef: {
87
- type: "string",
88
- description: "Target element ref (for 'drag' action)",
89
- },
90
- values: {
91
- type: "array",
92
- items: { type: "string" },
93
- description: "Values to select (for 'select_option' action)",
94
- },
95
- // press_key
96
- key: {
97
- type: "string",
98
- description: "Key to press (for 'press_key': Enter, Tab, Escape, ArrowDown, etc.)",
99
- },
100
- // scroll
101
- direction: {
102
- type: "string",
103
- enum: ["up", "down"],
104
- description: "Scroll direction",
105
- },
106
- amount: {
107
- type: "number",
108
- description: "Scroll amount in pixels (default: 500)",
109
- },
110
- // evaluate
111
- script: {
112
- type: "string",
113
- description: "JavaScript to evaluate in browser context (for 'evaluate' action)",
114
- },
115
- // get_console
116
- level: {
117
- type: "string",
118
- description: "Minimum console level filter (debug/info/warning/error)",
119
- },
120
- // get_network
121
- filter: {
122
- type: "string",
123
- description: "URL substring filter for network requests",
124
- },
125
- // wait
126
- selector: {
127
- type: "string",
128
- description: "CSS selector to wait for (for 'wait' action)",
129
- },
130
- timeout: {
131
- type: "number",
132
- description: "Timeout in milliseconds (for 'wait' action)",
133
- },
134
- // tab_select
135
- index: {
136
- type: "number",
137
- description: "Tab index (for 'tab_select'/'tab_close')",
138
- },
139
- // cookies_set
140
- cookies: {
141
- type: "array",
142
- items: {
143
- type: "object",
144
- properties: {
145
- name: { type: "string" },
146
- value: { type: "string" },
147
- domain: { type: "string" },
148
- path: { type: "string" },
149
- },
150
- required: ["name", "value", "domain"],
151
- },
152
- description: "Cookies to set (for 'cookies_set' action)",
153
- },
154
- // upload
155
- paths: {
156
- type: "array",
157
- items: { type: "string" },
158
- description: "File paths to upload (for 'upload' action)",
159
- },
160
- },
161
- required: ["action"],
162
- };
163
- // ── Helpers ───────────────────────────────────────────────────────────
164
- function ok(message, data) {
165
- return { success: true, message, data };
166
- }
167
- function fail(message) {
168
- return { success: false, message };
169
- }
170
- async function requireSession() {
171
- const session = getSession();
172
- if (session) {
173
- return session;
174
- }
175
- return launchBrowser();
176
- }
177
- // ── Action dispatcher ─────────────────────────────────────────────────
178
- async function executeBrowserAction(input) {
179
- const action = input;
180
- try {
181
- switch (action.action) {
182
- // ── Lifecycle ─────────────────────────────────────────────────
183
- case "launch": {
184
- const session = await launchBrowser({
185
- headless: action.headless,
186
- url: action.url,
187
- });
188
- const url = session.page.url();
189
- return ok(`Browser launched.${action.url ? ` Navigated to ${url}` : ""}\nUse 'snapshot' to see page content.`, { url });
190
- }
191
- case "close": {
192
- await closeBrowser();
193
- return ok("Browser closed.");
194
- }
195
- // ── Navigation ────────────────────────────────────────────────
196
- case "navigate": {
197
- const session = await requireSession();
198
- const result = await navigatePage(session.page, action.url);
199
- setRefs({}); // Refs are stale after navigation
200
- return ok(`Navigated to ${result.url}. Use 'snapshot' to see page content.`, result);
201
- }
202
- // ── Snapshot ──────────────────────────────────────────────────
203
- case "snapshot": {
204
- const session = await requireSession();
205
- const result = await snapshotPage(session.page, {
206
- interactive: action.interactive,
207
- });
208
- setRefs(result.refs);
209
- const header = `Page: ${result.title}\nURL: ${result.url}\n` +
210
- `Elements: ${result.stats.refs} total, ${result.stats.interactive} interactive\n\n`;
211
- return ok(header + result.snapshot, {
212
- url: result.url,
213
- title: result.title,
214
- stats: result.stats,
215
- });
216
- }
217
- // ── Click ─────────────────────────────────────────────────────
218
- case "click": {
219
- const session = await requireSession();
220
- await clickViaPlaywright({
221
- page: session.page,
222
- refs: getRefs(),
223
- ref: action.ref,
224
- doubleClick: action.doubleClick,
225
- button: action.button,
226
- modifiers: action.modifiers,
227
- });
228
- return ok(`Clicked ${action.ref}. Use 'snapshot' to see updated page.`);
229
- }
230
- // ── Type ──────────────────────────────────────────────────────
231
- case "type": {
232
- const session = await requireSession();
233
- await typeViaPlaywright({
234
- page: session.page,
235
- refs: getRefs(),
236
- ref: action.ref,
237
- text: action.text,
238
- submit: action.submit,
239
- slowly: action.slowly,
240
- });
241
- return ok(`Typed "${action.text.length > 50 ? action.text.slice(0, 50) + "..." : action.text}" into ${action.ref}.${action.submit ? " Submitted with Enter." : ""}`);
242
- }
243
- // ── Hover ─────────────────────────────────────────────────────
244
- case "hover": {
245
- const session = await requireSession();
246
- await hoverViaPlaywright({
247
- page: session.page,
248
- refs: getRefs(),
249
- ref: action.ref,
250
- });
251
- return ok(`Hovered over ${action.ref}.`);
252
- }
253
- // ── Drag ──────────────────────────────────────────────────────
254
- case "drag": {
255
- const session = await requireSession();
256
- await dragViaPlaywright({
257
- page: session.page,
258
- refs: getRefs(),
259
- startRef: action.startRef,
260
- endRef: action.endRef,
261
- });
262
- return ok(`Dragged ${action.startRef} to ${action.endRef}.`);
263
- }
264
- // ── Select option ─────────────────────────────────────────────
265
- case "select_option": {
266
- const session = await requireSession();
267
- await selectOptionViaPlaywright({
268
- page: session.page,
269
- refs: getRefs(),
270
- ref: action.ref,
271
- values: action.values,
272
- });
273
- return ok(`Selected [${action.values.join(", ")}] in ${action.ref}.`);
274
- }
275
- // ── Key press ─────────────────────────────────────────────────
276
- case "press_key": {
277
- const session = await requireSession();
278
- await pressKeyViaPlaywright({
279
- page: session.page,
280
- key: action.key,
281
- });
282
- return ok(`Pressed key: ${action.key}`);
283
- }
284
- // ── Scroll ────────────────────────────────────────────────────
285
- case "scroll": {
286
- const session = await requireSession();
287
- await scrollPage({
288
- page: session.page,
289
- direction: action.direction,
290
- amount: action.amount,
291
- });
292
- return ok(`Scrolled ${action.direction} ${action.amount ?? 500}px. Use 'snapshot' to see updated content.`);
293
- }
294
- // ── Evaluate ──────────────────────────────────────────────────
295
- case "evaluate": {
296
- const session = await requireSession();
297
- const result = await evaluateViaPlaywright({
298
- page: session.page,
299
- script: action.script,
300
- });
301
- const output = result === undefined
302
- ? "undefined"
303
- : typeof result === "string"
304
- ? result
305
- : JSON.stringify(result, null, 2);
306
- return ok(output, { result });
307
- }
308
- // ── Screenshot ────────────────────────────────────────────────
309
- case "screenshot": {
310
- const session = await requireSession();
311
- const buffer = await takeScreenshot({ page: session.page });
312
- const base64 = buffer.toString("base64");
313
- return ok(`Screenshot taken (${buffer.length} bytes, base64-encoded).`, {
314
- base64,
315
- mimeType: "image/png",
316
- });
317
- }
318
- // ── Console ───────────────────────────────────────────────────
319
- case "get_console": {
320
- await requireSession();
321
- const messages = filterConsoleMessages(getConsoleMessages(), action.level);
322
- return ok(formatConsoleMessages(messages), { count: messages.length });
323
- }
324
- // ── Network ───────────────────────────────────────────────────
325
- case "get_network": {
326
- await requireSession();
327
- const requests = filterNetworkRequests(getNetworkRequests(), action.filter);
328
- return ok(formatNetworkRequests(requests), { count: requests.length });
329
- }
330
- // ── Wait ──────────────────────────────────────────────────────
331
- case "wait": {
332
- const session = await requireSession();
333
- await waitForCondition({
334
- page: session.page,
335
- selector: action.selector,
336
- text: action.text,
337
- timeout: action.timeout,
338
- });
339
- return ok("Wait condition satisfied. Use 'snapshot' to see current page.");
340
- }
341
- // ── Tab management ────────────────────────────────────────────
342
- case "tab_list": {
343
- const tabs = listTabs();
344
- const desc = tabs
345
- .map((t) => `[${t.index}]${t.active ? " (active)" : ""} ${t.url}`)
346
- .join("\n");
347
- return ok(desc || "No tabs open.", { tabs });
348
- }
349
- case "tab_new": {
350
- const result = await newTab(action.url);
351
- return ok(`Opened new tab [${result.index}]: ${result.url}`, result);
352
- }
353
- case "tab_select": {
354
- await requireSession();
355
- const result = await selectTab(action.index);
356
- return ok(`Switched to tab ${action.index}: ${result.url}`, result);
357
- }
358
- case "tab_close": {
359
- await closeTab(action.index);
360
- return ok(`Tab closed.${action.index !== undefined ? ` (index ${action.index})` : ""}`);
361
- }
362
- // ── Cookies ───────────────────────────────────────────────────
363
- case "cookies_get": {
364
- const session = await requireSession();
365
- const result = await cookiesGet(session.context);
366
- const desc = result.cookies.length
367
- ? result.cookies.map((c) => `${c.name}=${c.value} (${c.domain})`).join("\n")
368
- : "No cookies.";
369
- return ok(desc, result);
370
- }
371
- case "cookies_set": {
372
- const session = await requireSession();
373
- await cookiesSet(session.context, action.cookies);
374
- return ok(`Set ${action.cookies.length} cookie(s).`);
375
- }
376
- case "cookies_clear": {
377
- const session = await requireSession();
378
- await cookiesClear(session.context);
379
- return ok("All cookies cleared.");
380
- }
381
- // ── Upload ────────────────────────────────────────────────────
382
- case "upload": {
383
- const session = await requireSession();
384
- await uploadFiles({
385
- page: session.page,
386
- refs: getRefs(),
387
- ref: action.ref,
388
- paths: action.paths,
389
- });
390
- return ok(`Uploaded ${action.paths.length} file(s) to ${action.ref}.`);
391
- }
392
- default: {
393
- const exhaustive = action;
394
- return fail(`Unknown browser action: ${exhaustive.action}`);
395
- }
396
- }
397
- }
398
- catch (err) {
399
- const message = err instanceof Error ? err.message : String(err);
400
- return fail(message);
401
- }
402
- }
403
- // ── Tool definition ───────────────────────────────────────────────────
404
- export const browserTool = {
405
- name: "browser",
406
- description: "Control a web browser via Playwright. Supports navigation, clicking, typing, taking snapshots of page content, and more. " +
407
- "Actions auto-start a browser session; use 'launch' only when you want explicit startup control. Use 'snapshot' to see the current page state as an accessibility tree with element refs like [e1], [e2]. " +
408
- "Use those refs with 'click', 'type', 'hover', etc. to interact with elements. " +
409
- "Use 'evaluate' to run JavaScript in the page context. Use 'screenshot' to capture the page visually.",
410
- category: "web",
411
- parameters: browserParameterSchema,
412
- riskLevel: "moderate",
413
- isReadOnly: false,
414
- loadingTier: "always",
415
- async execute(input, _context) {
416
- return executeBrowserAction(input);
417
- },
418
- };
@@ -1,4 +0,0 @@
1
- // Originally from OpenClaw (MIT License, Copyright 2025 Peter Steinberger)
2
- // https://github.com/openclaw/openclaw
3
- // Modified for ARIA — stripped OpenClaw runtime, rewired to ARIA Tool interface
4
- export { browserTool } from "./browser.js";
@@ -1,114 +0,0 @@
1
- // Originally from OpenClaw (MIT License, Copyright 2025 Peter Steinberger)
2
- // https://github.com/openclaw/openclaw
3
- // Modified for ARIA — stripped OpenClaw runtime, rewired to ARIA Tool interface
4
- /**
5
- * File upload and download handling.
6
- * Ported from OpenClaw's pw-tools-core.downloads.ts.
7
- *
8
- * Note: Upload is handled in pw-interactions.ts via setInputFiles.
9
- * This module provides download capture via page "download" event.
10
- */
11
- import { tmpdir } from "node:os";
12
- import { join, dirname, resolve, basename } from "node:path";
13
- import { mkdir } from "node:fs/promises";
14
- import { randomUUID } from "node:crypto";
15
- import { normalizeTimeoutMs } from "./pw-shared.js";
16
- // ── Filename sanitization ─────────────────────────────────────────────
17
- function sanitizeDownloadFileName(fileName) {
18
- const trimmed = String(fileName ?? "").trim();
19
- if (!trimmed) {
20
- return "download.bin";
21
- }
22
- // Force a basename so path separators/traversal can't escape the downloads dir.
23
- let base = basename(trimmed);
24
- let cleaned = "";
25
- for (let i = 0; i < base.length; i++) {
26
- const code = base.charCodeAt(i);
27
- if (code < 0x20 || code === 0x7f) {
28
- continue;
29
- }
30
- cleaned += base[i];
31
- }
32
- base = cleaned.trim();
33
- if (!base || base === "." || base === "..") {
34
- return "download.bin";
35
- }
36
- if (base.length > 200) {
37
- base = base.slice(0, 200);
38
- }
39
- return base;
40
- }
41
- function buildTempDownloadPath(fileName) {
42
- const id = randomUUID();
43
- const safeName = sanitizeDownloadFileName(fileName);
44
- return join(tmpdir(), "aria-downloads", `${id}-${safeName}`);
45
- }
46
- // ── Download waiter ───────────────────────────────────────────────────
47
- function createPageDownloadWaiter(page, timeoutMs) {
48
- let done = false;
49
- let timer;
50
- let handler;
51
- const cleanup = () => {
52
- if (timer) {
53
- clearTimeout(timer);
54
- }
55
- timer = undefined;
56
- if (handler) {
57
- page.off("download", handler);
58
- handler = undefined;
59
- }
60
- };
61
- const promise = new Promise((resolveP, reject) => {
62
- handler = (download) => {
63
- if (done) {
64
- return;
65
- }
66
- done = true;
67
- cleanup();
68
- resolveP(download);
69
- };
70
- page.on("download", handler);
71
- timer = setTimeout(() => {
72
- if (done) {
73
- return;
74
- }
75
- done = true;
76
- cleanup();
77
- reject(new Error("Timeout waiting for download"));
78
- }, timeoutMs);
79
- });
80
- return {
81
- promise,
82
- cancel: () => {
83
- if (done) {
84
- return;
85
- }
86
- done = true;
87
- cleanup();
88
- },
89
- };
90
- }
91
- // ── Public API ────────────────────────────────────────────────────────
92
- /**
93
- * Wait for the next download event on the page and save the file.
94
- */
95
- export async function waitForDownload(opts) {
96
- const timeout = normalizeTimeoutMs(opts.timeoutMs, 120_000);
97
- const waiter = createPageDownloadWaiter(opts.page, timeout);
98
- try {
99
- const download = (await waiter.promise);
100
- const suggested = download.suggestedFilename?.() || "download.bin";
101
- const outPath = opts.path?.trim() || buildTempDownloadPath(suggested);
102
- await mkdir(dirname(outPath), { recursive: true });
103
- await download.saveAs?.(outPath);
104
- return {
105
- url: download.url?.() || "",
106
- suggestedFilename: suggested,
107
- path: resolve(outPath),
108
- };
109
- }
110
- catch (err) {
111
- waiter.cancel();
112
- throw err;
113
- }
114
- }