feat: autonomous login#88
Conversation
WalkthroughThis PR implements a new autonomous login skill for the browserless MCP agent. It adds the complete skill pipeline: a formal procedure specification, DOM detection logic, LLM integration guidance, and test coverage to verify skill activation triggers. ChangesAutonomous Login Skill
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/skills/skills.spec.ts (1)
406-464: ⚡ Quick winAdd explicit tests for URL-match and sign-in-nudge triggers.
The new suite validates only the password-input path. Since the feature also adds URL and CTA trigger paths, add focused positives for those to prevent regressions.
🧪 Suggested test additions
describe('skills/detectSkills - autonomous-login', () => { + it('fires when URL matches login/auth patterns', () => { + const ctx = { + snapshot: snapshot([], 'https://example.com/account/signin'), + }; + expect(detectSkills(ctx, createSkillState())).to.include('autonomous-login'); + }); + + it('fires on sign-in nudge CTA text', () => { + const ctx = { + snapshot: snapshot([ + el({ ref: 1, role: 'button', name: 'Please sign in', selector: 'button#signin' }), + ]), + }; + expect(detectSkills(ctx, createSkillState())).to.include('autonomous-login'); + }); + it('fires when the snapshot contains a password input', () => { const ctx = { snapshot: snapshot([ el({ @@ it('does not fire when no password input is present', () => { const ctx = { snapshot: snapshot([ el({ @@ - el({ ref: 2, role: 'button', name: 'Sign in', selector: 'button#go' }), + el({ ref: 2, role: 'button', name: 'Continue browsing', selector: 'button#go' }), ]), }; expect(detectSkills(ctx, createSkillState())).to.not.include( 'autonomous-login', ); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/skills/skills.spec.ts` around lines 406 - 464, Add two focused positive tests for the other autonomous-login trigger paths: one that ensures detectSkills(ctx, createSkillState()) includes 'autonomous-login' when the context contains a sign-in URL (set ctx.url or equivalent to a URL pattern your code checks), and another that ensures it fires when the snapshot contains a clear sign-in CTA (e.g., an el with role 'button' and name like 'Sign in' or a link that your matcher recognizes); place these alongside the existing tests and use the same helpers (detectSkills, createSkillState, snapshot, el) so they run the same way as the password-input test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/skills/index.ts`:
- Around line 23-24: The LOGIN_NUDGE_RE currently misses plain auth CTAs like
"Sign in" or "Log in"; update the regex for LOGIN_NUDGE_RE to also match simple
standalone phrases and common variants (e.g., "Sign in", "Sign-in", "SignIn",
"Log in", "Log-in", "LogIn", "signin", "login", "sign into", "log into") in a
case-insensitive way so autonomous-login triggers on basic auth CTAs in addition
to the existing longer phrases.
---
Nitpick comments:
In `@test/skills/skills.spec.ts`:
- Around line 406-464: Add two focused positive tests for the other
autonomous-login trigger paths: one that ensures detectSkills(ctx,
createSkillState()) includes 'autonomous-login' when the context contains a
sign-in URL (set ctx.url or equivalent to a URL pattern your code checks), and
another that ensures it fires when the snapshot contains a clear sign-in CTA
(e.g., an el with role 'button' and name like 'Sign in' or a link that your
matcher recognizes); place these alongside the existing tests and use the same
helpers (detectSkills, createSkillState, snapshot, el) so they run the same way
as the password-input test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a17ca66-a864-498d-a69d-6e4826b49ac5
📒 Files selected for processing (5)
src/@types/types.d.tssrc/skills/autonomous-login.mdsrc/skills/index.tssrc/tools/agent.tstest/skills/skills.spec.ts
Summary
appendSkills(...)was missing on the snapshot return path inagent.ts, so triggers fired andmarkFiredran but the skill body was silently dropped.autonomous-loginskill load proactively across the cases that actually matter: added URL-match and sign-in-CTA triggers (in addition to the existing password-input trigger), and added an always-loaded## Authposture rule that tells the agent to load the skill before mentioning or suggesting sign-in — not just when a password field is on the page.Test plan
npm testpasses locallynpm run lintpasses locallynpm run coveragethresholds still metManual: reproduced the original failure (agent visiting
amazon.com/gp/cart/view.htmlwith an empty cart and not loadingautonomous-login); after the fix, the skill auto-injects on the snapshot via the sign-in-CTA trigger, and the Terminal-Goal-Check section prevents the agent from returning the empty cart as an answer.Checklist
Summary by CodeRabbit