agentbrowse 0.1.0 → 0.1.1

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +57 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -42,7 +42,7 @@ Sessions are isolated by `--session <id>` (default `default`), each with its own
42
42
  | `read [url]` | Current page (or open `<url>` first) as token-bounded markdown (`--max-chars`, `--page`) |
43
43
  | `links [url]` | Numbered, followable links (`--filter`) |
44
44
  | `snapshot [url]` | **Accessibility-tree view**: every actionable element with a stable `[ref]`, role, name, state (`--filter`, `--max`, `--json`). The robust way to act |
45
- | `find <text>` | Locate elements by visible text; numbers reusable by `click` |
45
+ | `find <text>` | Locate elements by visible text (falls back to accessible name); numbers reusable by `click` |
46
46
  | `click <target>` | Click by a `snapshot` ref (robust), visible text, a `links`/`find` number, or a CSS selector |
47
47
  | `type <field> <text>` | Type into a field (CSS selector or bare `name`) |
48
48
  | `fill -f name=value …` | Fill form fields |
package/dist/cli.js CHANGED
@@ -3,6 +3,52 @@
3
3
  // src/cli.ts
4
4
  import { Command } from "commander";
5
5
 
6
+ // package.json
7
+ var package_default = {
8
+ name: "agentbrowse",
9
+ version: "0.1.1",
10
+ description: "Agent-browser CLI: drive any website from the terminal.",
11
+ type: "module",
12
+ bin: {
13
+ agentbrowse: "dist/cli.js"
14
+ },
15
+ files: [
16
+ "dist",
17
+ "AGENTS.md"
18
+ ],
19
+ engines: {
20
+ node: ">=20"
21
+ },
22
+ scripts: {
23
+ build: "tsup",
24
+ dev: "tsx src/cli.ts",
25
+ test: "vitest run",
26
+ "test:watch": "vitest",
27
+ prepublishOnly: "npm run build && npm test"
28
+ },
29
+ dependencies: {
30
+ "@mozilla/readability": "^0.6.0",
31
+ ajv: "^8.17.1",
32
+ commander: "^12.1.0",
33
+ jsdom: "^24.1.0",
34
+ playwright: "^1.45.0",
35
+ turndown: "^7.2.0"
36
+ },
37
+ devDependencies: {
38
+ "@types/jsdom": "^21.1.0",
39
+ "@types/node": "^20.14.0",
40
+ "@types/turndown": "^5.0.4",
41
+ tsup: "^8.1.0",
42
+ tsx: "^4.16.0",
43
+ typescript: "^5.5.0",
44
+ vitest: "^2.0.0"
45
+ },
46
+ repository: {
47
+ type: "git",
48
+ url: "git+https://github.com/mandarwagh9/agentbrowse.git"
49
+ }
50
+ };
51
+
6
52
  // src/daemon/client.ts
7
53
  import net from "net";
8
54
  import path2 from "path";
@@ -744,7 +790,16 @@ async function startDaemon(sessionId, opts = {}) {
744
790
  case "find": {
745
791
  const text = String(req.args?.text ?? "");
746
792
  if (!text) return err(req, "bad_args", "find requires text");
747
- const matches = await page.getByText(text, { exact: false }).all();
793
+ let matches = await page.getByText(text, { exact: false }).all();
794
+ if (matches.length === 0) {
795
+ const needle = text.toLowerCase();
796
+ const named = parseAriaSnapshot(await page.locator("body").ariaSnapshot()).filter(
797
+ (e) => e.actionable && e.name.toLowerCase().includes(needle)
798
+ );
799
+ matches = named.map(
800
+ (e) => page.getByRole(e.role, { name: e.name, exact: true }).nth(e.nth)
801
+ );
802
+ }
748
803
  lastRefs = matches.map((locator) => ({ kind: "element", locator }));
749
804
  const items = await Promise.all(
750
805
  matches.map(async (loc, i) => ({
@@ -911,7 +966,7 @@ async function emit(produce) {
911
966
  }
912
967
  function buildProgram() {
913
968
  const program = new Command();
914
- program.name("agentbrowse").description("Agent-browser CLI: drive any website from the terminal.").version("0.0.1").option("--session <id>", "session name (isolated browser + cookies)", "default");
969
+ program.name("agentbrowse").description("Agent-browser CLI: drive any website from the terminal.").version(package_default.version).option("--session <id>", "session name (isolated browser + cookies)", "default");
915
970
  const session = (cmd) => cmd.optsWithGlobals().session;
916
971
  program.command("open").description("Navigate the session's browser to a URL.").argument("<url>", "URL to open").option("--json", "structured JSON output", false).action((url, opts, cmd) => emit(() => runOpen({ session: session(cmd), json: !!opts.json, url })));
917
972
  program.command("read").description("Read the current page (or open <url> first) as token-bounded markdown.").argument("[url]", "optional URL to open before reading").option("--json", "structured JSON output", false).option("--max-chars <n>", "max characters per page", (v) => parseInt(v, 10), 8e3).option("--page <n>", "page number when output is truncated", (v) => parseInt(v, 10), 1).action(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbrowse",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Agent-browser CLI: drive any website from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {