fastbrowser_cli 1.0.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.
Files changed (101) hide show
  1. package/README.md +0 -0
  2. package/dist/contrib/fastweb-cli/fastweb-cli.d.ts +3 -0
  3. package/dist/contrib/fastweb-cli/fastweb-cli.d.ts.map +1 -0
  4. package/dist/contrib/fastweb-cli/fastweb-cli.js +151 -0
  5. package/dist/contrib/fastweb-cli/fastweb-cli.js.map +1 -0
  6. package/dist/contrib/fastweb-cli/http-client.d.ts +7 -0
  7. package/dist/contrib/fastweb-cli/http-client.d.ts.map +1 -0
  8. package/dist/contrib/fastweb-cli/http-client.js +51 -0
  9. package/dist/contrib/fastweb-cli/http-client.js.map +1 -0
  10. package/dist/contrib/fastweb-http-server/fastweb-http-server.d.ts +3 -0
  11. package/dist/contrib/fastweb-http-server/fastweb-http-server.d.ts.map +1 -0
  12. package/dist/contrib/fastweb-http-server/fastweb-http-server.js +82 -0
  13. package/dist/contrib/fastweb-http-server/fastweb-http-server.js.map +1 -0
  14. package/dist/contrib/fastweb-http-server/routes.d.ts +6 -0
  15. package/dist/contrib/fastweb-http-server/routes.d.ts.map +1 -0
  16. package/dist/contrib/fastweb-http-server/routes.js +41 -0
  17. package/dist/contrib/fastweb-http-server/routes.js.map +1 -0
  18. package/dist/contrib/fastweb-http-server/tool-schemas.d.ts +63 -0
  19. package/dist/contrib/fastweb-http-server/tool-schemas.d.ts.map +1 -0
  20. package/dist/contrib/fastweb-http-server/tool-schemas.js +61 -0
  21. package/dist/contrib/fastweb-http-server/tool-schemas.js.map +1 -0
  22. package/dist/fastweb_cli/fastweb_cli.d.ts +3 -0
  23. package/dist/fastweb_cli/fastweb_cli.d.ts.map +1 -0
  24. package/dist/fastweb_cli/fastweb_cli.js +254 -0
  25. package/dist/fastweb_cli/fastweb_cli.js.map +1 -0
  26. package/dist/fastweb_cli/http-client.d.ts +7 -0
  27. package/dist/fastweb_cli/http-client.d.ts.map +1 -0
  28. package/dist/fastweb_cli/http-client.js +51 -0
  29. package/dist/fastweb_cli/http-client.js.map +1 -0
  30. package/dist/fastweb_cli/libs/http-client.d.ts +7 -0
  31. package/dist/fastweb_cli/libs/http-client.d.ts.map +1 -0
  32. package/dist/fastweb_cli/libs/http-client.js +51 -0
  33. package/dist/fastweb_cli/libs/http-client.js.map +1 -0
  34. package/dist/fastweb_cli/libs/server-manager.d.ts +12 -0
  35. package/dist/fastweb_cli/libs/server-manager.d.ts.map +1 -0
  36. package/dist/fastweb_cli/libs/server-manager.js +194 -0
  37. package/dist/fastweb_cli/libs/server-manager.js.map +1 -0
  38. package/dist/fastweb_http_server/fastweb_http_server.d.ts +3 -0
  39. package/dist/fastweb_http_server/fastweb_http_server.d.ts.map +1 -0
  40. package/dist/fastweb_http_server/fastweb_http_server.js +82 -0
  41. package/dist/fastweb_http_server/fastweb_http_server.js.map +1 -0
  42. package/dist/fastweb_http_server/libs/routes.d.ts +6 -0
  43. package/dist/fastweb_http_server/libs/routes.d.ts.map +1 -0
  44. package/dist/fastweb_http_server/libs/routes.js +41 -0
  45. package/dist/fastweb_http_server/libs/routes.js.map +1 -0
  46. package/dist/fastweb_http_server/libs/tool-schemas.d.ts +72 -0
  47. package/dist/fastweb_http_server/libs/tool-schemas.d.ts.map +1 -0
  48. package/dist/fastweb_http_server/libs/tool-schemas.js +65 -0
  49. package/dist/fastweb_http_server/libs/tool-schemas.js.map +1 -0
  50. package/dist/fastweb_http_server/routes.d.ts +6 -0
  51. package/dist/fastweb_http_server/routes.d.ts.map +1 -0
  52. package/dist/fastweb_http_server/routes.js +41 -0
  53. package/dist/fastweb_http_server/routes.js.map +1 -0
  54. package/dist/fastweb_http_server/tool-schemas.d.ts +63 -0
  55. package/dist/fastweb_http_server/tool-schemas.d.ts.map +1 -0
  56. package/dist/fastweb_http_server/tool-schemas.js +61 -0
  57. package/dist/fastweb_http_server/tool-schemas.js.map +1 -0
  58. package/dist/fastweb_mcp/fastweb_mcp.d.ts +4 -0
  59. package/dist/fastweb_mcp/fastweb_mcp.d.ts.map +1 -0
  60. package/dist/fastweb_mcp/fastweb_mcp.js +417 -0
  61. package/dist/fastweb_mcp/fastweb_mcp.js.map +1 -0
  62. package/dist/fastweb_mcp/libs/mcp_client.d.ts +120 -0
  63. package/dist/fastweb_mcp/libs/mcp_client.d.ts.map +1 -0
  64. package/dist/fastweb_mcp/libs/mcp_client.js +83 -0
  65. package/dist/fastweb_mcp/libs/mcp_client.js.map +1 -0
  66. package/dist/fastweb_mcp/libs/mcp_proxy.d.ts +10 -0
  67. package/dist/fastweb_mcp/libs/mcp_proxy.d.ts.map +1 -0
  68. package/dist/fastweb_mcp/libs/mcp_proxy.js +45 -0
  69. package/dist/fastweb_mcp/libs/mcp_proxy.js.map +1 -0
  70. package/dist/fastweb_mcp/libs/schemas.d.ts +28 -0
  71. package/dist/fastweb_mcp/libs/schemas.d.ts.map +1 -0
  72. package/dist/fastweb_mcp/libs/schemas.js +38 -0
  73. package/dist/fastweb_mcp/libs/schemas.js.map +1 -0
  74. package/dist/src/fastweb_mcp.d.ts +17 -0
  75. package/dist/src/fastweb_mcp.d.ts.map +1 -0
  76. package/dist/src/fastweb_mcp.js +342 -0
  77. package/dist/src/fastweb_mcp.js.map +1 -0
  78. package/dist/src/libs/mcp_client.d.ts +120 -0
  79. package/dist/src/libs/mcp_client.d.ts.map +1 -0
  80. package/dist/src/libs/mcp_client.js +83 -0
  81. package/dist/src/libs/mcp_client.js.map +1 -0
  82. package/dist/src/libs/mcp_proxy.d.ts +10 -0
  83. package/dist/src/libs/mcp_proxy.d.ts.map +1 -0
  84. package/dist/src/libs/mcp_proxy.js +45 -0
  85. package/dist/src/libs/mcp_proxy.js.map +1 -0
  86. package/docs/brainstorm_scrap_by_ai.md +32 -0
  87. package/docs/feature_support_cli.md +86 -0
  88. package/package.json +36 -0
  89. package/src/fastweb_cli/fastweb_cli.ts +306 -0
  90. package/src/fastweb_cli/libs/http-client.ts +50 -0
  91. package/src/fastweb_cli/libs/server-manager.ts +210 -0
  92. package/src/fastweb_http_server/fastweb_http_server.ts +97 -0
  93. package/src/fastweb_http_server/libs/routes.ts +44 -0
  94. package/src/fastweb_http_server/libs/tool-schemas.ts +107 -0
  95. package/src/fastweb_mcp/fastweb_mcp.ts +475 -0
  96. package/src/fastweb_mcp/libs/mcp_client.ts +117 -0
  97. package/src/fastweb_mcp/libs/mcp_proxy.ts +48 -0
  98. package/src/fastweb_mcp/libs/schemas.ts +44 -0
  99. package/tmp/.claude/settings.local.json +7 -0
  100. package/tmp/.claude/skills/fastweb/SKILL.md +214 -0
  101. package/tsconfig.json +40 -0
@@ -0,0 +1,44 @@
1
+ // npm imports
2
+ import { z } from 'zod';
3
+
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ ///////////////////////////////////////////////////////////////////////////////
6
+ // Authoritative query selector schemas — shared between the MCP server
7
+ // and the HTTP/CLI layer. Kept out of the fastweb_mcp.ts entrypoint so
8
+ // importing the schemas does not execute the CLI's top-level `main()`.
9
+ ///////////////////////////////////////////////////////////////////////////////
10
+ ///////////////////////////////////////////////////////////////////////////////
11
+
12
+ export const QuerySelectorInputSchema = z.object({
13
+ selector: z.string()
14
+ .describe("CSS-like selector to query the accessibility tree"),
15
+ limit: z.number()
16
+ .describe("Maximum number of nodes to return (excluding ancestors). Set to 0 for no limit.")
17
+ .default(0),
18
+ withAncestors: z.boolean()
19
+ .describe("Whether to include ancestor nodes in the result")
20
+ .default(true),
21
+ });
22
+
23
+ export const QuerySelectorsInputSchema = z.object({
24
+ selectors: z.array(QuerySelectorInputSchema)
25
+ .describe("List of selectors to query the accessibility tree"),
26
+ });
27
+
28
+ export const QuerySelectorFirstInputSchema = z.object({
29
+ selector: z.string()
30
+ .describe("CSS-like selector to query the accessibility tree"),
31
+ withAncestors: z.boolean()
32
+ .describe("Whether to include ancestor nodes in the result")
33
+ .default(true),
34
+ });
35
+
36
+ export const QuerySelectorsFirstInputSchema = z.object({
37
+ selectors: z.array(QuerySelectorFirstInputSchema)
38
+ .describe("List of selectors; for each, the first matching node is returned"),
39
+ });
40
+
41
+ export type QuerySelectorInput = z.infer<typeof QuerySelectorInputSchema>;
42
+ export type QuerySelectorsInput = z.infer<typeof QuerySelectorsInputSchema>;
43
+ export type QuerySelectorFirstInput = z.infer<typeof QuerySelectorFirstInputSchema>;
44
+ export type QuerySelectorsFirstInput = z.infer<typeof QuerySelectorsFirstInputSchema>;
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npx tsx *)"
5
+ ]
6
+ }
7
+ }
@@ -0,0 +1,214 @@
1
+ ---
2
+ name: fastweb
3
+ description: >
4
+ Control a live browser from the command line: navigate, click, fill forms, and query the accessibility tree with CSS-like selectors. Lighter alternative to Chrome DevTools MCP or Puppeteer. Triggers on: navigate/click/fill actions, page snapshots, or mentions of fastweb.
5
+ ---
6
+
7
+ # fastweb Skill
8
+
9
+ `fastweb-cli` is a command-line client for the FastWeb HTTP server, which keeps a persistent
10
+ MCP connection to a Chrome browser alive so commands incur minimal latency. Each command
11
+ maps 1-to-1 to a FastWeb tool and returns the tool's response on stdout.
12
+
13
+ ## Invocation
14
+
15
+ Run the CLI directly via `tsx`:
16
+
17
+ ```bash
18
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts <command> [flags]
19
+ ```
20
+
21
+ ## Typical Workflow
22
+
23
+ 1. **Query** the accessibility tree for specific nodes: `query_selectors` (first match per selector) or `query_selectors_all` (every match per selector).
24
+ 2. **Act** on an element by its accessibility selector: `click`, `fill_form`, `press_keys`. The selector can be a direct uid reference (e.g. `#1_42`, fastest path) or any CSS-like selector (e.g. `button[name="Submit"]`), which is resolved to a uid internally.
25
+
26
+ Snapshot output looks like:
27
+
28
+ ```
29
+ uid=1_0 RootWebArea "Example Domain" url="https://example.com/"
30
+ uid=1_1 heading "Example Domain" level="1"
31
+ uid=1_2 link "More information..." url="https://www.iana.org/..."
32
+ ```
33
+
34
+ ## Page Management
35
+
36
+ ```bash
37
+ # List all open browser pages
38
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts list_pages
39
+
40
+ # Open a new page at a URL
41
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts new_page --url https://example.com
42
+
43
+ # Close a page by its numeric id
44
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts close_page --page-id 1
45
+
46
+ # Navigate the current page to a URL
47
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts navigate_page --url https://example.com
48
+ ```
49
+
50
+
51
+ ## Selector Language
52
+
53
+ The selector syntax is modelled on CSS selectors, adapted for accessibility tree structures.
54
+
55
+ ### Role selector
56
+
57
+ Matches nodes by their accessibility role.
58
+
59
+ ```
60
+ button
61
+ link
62
+ comboxbox
63
+ searchbox
64
+ heading
65
+ WebArea
66
+ ```
67
+
68
+ ### Universal selector
69
+
70
+ Matches any node.
71
+
72
+ ```
73
+ *
74
+ ```
75
+
76
+ ### UID selector
77
+
78
+ Matches a node by its exact unique identifier.
79
+
80
+ ```
81
+ #4
82
+ #1_3
83
+ ```
84
+
85
+ ### Attribute selectors
86
+
87
+ Attribute selectors match values inside `node.attributes`. The special virtual attribute `name` maps to `node.name`.
88
+
89
+ | Syntax | Semantics |
90
+ |--------|-----------|
91
+ | `[attr]` | attribute is present |
92
+ | `[attr="value"]` | exact match |
93
+ | `[attr^="prefix"]` | starts with |
94
+ | `[attr$="suffix"]` | ends with |
95
+ | `[attr*="sub"]` | contains substring |
96
+
97
+ ```
98
+ link[href]
99
+ button[disabled="true"]
100
+ link[href^="https"]
101
+ link[href$=".com"]
102
+ link[href*="example"]
103
+ heading[name="Welcome"]
104
+ link[name="Click \"here\""]
105
+ ```
106
+
107
+ ### Combinators
108
+
109
+ | Syntax | Semantics |
110
+ |--------|-----------|
111
+ | `A B` | B is a descendant of A (any depth) |
112
+ | `A > B` | B is a direct child of A |
113
+ | `A, B` | union — matches A or B |
114
+
115
+ ```
116
+ WebArea link
117
+ main > button
118
+ heading, button
119
+ RootWebArea > link[href^="https"]
120
+ ```
121
+
122
+ ### Examples
123
+
124
+ Sample accessibility tree:
125
+
126
+ ```
127
+ uid=1 WebArea "Main Page"
128
+ uid=2 main
129
+ uid=3 heading "Welcome"
130
+ uid=4 link "Click here" href="https://example.com"
131
+ uid=5 button "Submit" disabled="true"
132
+ uid=6 navigation
133
+ uid=7 link "Home" href="/"
134
+ uid=8 link "About" href="/about"
135
+ ```
136
+
137
+ Example queries on it:
138
+ - `link` matches all the links (uid=4, uid=7, uid=8)
139
+ - 'navigation > link' matches only the links that are direct children of navigation (uid=7, uid=8)
140
+ - `link[href^="https"]` matches links with an external href (uid=4)
141
+ - `button[name="Submit"]` matches the submit button by name (uid=5)
142
+ - `*[disabled="true"]` matches any disabled element (uid=5)
143
+ - `heading, button` matches both headings and buttons in one query (uid=3, uid=5)
144
+ - `#7` matches a node by its UID (uid=7)
145
+
146
+ ## Inspection
147
+
148
+ - `query_selectors` and `query_selectors_all` are the most efficient way to get specific elements or data from the page. Use them instead of `take_snapshot` whenever possible.
149
+ - Prefer `query_selectors` when you only need the first match per selector (cheaper, less output); use `query_selectors_all` when you need every match or want to cap with `--limit`.
150
+
151
+ ```bash
152
+ # Query the accessibility tree returning the FIRST match per selector (--selector is repeatable)
153
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts query_selectors --selector "button" --selector "link"
154
+
155
+ # Exclude ancestor nodes from the result
156
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts query_selectors --selector 'heading[level="1"]' --no-with-ancestors
157
+
158
+ # Per-selector control over withAncestors via JSON
159
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts query_selectors \
160
+ --selectors-json '[{"selector":"button","withAncestors":true},{"selector":"link","withAncestors":false}]'
161
+
162
+ # Query the accessibility tree returning ALL matches per selector (--selector is repeatable)
163
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts query_selectors_all --selector "button" --selector "link" --limit 5
164
+
165
+ # Exclude ancestor nodes from the result
166
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts query_selectors_all --selector 'heading[level="1"]' --no-with-ancestors
167
+
168
+ # Per-selector control over limit / withAncestors via JSON
169
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts query_selectors_all \
170
+ --selectors-json '[{"selector":"button","limit":3,"withAncestors":true},{"selector":"link","limit":0,"withAncestors":false}]'
171
+
172
+ # Take an accessibility-tree full page snapshot of the current page - very expensive, prefer targeted queries when possible
173
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts take_snapshot
174
+ ```
175
+
176
+ ## Interaction
177
+
178
+ ```bash
179
+ # Click by a direct uid reference (fast path - no accessibility-tree lookup)
180
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts click --selector "#1_42"
181
+
182
+ # Click by any CSS-like selector - resolved to a uid internally
183
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts click -s 'button[name="Submit"]'
184
+
185
+ # Fill a single form field - selector can be a uid (#1_7) or any CSS-like selector
186
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts fill_form -s 'textbox[name="Email"]' --value "hello@example.com"
187
+
188
+ # Press a comma-separated sequence of keys (literals and named keys both work)
189
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts press_keys --keys "Tab, Tab, Enter"
190
+ npx tsx ../src/fastweb_cli/fastweb_cli.ts press_keys --keys "Hello, Tab, Enter"
191
+ ```
192
+
193
+ ## Command Reference
194
+
195
+ | Command | Purpose | Required flags |
196
+ |---------|---------|----------------|
197
+ | `list_pages` | List open browser pages | — |
198
+ | `new_page` | Open a new page at a URL | `--url` |
199
+ | `close_page` | Close a page by id | `--page-id` |
200
+ | `navigate_page` | Navigate current page to a URL | `--url` |
201
+ | `take_snapshot` | Dump the accessibility tree of the whole page - very expensive, prefer targeted queries (`query_selectors` / `query_selectors_all`) when possible | — |
202
+ | `query_selectors` | Query a11y tree by CSS-like selector, returning the first match per selector | `--selector` or `--selectors-json` |
203
+ | `query_selectors_all` | Query a11y tree by CSS-like selector, returning every match per selector | `--selector` or `--selectors-json` |
204
+ | `click` | Click an element by accessibility selector | `--selector` / `-s` |
205
+ | `fill_form` | Fill a form field by accessibility selector | `--selector` / `-s`, `--value` |
206
+ | `press_keys` | Press a comma-separated key sequence | `--keys` |
207
+ | `server start` | Start the HTTP server daemon | — |
208
+ | `server status` | Report server running/stopped | — |
209
+ | `server stop` | Stop the HTTP server | — |
210
+
211
+ ## Output & Errors
212
+
213
+ Tool output is written to **stdout** — one line per response content part. On failure the
214
+ CLI writes `fastweb-cli error: <message>` to **stderr** and exits with code 1.
package/tsconfig.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": [
6
+ "ES2020",
7
+ "DOM"
8
+ ],
9
+ "types": [
10
+ "node"
11
+ ],
12
+ "outDir": "./dist",
13
+ "rootDir": "./src",
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true,
17
+ "strict": true,
18
+ "noImplicitAny": true,
19
+ "strictNullChecks": true,
20
+ "strictFunctionTypes": true,
21
+ "strictBindCallApply": true,
22
+ "strictPropertyInitialization": true,
23
+ "noImplicitThis": true,
24
+ "alwaysStrict": true,
25
+ "noImplicitReturns": true,
26
+ "noFallthroughCasesInSwitch": true,
27
+ "esModuleInterop": true,
28
+ "skipLibCheck": true,
29
+ "forceConsistentCasingInFileNames": true,
30
+ "resolveJsonModule": true,
31
+ "isolatedModules": true
32
+ },
33
+ "include": [
34
+ "src/**/*"
35
+ ],
36
+ "exclude": [
37
+ "node_modules",
38
+ "dist"
39
+ ]
40
+ }