crawlio-browser 1.5.0 → 1.5.2

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.
@@ -1,7 +1,7 @@
1
1
  // src/shared/constants.ts
2
2
  import { homedir } from "os";
3
3
  import { join } from "path";
4
- var PKG_VERSION = "1.5.0";
4
+ var PKG_VERSION = "1.5.2";
5
5
  var WS_PORT = 9333;
6
6
  var WS_PORT_MAX = 9342;
7
7
  var WS_HOST = "127.0.0.1";
@@ -9,7 +9,7 @@ import {
9
9
  WS_PORT_MAX,
10
10
  WS_RECONNECT_GRACE,
11
11
  WS_STALE_THRESHOLD
12
- } from "./chunk-GJH6PLST.js";
12
+ } from "./chunk-BKBNDFXW.js";
13
13
 
14
14
  // src/mcp-server/index.ts
15
15
  import { randomBytes as randomBytes2 } from "crypto";
@@ -4112,7 +4112,7 @@ function createCodeModeTools(bridge2, crawlio2) {
4112
4112
  process.title = "Crawlio Agent";
4113
4113
  var initMode = process.argv.includes("init") || process.argv.includes("--setup") || process.argv.includes("setup");
4114
4114
  if (initMode) {
4115
- const { runInit } = await import("./init-CG5XREFD.js");
4115
+ const { runInit } = await import("./init-5MP7GP7G.js");
4116
4116
  await runInit(process.argv.slice(2));
4117
4117
  process.exit(0);
4118
4118
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PKG_VERSION
3
- } from "./chunk-GJH6PLST.js";
3
+ } from "./chunk-BKBNDFXW.js";
4
4
 
5
5
  // src/mcp-server/init.ts
6
6
  import { execFileSync, spawn } from "child_process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crawlio-browser",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "MCP server with 96 CDP-backed tools for browser automation — screenshots, DOM, network capture, framework detection, cookies, storage, session recording, performance metrics via Chrome",
5
5
  "type": "module",
6
6
  "main": "dist/mcp-server/index.js",
@@ -36,6 +36,13 @@ Check connection status anytime:
36
36
  return await bridge.send({ type: "get_connection_status" })
37
37
  ```
38
38
 
39
+ ## Critical Rules
40
+
41
+ 1. **ALWAYS `search` before `execute`** when you're unsure of a command name or its parameters. Never guess command names — they will fail.
42
+ 2. **Return values are objects**, not primitives. Always destructure or access properties (see Return Value Shapes below).
43
+ 3. **`close_tab` requires `tabId`** — it will error without one. Get tabId from `list_tabs` or `connect_tab`.
44
+ 4. **`connect_tab` before any interaction** — most commands require an active tab connection.
45
+
39
46
  ## Core Patterns via `execute`
40
47
 
41
48
  All browser commands run inside the `execute` tool. The code has access to:
@@ -54,10 +61,10 @@ return await smart.navigate("https://example.com")
54
61
  ### Screenshots
55
62
 
56
63
  ```js
57
- return await smart.screenshot()
64
+ return await bridge.send({ type: 'take_screenshot' })
58
65
  ```
59
66
 
60
- Returns base64 PNG. Use `{ fullPage: true }` for full-page capture.
67
+ Returns `{ screenshot: string }` (base64 PNG). For full-page: `bridge.send({ type: 'take_screenshot', fullPage: true })`.
61
68
 
62
69
  ### OCR Text Extraction (macOS only)
63
70
 
@@ -105,7 +112,7 @@ return await smart.snapshot()
105
112
  return await smart.snapshot()
106
113
  ```
107
114
 
108
- Returns the a11y tree use this to discover available elements when selectors fail.
115
+ Returns `{ snapshot: string }` — the a11y tree text. Use this to discover available elements when selectors fail.
109
116
 
110
117
  ### Evaluate JavaScript
111
118
 
@@ -284,6 +291,65 @@ return await crawlio.api("GET", "/settings")
284
291
  return await crawlio.api("POST", "/export", { format: "zip", destinationPath: "/tmp/site.zip" })
285
292
  ```
286
293
 
294
+ ## Return Value Shapes
295
+
296
+ Commands return **objects**, not primitives. Always access the correct property.
297
+
298
+ ### smart methods
299
+
300
+ ```js
301
+ // smart.snapshot() → { snapshot: string }
302
+ const snap = await smart.snapshot();
303
+ const tree = snap.snapshot; // the a11y tree text
304
+ // WRONG: snap.split('\n') — snap is an object, not a string
305
+
306
+ // smart.evaluate(expr) → { result: any, type: string }
307
+ const res = await smart.evaluate("document.title");
308
+ const title = res.result; // the actual value
309
+ const type = res.type; // "string", "number", "object", etc.
310
+ // WRONG: res.substring() — res is an object, not the raw value
311
+ ```
312
+
313
+ ### bridge.send commands
314
+
315
+ ```js
316
+ // list_tabs → { tabs: Tab[], connectedTabId: number|null }
317
+ const result = await bridge.send({ type: 'list_tabs' });
318
+ const tabs = result.tabs; // array of tab objects
319
+ const connected = result.connectedTabId;
320
+
321
+ // connect_tab → { action, tabId, url, title, windowId, capturing, domainState }
322
+ const tab = await bridge.send({ type: 'connect_tab', tabId: 123 });
323
+
324
+ // capture_page → { url, title, framework, network, console, cookies, dom, capturedAt }
325
+ const page = await bridge.send({ type: 'capture_page' });
326
+
327
+ // take_screenshot → { screenshot: string } (base64 PNG)
328
+ const ss = await bridge.send({ type: 'take_screenshot' });
329
+
330
+ // get_cookies → { cookies: Cookie[] }
331
+ const result = await bridge.send({ type: 'get_cookies' });
332
+ const cookies = result.cookies;
333
+
334
+ // get_console_logs → { logs: LogEntry[] }
335
+ const result = await bridge.send({ type: 'get_console_logs' });
336
+ const logs = result.logs;
337
+
338
+ // close_tab → requires tabId!
339
+ await bridge.send({ type: 'close_tab', tabId: 123 }); // REQUIRED
340
+ // WRONG: bridge.send({ type: 'close_tab' }) — will error
341
+ ```
342
+
343
+ ### Network capture (start/stop pattern — no `get_network_entries`)
344
+
345
+ ```js
346
+ await bridge.send({ type: 'start_network_capture' });
347
+ // ... interactions ...
348
+ const result = await bridge.send({ type: 'stop_network_capture' });
349
+ const entries = result.entries; // array of network entries
350
+ // WRONG: bridge.send({ type: 'get_network_entries' }) — does NOT exist
351
+ ```
352
+
287
353
  ## Error Handling
288
354
 
289
355
  | Error | Solution |
@@ -309,8 +375,8 @@ await smart.click("button[type='submit']")
309
375
  await sleep(2000)
310
376
 
311
377
  // 4. Verify navigation
312
- const title = await smart.evaluate("document.title")
313
- return { title, url: await smart.evaluate("location.href") }
378
+ const title = (await smart.evaluate("document.title")).result
379
+ return { title, url: (await smart.evaluate("location.href")).result }
314
380
  ```
315
381
 
316
382
  ## Reference