feat: add adapter_hints to browser analyze, wire it up as a real command - #236
Open
ayushsingh82 wants to merge 1 commit into
Open
feat: add adapter_hints to browser analyze, wire it up as a real command#236ayushsingh82 wants to merge 1 commit into
ayushsingh82 wants to merge 1 commit into
Conversation
Browser recon now runs on the Playwright-style `browser run` sandbox
while adapters stay on the stable IPage/registry API. Nothing bridged
the two: an agent doing recon had to manually re-derive strategy choice
and adapter shape from raw evidence, with only a prose reminder ("do
not paste Playwright code into an adapter") standing between the two
contracts.
analyze.ts already computed most of what's needed (pattern
classification, anti-bot detection, scored network evidence, nearest
adapter) via analyzeSite(), but per agentrhq#217 the CLI wrapper that used to
drive it was removed in the browser-run migration, leaving it
unreachable from any command.
- Add buildAdapterHints()/AdapterHints to analyze.ts: a recommended
discovery-time strategy (PUBLIC_API/COOKIE_API/UI_SELECTOR/DOM_STATE/
INTERCEPT), the adapter-compatible path it maps to (browser:false ->
func(args) vs browser:true -> func(page,args)), flagged state hazards
(anti-bot, auth failures, missing cookies when a cookie strategy is
recommended), a pointer to the snapshot tool for selector evidence
(not captured by PageSignals), and a fixed do-not-copy-Playwright
notice. Wired into AnalyzeReport as `adapter_hints`.
- Re-register `webcmd browser analyze --stdin|--file` as a pure JSON-in/
JSON-out command: no live session, no daemon/CDP integration, just
scores PageSignals an agent already captured via `browser run` and
prints the AnalyzeReport (including adapter_hints). This intentionally
avoids the exact bug agentrhq#217 reported (a required <session> arg with no
documented example) by not taking a session at all.
- Update site-recon.md with an optional PageSignals-shaped recon script
piped into the new command, and SKILL.md's Step 3 to mention it.
- IPage is untouched, per the issue's explicit constraint to only extend
it when evals prove a missing capability.
Fixes agentrhq#226
Author
|
@beubax Fixed — this PR adds a structured |
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per the issue: browser recon runs on the Playwright-style
browser runsandbox while adapters stay on the stableIPage/registry API, and nothing bridged the two — an agent doing recon had to manually re-derive strategy choice and adapter shape from raw evidence, with only a prose reminder ("do not paste Playwright code into an adapter") standing between the two contracts.analyze.tsalready computed most of what's needed for this (pattern classification, anti-bot detection, scored network evidence, nearest adapter) viaanalyzeSite(), but per #217 the CLI wrapper that used to drive it was removed during the browser-run migration, leaving the whole module unreachable from any command.What this PR does:
buildAdapterHints()/AdapterHintstoanalyze.ts: a recommended discovery-time strategy (PUBLIC_API/COOKIE_API/UI_SELECTOR/DOM_STATE/INTERCEPT), the adapter-compatible path it maps to (browser:false -> func(args)vsbrowser:true -> func(page,args)), flagged state hazards (anti-bot, auth failures, missing cookies when a cookie strategy is recommended), a pointer to the snapshot tool for selector evidence (not somethingPageSignalscaptures), and a fixed do-not-copy-Playwright notice. Wired intoAnalyzeReportasadapter_hints.webcmd browser analyze --stdin|--fileas a pure JSON-in/JSON-out command — no live session, no daemon/CDP integration, just scoresPageSignalsan agent already captured viabrowser runand prints theAnalyzeReport(includingadapter_hints). This deliberately avoids resurrecting the exact bug webcmd-adapter-author skill:browser analyzeexample is missing the required <session> argument #217 reported (a required<session>arg with no documented example) by not taking a session at all — recon evidence capture stays entirely in the existingbrowser runsandbox.site-recon.mdwith an optionalPageSignals-shaped recon script piped into the new command, andSKILL.md's Step 3 to mention it as an alternative to manually reading the pattern table.IPageis untouched, per the issue's explicit constraint to only extend it when evals prove a missing capability.Fixes #226
Test plan
buildAdapterHintsacross Pattern A (with/without anti-bot), B, C, D, E — strategy recommendation, adapter-compatible path, and hazard flags (src/browser/analyze.test.ts)browser analyzeend-to-end via--fileand--stdin, plus validation errors (neither/both flags, invalid JSON, missing required field) (src/cli.test.ts)browsersubcommand list/count to includeanalyze--file,--stdin, and all four error paths, confirmed exit codes and messagesnpm run typecheckclean,npm run buildclean, generated artifacts (cli-manifest.json,hosted-contract.json,webcmd-plugin.json) show no diffnpm test— 385 test files / 4629 passed, 1 skipped