@dikshanty94/webnav 0.2.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 (145) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +283 -0
  3. package/bin/webnav +18 -0
  4. package/dist/agent/loop.d.ts +59 -0
  5. package/dist/agent/loop.js +267 -0
  6. package/dist/agent/server.d.ts +60 -0
  7. package/dist/agent/server.js +254 -0
  8. package/dist/cli-help.d.ts +3 -0
  9. package/dist/cli-help.js +111 -0
  10. package/dist/cli-spec.d.ts +24 -0
  11. package/dist/cli-spec.js +460 -0
  12. package/dist/cli.d.ts +208 -0
  13. package/dist/cli.js +2558 -0
  14. package/dist/contract.d.ts +20 -0
  15. package/dist/contract.js +15 -0
  16. package/dist/creds.d.ts +46 -0
  17. package/dist/creds.js +126 -0
  18. package/dist/dashboard/server.d.ts +137 -0
  19. package/dist/dashboard/server.js +395 -0
  20. package/dist/dashboard/shell.d.ts +1 -0
  21. package/dist/dashboard/shell.js +1343 -0
  22. package/dist/explorer/analyse.d.ts +25 -0
  23. package/dist/explorer/analyse.js +39 -0
  24. package/dist/explorer/diff.d.ts +11 -0
  25. package/dist/explorer/diff.js +22 -0
  26. package/dist/explorer/draft.d.ts +81 -0
  27. package/dist/explorer/draft.js +1658 -0
  28. package/dist/explorer/fingerprint-page.d.ts +11 -0
  29. package/dist/explorer/fingerprint-page.js +19 -0
  30. package/dist/explorer/fingerprint.d.ts +14 -0
  31. package/dist/explorer/fingerprint.js +18 -0
  32. package/dist/explorer/infer.d.ts +85 -0
  33. package/dist/explorer/infer.js +370 -0
  34. package/dist/explorer/pattern-propose.d.ts +27 -0
  35. package/dist/explorer/pattern-propose.js +81 -0
  36. package/dist/explorer/patterns.d.ts +49 -0
  37. package/dist/explorer/patterns.js +290 -0
  38. package/dist/explorer/shadow.d.ts +3 -0
  39. package/dist/explorer/shadow.js +95 -0
  40. package/dist/graph/coverage.d.ts +33 -0
  41. package/dist/graph/coverage.js +155 -0
  42. package/dist/graph/edit.d.ts +47 -0
  43. package/dist/graph/edit.js +211 -0
  44. package/dist/graph/frontier.d.ts +24 -0
  45. package/dist/graph/frontier.js +95 -0
  46. package/dist/graph/seed.d.ts +23 -0
  47. package/dist/graph/seed.js +29 -0
  48. package/dist/graph/show.d.ts +8 -0
  49. package/dist/graph/show.js +6 -0
  50. package/dist/graph/teach.d.ts +8 -0
  51. package/dist/graph/teach.js +10 -0
  52. package/dist/hosted.d.ts +36 -0
  53. package/dist/hosted.js +69 -0
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.js +4 -0
  56. package/dist/mapstore/record.d.ts +128 -0
  57. package/dist/mapstore/record.js +224 -0
  58. package/dist/mapstore/schema.sql +47 -0
  59. package/dist/mapstore/store.d.ts +108 -0
  60. package/dist/mapstore/store.js +399 -0
  61. package/dist/mapstore/types.d.ts +87 -0
  62. package/dist/mapstore/types.js +29 -0
  63. package/dist/mcp/server.d.ts +46 -0
  64. package/dist/mcp/server.js +163 -0
  65. package/dist/paths.d.ts +10 -0
  66. package/dist/paths.js +33 -0
  67. package/dist/playwright/adapter.d.ts +62 -0
  68. package/dist/playwright/adapter.js +145 -0
  69. package/dist/playwright/ax-adapter.d.ts +33 -0
  70. package/dist/playwright/ax-adapter.js +76 -0
  71. package/dist/playwright/capture.d.ts +2 -0
  72. package/dist/playwright/capture.js +10 -0
  73. package/dist/playwright/fingerprint.d.ts +40 -0
  74. package/dist/playwright/fingerprint.js +139 -0
  75. package/dist/playwright/profile-lock.d.ts +15 -0
  76. package/dist/playwright/profile-lock.js +51 -0
  77. package/dist/playwright/sessions.d.ts +72 -0
  78. package/dist/playwright/sessions.js +229 -0
  79. package/dist/playwright/snapshot.d.ts +10 -0
  80. package/dist/playwright/snapshot.js +52 -0
  81. package/dist/playwright/throttle.d.ts +14 -0
  82. package/dist/playwright/throttle.js +76 -0
  83. package/dist/playwright/video.d.ts +13 -0
  84. package/dist/playwright/video.js +32 -0
  85. package/dist/protocol.d.ts +49 -0
  86. package/dist/protocol.js +3 -0
  87. package/dist/recorder/agent-session.d.ts +59 -0
  88. package/dist/recorder/agent-session.js +230 -0
  89. package/dist/recorder/capture-loop.d.ts +19 -0
  90. package/dist/recorder/capture-loop.js +40 -0
  91. package/dist/recorder/coverage.d.ts +22 -0
  92. package/dist/recorder/coverage.js +49 -0
  93. package/dist/recorder/hover-probe.d.ts +35 -0
  94. package/dist/recorder/hover-probe.js +100 -0
  95. package/dist/recorder/ingest.d.ts +39 -0
  96. package/dist/recorder/ingest.js +138 -0
  97. package/dist/recorder/live-record.d.ts +41 -0
  98. package/dist/recorder/live-record.js +255 -0
  99. package/dist/recorder/live.d.ts +53 -0
  100. package/dist/recorder/live.js +400 -0
  101. package/dist/recorder/probe.d.ts +14 -0
  102. package/dist/recorder/probe.js +33 -0
  103. package/dist/recorder/replay.d.ts +60 -0
  104. package/dist/recorder/replay.js +401 -0
  105. package/dist/recorder/review.d.ts +73 -0
  106. package/dist/recorder/review.js +171 -0
  107. package/dist/recorder/snapshot-dom.d.ts +7 -0
  108. package/dist/recorder/snapshot-dom.js +25 -0
  109. package/dist/router/auth-status.d.ts +20 -0
  110. package/dist/router/auth-status.js +55 -0
  111. package/dist/router/browse.d.ts +108 -0
  112. package/dist/router/browse.js +214 -0
  113. package/dist/router/catalog.d.ts +18 -0
  114. package/dist/router/catalog.js +6 -0
  115. package/dist/router/extract-content.d.ts +13 -0
  116. package/dist/router/extract-content.js +87 -0
  117. package/dist/router/live-extension-browser.d.ts +35 -0
  118. package/dist/router/live-extension-browser.js +175 -0
  119. package/dist/router/path.d.ts +7 -0
  120. package/dist/router/path.js +55 -0
  121. package/dist/router/read.d.ts +26 -0
  122. package/dist/router/read.js +30 -0
  123. package/dist/router/readiness.d.ts +9 -0
  124. package/dist/router/readiness.js +55 -0
  125. package/dist/router/replay.d.ts +14 -0
  126. package/dist/router/replay.js +23 -0
  127. package/dist/router/resolve.d.ts +21 -0
  128. package/dist/router/resolve.js +33 -0
  129. package/dist/router/search-live.d.ts +21 -0
  130. package/dist/router/search-live.js +98 -0
  131. package/dist/router/search-providers.d.ts +5 -0
  132. package/dist/router/search-providers.js +12 -0
  133. package/dist/router/search.d.ts +6 -0
  134. package/dist/router/search.js +62 -0
  135. package/dist/router/suite.d.ts +69 -0
  136. package/dist/router/suite.js +226 -0
  137. package/dist/router/tokens.d.ts +13 -0
  138. package/dist/router/tokens.js +26 -0
  139. package/dist/router/walk-live.d.ts +57 -0
  140. package/dist/router/walk-live.js +308 -0
  141. package/dist/router/walk-session.d.ts +49 -0
  142. package/dist/router/walk-session.js +90 -0
  143. package/dist/router/walk.d.ts +48 -0
  144. package/dist/router/walk.js +384 -0
  145. package/package.json +59 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Dikshant Yadav
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,283 @@
1
+ # webnav
2
+
3
+ [![CI](https://github.com/lucyfuur94/webnav-core/actions/workflows/ci.yml/badge.svg)](https://github.com/lucyfuur94/webnav-core/actions/workflows/ci.yml)
4
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6.svg)](https://www.typescriptlang.org/)
6
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
7
+ ![zero-LLM](https://img.shields.io/badge/runtime-zero--LLM-7c4dff.svg)
8
+
9
+ **Stop your web-browsing AI agent from re-exploring the same sites every run.** Your agent maps
10
+ a website **once** — then travels it forever with `webnav walk`: deterministic, zero-LLM,
11
+ page-to-page autopilot that pauses only at genuine forks (what to buy, an irreversible button)
12
+ and hands the wheel back. It's a **reusable site map, not page compression** — most token-saving
13
+ tools shrink what the agent *reads*; webnav remembers *where things are* so it stops re-finding
14
+ the route. webnav is the map and the mechanics; the agent keeps all the judgment.
15
+
16
+ ## See it
17
+
18
+ A real run against saucedemo's full checkout flow (map + credentials already recorded):
19
+
20
+ ```console
21
+ $ webnav walk --start www.saucedemo.com:login --goal www.saucedemo.com:checkout-overview
22
+ { "status": "needs-navigation",
23
+ "semanticStep": "open the shopping cart",
24
+ "question": "before \"open the shopping cart\", fire these in-page affordances: aff_addcart",
25
+ "snapshot": "…", "session": "walk-w-…", "browserSession": "w-…" }
26
+ # ^ paused at a REAL fork: webnav won't decide what you buy. The agent picks from the snapshot:
27
+
28
+ $ webnav use click e54 --session w-… # add-to-cart — the agent's one judgment call
29
+ $ webnav walk-resume walk-w-… --ref e124 # continue; e124 = the icon-only cart badge
30
+ { "status": "done", "cost": { "playwright_calls": 12 } }
31
+ ```
32
+
33
+ **4 agent-visible CLI calls**, login → inventory → cart → checkout form (**auto-filled from
34
+ locally-stored creds** — never in the map) → overview. 12 browser actions underneath, zero
35
+ agent tokens spent on navigation.
36
+
37
+ In our [navigation benchmark](bench/results/2026-06-13-nav-v2.md) (both arms on Haiku, the same
38
+ browser underneath), on a deep multi-step route **`walk` used ~3× fewer agent steps than an agent
39
+ ad-hoc-driving the raw browser — median 6 calls vs 18 — and reached the goal more reliably (3/3 vs
40
+ 2/3).** Honest caveat, also in that file: the win shows up on *deep, reliably-walked* routes; on
41
+ shallow 1–2-hop routes, or when the agent falls back to manual driving, the two tie. webnav helps
42
+ most exactly where ad-hoc driving hurts most — the long, repeated journeys.
43
+
44
+ ## Drive a tab from a side panel (Chrome extension)
45
+
46
+ There's also a Chrome extension in [`webnav-extension/`](webnav-extension/) — a docked side
47
+ panel where you type a goal and watch the agent drive your **active tab** (read / click / type /
48
+ scroll, via `chrome.debugger`/CDP), on your own Claude Code subscription. It **recalls first**
49
+ (`list_routes` → `check_route`) so a site you've mapped is replayed, not re-explored — and every
50
+ run is recorded back into the map, so the *next* time is the cheap deterministic `walk`.
51
+
52
+ <img src="docs/media/extension-sidebar-light.png#gh-light-mode-only" alt="webnav agent side panel — a goal, recall-first action trail, and a streamed reply" width="420">
53
+ <img src="docs/media/extension-sidebar-dark.png#gh-dark-mode-only" alt="webnav agent side panel — a goal, recall-first action trail, and a streamed reply" width="420">
54
+
55
+ - **Ask** (approve a plan first) or **Act** (run on its own); irreversible steps (pay / place
56
+ order / delete) always pause for you.
57
+ - **Watch every step** — narration + the tool trail render live; a cursor glides to each action.
58
+ - **Take over** any time, drive by hand, hand back.
59
+
60
+ **Try it** (needs the local server for the zero-LLM navigation + recording):
61
+
62
+ ```console
63
+ cd webnav-extension && npm i && npm run build # emits the *.js next to *.ts
64
+ webnav dev agent-serve --port 7779 # prints a token — paste it into the panel
65
+ ```
66
+
67
+ Then `chrome://extensions` → Developer mode → **Load unpacked** → pick `webnav-extension/`,
68
+ open the panel (toolbar icon or **⌘/Ctrl-E**), paste the token, and type a goal. Runs show up on
69
+ the dashboard tagged **Extension**. Full walkthrough: [`webnav-extension/README.md`](webnav-extension/README.md).
70
+
71
+ ## Why
72
+
73
+ Web agents re-discover the same websites every single day, paying the same token bill every
74
+ time: snapshot → reason → click → snapshot. For sites you (or your agents) use repeatedly —
75
+ internal tools, automation testing, back-office workflows — that navigation should be
76
+ **remembered, not re-reasoned**. webnav stores the durable *intent* of each step, replays it
77
+ deterministically, self-heals when the site drifts, and **never** auto-fires an irreversible
78
+ action: commit points always pause for the agent (or you) to decide.
79
+
80
+ ## Quickstart (≈60 seconds to a working walk)
81
+
82
+ ```bash
83
+ npm install && npm link # Node 18/20/22; installs `webnav` on PATH (runs src via tsx — NO build step)
84
+ # also needs `playwright-cli` on PATH
85
+
86
+ # walk a site WITHOUT learning it — import a map someone already made:
87
+ webnav dev import-map mappacks/orangehrm.mappack.json # 17 states, in-page repertoire + domain shadow
88
+ webnav dev creds set opensource-demo.orangehrmlive.com username=Admin password=admin123 # YOUR creds, local only
89
+ webnav walk --start opensource-demo.orangehrmlive.com:auth-login \
90
+ --goal opensource-demo.orangehrmlive.com:recruitment-viewcandidates --headless
91
+ # → webnav drives login → dashboard → … → the Candidates list, pausing only at genuine forks.
92
+
93
+ webnav dev list # the sites you have maps for (saucedemo ships seeded by default)
94
+ ```
95
+
96
+ Three packs ship in [`mappacks/`](mappacks/) (saucedemo · OrangeHRM · automationexercise) — skeleton
97
+ only, never credentials. To map **your own** site, hand an agent the prompt in
98
+ [`docs/LEARNING-A-SITE.md`](docs/LEARNING-A-SITE.md). Dev/contributor commands:
99
+
100
+ ```bash
101
+ webnav --help # the tool menu (a peer of playwright-cli)
102
+ npm test # unit tests (+ gated browser e2e)
103
+ npm run build # tsc -> dist/ (only for the published build; the CLI runs src directly)
104
+ ```
105
+
106
+ **Using it from an MCP client (Claude Desktop/Code, etc.)** — webnav serves every verb as an MCP
107
+ tool over stdio, so your agent gets `walk`/`use`/`search`/… natively, no shelling out. One line:
108
+
109
+ ```json
110
+ { "mcpServers": { "webnav": { "command": "webnav", "args": ["mcp"] } } }
111
+ ```
112
+
113
+ ## How the map grows (start here if you're new)
114
+
115
+ webnav is a **map** — and a fresh install is **not** blank, but it is small. Here's
116
+ honestly what you get and how it grows, so there are no surprises:
117
+
118
+ - **What ships, out of the box.** The first time you run any verb, webnav seeds a shared
119
+ map at **`~/.webnav/webnav.db`** (per-user, shared across every terminal/folder on the
120
+ machine — *not* a per-directory file). It comes pre-seeded with **one** worked example:
121
+ **saucedemo.com** — a full login→browse→cart→checkout `walk` map. This works immediately:
122
+ ```bash
123
+ webnav walk --start www.saucedemo.com:login \
124
+ --goal www.saucedemo.com:checkout-complete # saucedemo, seeded
125
+ ```
126
+ Nothing else is seeded — webnav is a blank-slate map tool, and saucedemo is the single
127
+ example that proves it works. **You record your own sites** (see below); that's the
128
+ product. This fits any flow you repeat against the same site: automation testing,
129
+ internal tools, back-office workflows, recurring agent tasks. (An earlier GitHub-recall
130
+ + internet-graph engine — the v1 proof-of-engine — was removed from the tree 2026-06-13;
131
+ it lives in git history if that surface ever returns.)
132
+ - **The map persists and self-heals.** It's saved to `~/.webnav/webnav.db` and reused on
133
+ every run — you do **not** rebuild it each time. When a remembered step drifts (a renamed
134
+ or moved element), a `walk` escalates once for the agent to pick the element, then **writes
135
+ the fix back** so the next run resolves it deterministically (principle #3). Routes you use
136
+ stay fresh. Credentials for login-gated sites live **outside** the
137
+ map, locally, at `~/.webnav/credentials.json` (chmod 600) — never in the DB, never shared.
138
+ - **Mapping a NEW site — hand your AGENT the learn prompt.** webnav is built for agents, so you
139
+ don't map by hand: you give an agent (even a cheap one — we use Haiku) the reusable prompt in
140
+ **[`docs/LEARNING-A-SITE.md`](docs/LEARNING-A-SITE.md)** and let it run autonomously. It drives the
141
+ site once through webnav's `use` primitives while recording, then `dev graph-analyse --draft` folds
142
+ that into a SELF-VERIFIED map (absolute URLs, unique element fingerprints, the in-page affordance
143
+ repertoire, the declared domain shadow) which it persists with `dev graph-edit`. No hand-authoring
144
+ of fingerprints or URLs. (That prompt learned the seeded OrangeHRM map — login + 11 modules,
145
+ exercised — in a single one-shot run.) Re-learn cleanly with `dev node-clear`.
146
+ - **Or skip learning — import a map pack someone already made.** A map travels as a pack, so only the
147
+ first person learns a site. `webnav dev import-map <pack.json>` loads a site's skeleton; set your own
148
+ login with `dev creds set` (packs are skeleton-only, never carry credentials). Two packs ship in
149
+ **[`mappacks/`](mappacks/)** (saucedemo, OrangeHRM); `dev export-map <site>` makes your own to share.
150
+ - **Or record a site by browsing it yourself.** No agent needed: run `webnav dev record-live
151
+ --session S --url <site>` — it opens a headed browser at that URL, and you click through the
152
+ flow naturally. Every action you take is captured (real playwright a11y snapshots, never typed
153
+ values — only which field changed) into the same session store the agent-record path uses. Stop
154
+ with Ctrl-C or `webnav dev record-stop --session S`, then it's the same `dev graph-analyse
155
+ <session> --draft` → `graph-edit` → `walk` pipeline.
156
+ - **Or drive + record from the Chrome extension** — the [side panel](#drive-a-tab-from-a-side-panel-chrome-extension)
157
+ above: give the agent a goal, it drives your active tab (recalling known routes first), and the
158
+ run is captured back into the map. (An earlier extension *capture-only* path that approximated the
159
+ a11y tree from the raw DOM is retired — it broke on SPAs; the current extension captures via real
160
+ CDP accessibility instead. `dev ingest` still exists as that legacy receiver.)
161
+ - **Inspect what you have** anytime: `webnav dev dashboard` (a localhost operator UI). Its
162
+ **Sessions** tab lists every recorded run — tagged by source (**Extension** / **Agent** /
163
+ **Manual**), with a filter, step counts, and a Verified badge — plus record-by-clicking + replay:
164
+
165
+ <img src="docs/media/dashboard-sessions-light.png#gh-light-mode-only" alt="webnav dashboard — Sessions tab with Extension/Agent/Manual source tags and a source filter" width="820">
166
+ <img src="docs/media/dashboard-sessions-dark.png#gh-dark-mode-only" alt="webnav dashboard — Sessions tab with Extension/Agent/Manual source tags and a source filter" width="820">
167
+
168
+ Or the text views `dev outline <site>` / `dev mermaid <site>`.
169
+
170
+ **TL;DR:** out of the box you can `walk` saucedemo; everything else you map yourself. Same
171
+ machine + a mapped site → instant, cached, self-healing. A brand-new site → you (or your
172
+ agent) record it once first.
173
+
174
+ ## Verbs
175
+
176
+ ```
177
+ # Travel a map you've built (the core win: deterministic, low-token replay)
178
+ webnav walk --start <state> --goal <state> autopilot a multi-step route; pauses at genuine forks
179
+ webnav walk-resume <session> --ref|--classify answer a paused walk's fork and continue
180
+ webnav creds set <site> key=value... store login/form creds locally (~/.webnav, chmod 600)
181
+
182
+ # Drive a live browser one step at a time (explore/build; each step recordable)
183
+ webnav use navigate <url> --session S open a URL (records a landing if S is recording)
184
+ webnav use snapshot --session S read the page + element refs (never records)
185
+ webnav use click <ref> / use type <ref> <t> act on a ref; records the before/after effect
186
+ webnav read <url> [--raw] open a URL -> distilled content
187
+ webnav search "<query>" [--top N] open-web search -> extracted evidence
188
+ webnav eval <url> "<js>" | network <url> targeted JS extraction | the page's API calls
189
+
190
+ # Author a site's map (the record -> analyse -> edit flow)
191
+ webnav dev record-start / record-stop bracket a mapping session
192
+ webnav dev record-live --session S --url U headed browser; click through it yourself, webnav records
193
+ webnav dev agent-serve [--port 7779] local server the Chrome extension drives (SSE + CDP); records each run
194
+ webnav dev ingest [--port 7778] legacy receiver for the retired DOM-capture extension path
195
+ webnav dev graph-analyse --session S [--draft] mechanical structure from what you recorded
196
+ (--draft = a self-verified, ready-to-edit graph spec)
197
+ webnav dev graph-edit --node <id> --graph J write the validated graph
198
+ webnav dev effects --session S the RAW recorded before/after snapshots
199
+ webnav dev outline <site> | mermaid <site> completeness check | renderable diagram
200
+ webnav dev graph-show --node <id> a site's stored states + edges (JSON)
201
+ webnav dev export-map <site> a site's map pack as JSON (skeleton only, no creds)
202
+ webnav dev dashboard [--port N] local operator UI: sites + JSON map + credentials
203
+ webnav dev list the sites you have maps for + state counts
204
+ webnav dev node-clear / node-rm --node <id> empty a site's map (re-learn) / delete it entirely
205
+ webnav dev node-add / edge-add / capture teach + inspect helpers
206
+ ```
207
+ `webnav <verb> --help` for details. Output is JSON on stdout; exit 0 ok / 2 error / 3 empty.
208
+
209
+ ### MCP server
210
+
211
+ `webnav mcp` serves every verb as an MCP tool over stdio — point an MCP client at it and
212
+ agents get the verbs natively (no shelling out). Tools are generated from the same command
213
+ registry as `--help`, and every call runs the real CLI, so the two surfaces can't drift:
214
+
215
+ ```json
216
+ { "mcpServers": { "webnav": { "command": "webnav", "args": ["mcp"] } } }
217
+ ```
218
+
219
+ Consumer verbs can also be invoked canonically as `webnav use <verb> ...` and map-authoring verbs as `webnav dev <verb> ...`; bare consumer verbs (e.g. `webnav read ...`) still work too.
220
+
221
+ ### Inspect a site's map
222
+ The map is for the calling AGENT (walk), not a human dashboard. To inspect
223
+ what's captured, use the text views — no UI:
224
+ ```bash
225
+ webnav dev outline www.saucedemo.com # top-to-bottom states + affordances + completeness cues
226
+ webnav dev mermaid www.saucedemo.com # paste into GitHub/mermaid.live to render
227
+ webnav dev graph-show --node <id> # raw JSON
228
+ ```
229
+
230
+ ## Architecture (one CLI, three components, ZERO LLM)
231
+
232
+ - **Explorer** — reads a site's declared structure (observe-first), folds a recording into a
233
+ self-verified map draft (states, typed affordances, the declared domain shadow), recognizes states.
234
+ - **MapStore** — SQLite persistence: states (+ affordances + declared shadow), projected edges, the
235
+ site-node index, and record sessions.
236
+ - **Router** — walks a route, replays it (cached selector → deterministic fingerprint re-resolve),
237
+ self-heals, returns evidence OR a `needs-navigation`/`needs-classification` "your move" response for
238
+ the agent. Never judges, never calls an LLM.
239
+
240
+ ## Source map (`src/`)
241
+
242
+ ```
243
+ cli.ts, cli-spec.ts, cli-help.ts CLI: parsing, command registry, help rendering
244
+ protocol.ts, contract.ts walk response types · published @dikshanty94/webnav types
245
+ paths.ts, creds.ts, hosted.ts ~/.webnav paths · local credential store · remote-map client
246
+ mcp/ server.ts `webnav mcp`: every verb as an MCP tool (generated from cli-spec)
247
+ mapstore/ types.ts, store.ts, record.ts, schema.sql SQLite persistence (states+affordances+shadow, edges, nodes, node_edges, record sessions)
248
+ playwright/ adapter.ts, snapshot.ts, capture.ts, fingerprint.ts, sessions.ts, throttle.ts playwright-cli child-process · a11y snapshot parser · element fingerprints · session guardrails
249
+ explorer/ analyse.ts, diff.ts, draft.ts, shadow.ts, fingerprint.ts, fingerprint-page.ts analyse a recording → self-verified draft (affordances + declared domain shadow) + state recognition
250
+ router/ resolve.ts, replay.ts, path.ts, walk.ts, walk-live.ts, walk-session.ts deterministic resolve/replay + interactive multi-step walk + pathfinding
251
+ readiness.ts, extract.ts, extract-content.ts, tokens.ts, browse.ts, read.ts bot-wall detection · signal/content extraction · token-savings · page reading
252
+ search.ts, search-providers.ts, search-live.ts multi-provider open-web search
253
+ catalog.ts dev list (the map index)
254
+ graph/ seed.ts, teach.ts, edit.ts, show.ts, coverage.ts map authoring + inspection (saucedemo seed, graph-edit, graph-show, outline/mermaid)
255
+ dashboard/ server.ts, shell.ts `webnav dev dashboard` local operator UI
256
+ ```
257
+ Tests mirror this under `tests/`. The live e2e walk tests are gated behind `WEBNAV_LIVE=1`.
258
+
259
+ ## Principles (full list in CLAUDE.md)
260
+
261
+ 1. Observe first, traverse rarely. 2. Never traverse a declared commit point. 3. Store durable
262
+ semantic routes; cache selectors. 4. Usage-learned weights are a hosted-service concern. 5. The map
263
+ surfaces evidence; the **agent** judges. **5a. ZERO LLM in webnav** — all reasoning offloaded to
264
+ the calling agent via a call-and-response protocol. 6. The map is a use-case-independent
265
+ navigation skeleton; goals declare signal interests. **Never evade bot-walls** — detect + escalate.
266
+
267
+ ## Status
268
+
269
+ All current work is merged to `main`, tests green. See **`docs/STATUS.md`** for the live
270
+ checklist, pending work, and known limitations; **`CLAUDE.md`** holds the settled design,
271
+ mental model, and principles. Design docs: `docs/superpowers/specs/`.
272
+
273
+ ## Contributing
274
+
275
+ PRs welcome — see [`CONTRIBUTING.md`](CONTRIBUTING.md) (the settled principles, dev setup, and how
276
+ to contribute a **site map** — the highest-leverage contribution). Report security issues privately
277
+ per [`SECURITY.md`](SECURITY.md). Be excellent to each other: [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
278
+
279
+ ## License
280
+
281
+ [Apache License 2.0](LICENSE). Free to use, modify, and redistribute (including commercially)
282
+ **with attribution**: retain the copyright notice and the [`NOTICE`](NOTICE) file. Includes an
283
+ explicit patent grant. Copyright 2026 Dikshant Yadav.
package/bin/webnav ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+ # webnav launcher — runs the TypeScript CLI directly via the project's local tsx,
3
+ # so `webnav` works on PATH with NO build step (always runs current src/).
4
+ # Resolve the repo root from this script's location (bin/ is at the repo root),
5
+ # following symlinks (npm link puts a symlink on PATH).
6
+ SOURCE="${BASH_SOURCE[0]}"
7
+ while [ -L "$SOURCE" ]; do
8
+ DIR="$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
9
+ SOURCE="$(readlink "$SOURCE")"
10
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
11
+ done
12
+ ROOT="$(cd -P "$(dirname "$SOURCE")/.." >/dev/null 2>&1 && pwd)"
13
+ # In the repo: run current src/ via tsx (no build step). In the published
14
+ # package (no src/, only dist/): run the compiled CLI.
15
+ if [ -f "$ROOT/src/cli.ts" ] && [ -x "$ROOT/node_modules/.bin/tsx" ]; then
16
+ exec "$ROOT/node_modules/.bin/tsx" "$ROOT/src/cli.ts" "$@"
17
+ fi
18
+ exec node "$ROOT/dist/cli.js" "$@"
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import type { MapStore } from '../mapstore/store.js';
3
+ import type { State } from '../mapstore/types.js';
4
+ import type { WalkBrowser } from '../router/walk.js';
5
+ import type { AgentEvent } from './server.js';
6
+ export interface ToolDef {
7
+ name: string;
8
+ description: string;
9
+ shape: z.ZodRawShape;
10
+ handler: (args: Record<string, unknown>, extra: unknown) => Promise<{
11
+ content: Array<{
12
+ type: 'text';
13
+ text: string;
14
+ }>;
15
+ }>;
16
+ }
17
+ export type QueryFn = (params: {
18
+ prompt: string;
19
+ tools: ToolDef[];
20
+ mode: 'ask' | 'act';
21
+ model?: string;
22
+ resume?: string;
23
+ emit: (e: AgentEvent) => void;
24
+ signal?: AbortSignal;
25
+ }) => AsyncIterable<unknown>;
26
+ export interface RunAgentGoalArgs {
27
+ goal: string;
28
+ sessionId: string;
29
+ mode: 'ask' | 'act';
30
+ model?: string;
31
+ browser: WalkBrowser;
32
+ store: MapStore;
33
+ states: State[];
34
+ emit: (e: AgentEvent) => void;
35
+ query?: QueryFn;
36
+ signal?: AbortSignal;
37
+ resumeSessionId?: string;
38
+ onSdkSession?: (sdkSessionId: string) => void;
39
+ awaitApproval?: () => Promise<boolean>;
40
+ }
41
+ /**
42
+ * Run one agent goal. Streams SDK narration back as AgentEvents:
43
+ * - assistant text -> { type: 'turn', text }
44
+ * - tool-use blocks -> { type: 'narrate', label } (display-only; the REAL CDP `action`
45
+ * events come from the channel in server.ts, never from here)
46
+ * - final result -> { type: 'done', summary }
47
+ * - any throw -> { type: 'error', message }
48
+ *
49
+ * Ask/Auto/Act gate semantics (crit #3/#4 — these three are OBSERVABLY different):
50
+ * - ACT: no confirmations. Drives freely. (Commit points are still protected by
51
+ * walkRoute's needs-classification — never auto-fired.)
52
+ * - AUTO: drives freely EXCEPT it pauses for approval before a goto to a NEW ORIGIN
53
+ * (cross-site navigation = the cheap "meaningful action" signal). Gate lives in
54
+ * the goto tool handler (buildTools). Same-origin driving is never gated.
55
+ * - ASK: emit the plan, then BLOCK the whole run on awaitApproval() BEFORE the query's
56
+ * first driving tool can run. Approve → run. Deny → emit a "denied" done and
57
+ * return without ever starting the query (nothing drives).
58
+ */
59
+ export declare function runAgentGoal(args: RunAgentGoalArgs): Promise<void>;