Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/skills/autonomous-login.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,20 @@ Anything missing → `FORM_NOT_FOUND` (say what's missing).

## Submit

One batched call (type username, type password, click submit) with Gate-2 values → `waitForNavigation` (10000ms) or `waitForResponse` on `*`. Both time out → verify anyway (page may update in place). Re-snapshot only when capture protection is not armed. **Never retype the same credentials to retry** — caller's call. If `loadSecret` filled a field, keep the batch as fill → click submit → `waitForNavigation`: navigation and response waits are allowed while armed, but navigation alone does not unlock snapshots. A completed redirect does not require a signed-in marker before checking removal; it is eligibility for the safe-clear checks below, not proof of clearance or login success. If navigation did not complete, first use `waitForSelector` for a newly appeared post-submit marker. After the safe-clear checks, explicitly send `{ method: "clearSecrets" }`, request a fresh snapshot of the destination, and apply Verify success (including challenge/error handling).
One batched call (type username, type password, click submit) with Gate-2 values → `waitForNavigation` (10000ms) or `waitForResponse` on `*`. Both time out → verify anyway (page may update in place). Re-snapshot only when capture protection is not armed. **Never retype the same credentials to retry** — caller's call. If `loadSecret` filled a field, keep the batch as fill → click submit → `waitForNavigation`: navigation and response waits are allowed while armed, but navigation alone does not unlock snapshots. A completed redirect does not require a signed-in marker before checking removal; it is eligibility for the safe-clear checks below, not proof of clearance or login success. After a completed redirect and successful safe-clear checks, explicitly send `{ method: "clearSecrets" }`, request a fresh snapshot of the destination, and apply Verify success (including challenge/error handling).

Before clearing, require the fill to finish and secret-bearing content to be gone from all tabs, including hidden fields. While armed, `getTabs` returns only tab IDs and active flags; `switchTab { targetId }` returns only success and the target ID. Record the destination ID, enumerate tabs, switch to each, and use secret-safe `waitForSelector` for `body:not(:has(<filled-field-selector>))` per field (10000ms). This checks removal, not visibility. Re-enumerate before clearing; check any new tabs and return to the destination. A pre-existing Account link proves nothing. These checks cover known fields, not arbitrary copied content or inaccessible frames: if any secret-bearing surface is unknown or cannot be checked, do not clear. Any required marker/removal wait fails → do not clear or snapshot; send the applicable reports (`reportSkillOutcome` if you loaded a site recipe, then `reportOutcome` with `success: false`, `reason` `other`), then `close`; the outcome is `SUBMIT_NO_FEEDBACK`. This rule applies after navigation as well as a timeout, and to TOTP and emailed-code submissions below. Never use `clearSecrets` to inspect whether clearing was safe.
If navigation did not complete and capture protection is not armed, take a fresh snapshot and follow Verify success or the MFA re-verification rules below. This applies to passwords and codes supplied via `type`. While capture protection is armed, send `{ method: "signInStatus" }` alone as your next call (it waits up to 10000 ms and returns no page content). Treat a command error as `no_result`. Then act on `outcome`:

- `credentials_rejected` → do not clear; outcome `INVALID_CREDENTIALS`.
- `verification_required` → run the safe-clear checks below. If they fail, do not clear or snapshot; report `MFA_INPUT_MISSING`. If they pass, send `clearSecrets`. After a primary credential submit, go to the MFA branch. After an MFA code submit, take a fresh snapshot and re-verify instead of starting MFA again: handle a rejected code or a second prompt by the MFA rules below. `verification` names the method: `totp` → authenticator code, `email` → emailed code; `sms`, `push`, `passkey`, `hardware_key` and `unknown` → `MFA_INPUT_MISSING` unless the user supplies a code.
- `challenge` with `captcha` → do not clear and do not solve while capture protection is armed; outcome `CAPTCHA_BLOCKED`.
- `challenge` with `identity_check` → do not clear; outcome `UNEXPECTED_STATE`.
- `form_gone` → no visible password field, not proof of login. Run the safe-clear checks below; if they pass, send `clearSecrets` and request a fresh destination snapshot. Handle errors and challenges as in Verify success, but require a newly visible signed-in control before reporting success; otherwise report `SUBMIT_NO_FEEDBACK`. A missing password field or changed URL alone is not enough on this path.
- `no_result` → do not clear; outcome `SUBMIT_NO_FEEDBACK`.

`signInStatus` never authorizes `clearSecrets` on its own.

Before clearing, require the fill to finish and secret-bearing content to be gone from all tabs, including hidden fields. While armed, `getTabs` returns only tab IDs and active flags; `switchTab { targetId }` returns only success and the target ID. Record the destination ID, enumerate tabs, switch to each, and use secret-safe `waitForSelector` for `body:not(:has(<filled-field-selector>))` per field (10000ms). This checks removal, not visibility. Re-enumerate before clearing; check any new tabs and return to the destination. A pre-existing Account link proves nothing. These checks cover known fields, not arbitrary copied content or inaccessible frames: if any secret-bearing surface is unknown or cannot be checked, do not clear. If a safe-clear check fails, do not clear or snapshot. For `verification_required`, follow Final response with `MFA_INPUT_MISSING`. Otherwise, the outcome is `SUBMIT_NO_FEEDBACK`: send the applicable reports (`reportSkillOutcome` if you loaded a site recipe, then `reportOutcome` with `success: false`, `reason` `other`), then `close`. This rule applies after navigation as well as a timeout, and to TOTP and emailed-code submissions below. Never use `clearSecrets` to inspect whether clearing was safe.

## Verify success (any one, priority order)

Expand Down Expand Up @@ -95,7 +106,7 @@ Triggered by `autocomplete="one-time-code"`, numeric input with `maxlength` ∈

- Contextually-matched TOTP (Gate-2 rule; an `op://…?attribute=otp` ref via `loadSecret`, or a user-supplied code via `type`) → fill, submit, re-verify.

**Emailed code.** If the task names a mailbox item in the bound vault, let the site send the code, focus the code input, then send `{ method: "loadSecret", params: { ref: "mail://<vault>/<item>/otp", selector: "<code input>" } }` — the server polls that mailbox for up to ~45 s and types the newest code; you never see it (vault and item segments are URL-encoded; append `?wait=90000` for slow senders). In the same batch click the submit control, then `waitForNavigation` (10000ms). Navigation and response waits are allowed while armed but do not unlock snapshots. Follow Submit: a completed redirect permits removal checks without a signed-in marker; an in-place update requires a new marker. Confirm every per-tab safe-clear condition before `{ method: "clearSecrets" }` and a fresh destination snapshot. If those conditions cannot be confirmed, do not `clearSecrets` to peek. `OtpTimeout` → click `Resend` once and retry once. **No mailbox item, or two timeouts → ask the user for the code in plain text and STOP this turn. Do NOT `close` — this turn is not your final response. Leave the session open so the code input and cookies survive the round-trip.** User replies → `type` it, submit, re-verify. **Magic link** (no code field) → ask the user to click it, keep the session open, then re-verify. **Phone/SMS or WebAuthn** → never attempt.
**Emailed code.** If the task names a mailbox item in the bound vault, let the site send the code, focus the code input, then send `{ method: "loadSecret", params: { ref: "mail://<vault>/<item>/otp", selector: "<code input>" } }` — the server polls that mailbox for up to ~45 s and types the newest code; you never see it (vault and item segments are URL-encoded; append `?wait=90000` for slow senders). In the same batch click the submit control, then `waitForNavigation` (10000ms). Navigation and response waits are allowed while armed but do not unlock snapshots. Follow Submit for the completed redirect or in-place update. Confirm every per-tab safe-clear condition before `{ method: "clearSecrets" }` and a fresh destination snapshot. If those conditions cannot be confirmed, do not `clearSecrets` to peek. `OtpTimeout` → click `Resend` once and retry once. **No mailbox item, or two timeouts → ask the user for the code in plain text and STOP this turn. Do NOT `close` — this turn is not your final response. Leave the session open so the code input and cookies survive the round-trip.** User replies → `type` it, submit, re-verify. **Magic link** (no code field) → ask the user to click it, keep the session open, then re-verify. **Phone/SMS or WebAuthn** → never attempt.

- No matching TOTP and no mailbox item → ask the user (the rule above). User declines / has none, or the prompt demands phone/SMS or WebAuthn → `MFA_INPUT_MISSING`.
- Code rejected (`/invalid|expired|incorrect/i`) → ask for a fresh code (same don't-close rule); one fresh-code rejection → `MFA_FAILED`.
Expand Down
2 changes: 1 addition & 1 deletion src/skills/autonomous-registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ A vault item exists from the moment `saveSecret` succeeded: give its title and `

Triggered by `autocomplete="one-time-code"`, a numeric input with `maxlength` ∈ {4,6,8}, a label/`name`/`placeholder` matching `/code|verif|otp|confirm/i`, or text like "we sent a code/link to <email>".

**Emailed code.** If the task names a mailbox item in the bound vault, let the site send the code, focus the code input, then send `{ method: "loadSecret", params: { ref: "mail://<vault>/<item>/otp", selector: "<code input>" } }` — the server polls that mailbox for up to ~45 s and types the newest code; you never see it (vault and item segments are URL-encoded; append `?wait=90000` for slow senders). In the same batch click the submit control, then `waitForNavigation` (10000ms). Navigation and response waits are allowed while armed but do not unlock snapshots. Follow Submit: a completed redirect permits removal checks without a signed-in marker; an in-place update requires a new marker. Confirm every per-tab safe-clear condition before `{ method: "clearSecrets" }` and a fresh destination snapshot. If those conditions cannot be confirmed, do not `clearSecrets` to peek. `OtpTimeout` → click `Resend` once and retry once. **No mailbox item, or two timeouts → ask the user for the code in plain text and STOP this turn. Do NOT `close` — this turn is not your final response. Leave the session open so the code input and cookies survive the round-trip.** User replies → `type` it, submit, re-verify. **Magic link** (no code field) → ask the user to click it, keep the session open, then re-verify. **Phone/SMS or WebAuthn** → never attempt.
**Emailed code.** If the task names a mailbox item in the bound vault, let the site send the code, focus the code input, then send `{ method: "loadSecret", params: { ref: "mail://<vault>/<item>/otp", selector: "<code input>" } }` — the server polls that mailbox for up to ~45 s and types the newest code; you never see it (vault and item segments are URL-encoded; append `?wait=90000` for slow senders). In the same batch click the submit control, then `waitForNavigation` (10000ms). Navigation and response waits are allowed while armed but do not unlock snapshots. Follow Submit for the completed redirect or in-place update. Confirm every per-tab safe-clear condition before `{ method: "clearSecrets" }` and a fresh destination snapshot. If those conditions cannot be confirmed, do not `clearSecrets` to peek. `OtpTimeout` → click `Resend` once and retry once. **No mailbox item, or two timeouts → ask the user for the code in plain text and STOP this turn. Do NOT `close` — this turn is not your final response. Leave the session open so the code input and cookies survive the round-trip.** User replies → `type` it, submit, re-verify. **Magic link** (no code field) → ask the user to click it, keep the session open, then re-verify. **Phone/SMS or WebAuthn** → never attempt.

Registration outcomes: user declines or has no code → `EMAIL_CODE_REQUIRED`; two timeouts and no user-supplied code → `EMAIL_CODE_TIMEOUT`; phone/SMS verification demanded → `PHONE_VERIFICATION_REQUIRED`; authenticator (QR) setup → skip when optional, else `MFA_SETUP_REQUIRED`; a second verification prompt after the first cleared → `UNEXPECTED_STATE`. The vault item already exists at this point — give its title and `op://` reference whatever the outcome.

Expand Down
3 changes: 2 additions & 1 deletion src/skills/system-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Commands with defined parameters (validated server-side). A loaded skill or site
- Navigation and tabs: \`goto\`, \`back\`, \`forward\`, \`reload\`, \`getTabs\`, \`switchTab\`, \`createTab\`, \`closeTab\`.
- Observe and interact: \`snapshot\`, \`text\`, \`html\`, \`evaluate\`, \`screenshot\`, \`click\`, \`type\`, \`select\`, \`checkbox\`, \`hover\`, \`scroll\`, \`solve\`.
- Wait: \`waitForSelector\`, \`waitForNavigation\`, \`waitForTimeout\`, \`waitForRequest\`, \`waitForResponse\`. For a click that navigates, pass \`waitUntil: "load"\` on the \`click\` itself instead of following it with \`waitForNavigation\`, which can miss a fast navigation.
- Files, capture and secrets: \`uploadFile\`, \`getDownloads\`, \`startRecording\`, \`stopRecording\`, \`liveURL\`, \`loadSecret\`, \`saveSecret\`, \`clearSecrets\`.
- Files, capture and secrets: \`uploadFile\`, \`getDownloads\`, \`startRecording\`, \`stopRecording\`, \`liveURL\`, \`loadSecret\`, \`signInStatus\`, \`saveSecret\`, \`clearSecrets\`.
- Reports and cleanup: \`reportSkillOutcome\`, \`reportOutcome\`, \`reportProfileAuthentication\`, \`close\`.

- **goto** { url, waitUntil? } — default "domcontentloaded"
Expand All @@ -176,6 +176,7 @@ Commands with defined parameters (validated server-side). A loaded skill or site
- **waitForResponse** { url?, statuses?, timeout? } — url is glob \`"*api/results*"\`
- **createTab** { url?, activate?, waitUntil? } — default activate: true; false = background
- **loadSecret** { ref, selector? } — fills a vault secret server-side (\`op://<vault>/<item>/<field>\`, or \`mail://<vault>/<inbox item>/otp\` for an emailed code); you never see the value; arms capture protection, including snapshots. Navigation alone does not unlock captures
- **signInStatus** { timeout? } — after a loadSecret submit, returns { outcome, verification?, challenge? } while captures stay locked; outcomes: form_gone · credentials_rejected · verification_required · challenge · no_result.
- **saveSecret** { title, username, password, website?, vault? } → \`{ ok, ref }\` or \`{ ok: false, error, vaults? }\` — needs \`integrationId\` on the FIRST call; omit \`vault\` unless the result lists several
- **clearSecrets** {} — lowers capture protection; use only after the fill completes and secret-bearing content is gone from all tabs, including hidden fields, never just after clicking submit. Then request a fresh snapshot. \`waitForNavigation\`/\`waitForResponse\`/\`waitForSelector\` are allowed while armed but do not unlock snapshots
- **liveURL** { timeout?, instructions? } — defaults to five minutes, capped at your plan maximum and remaining browser time. For a handoff, keep the session alive and say what to do and when to click Done. Omitted instructions give generic instructions; an empty string disables the card and Done button. The link does not extend the browser deadline.
Expand Down
7 changes: 5 additions & 2 deletions src/tools/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const SECRET_SAFE_METHODS = new Set([
'waitForTimeout',
// Result carries only url, status and elapsed time.
'waitForResponse',
// Result carries only outcome codes and elapsed time.
'signInStatus',
'uploadFile',
'saveProfile',
// Saving registers values for redaction but neither arms nor reads the capture gate.
Expand Down Expand Up @@ -1193,13 +1195,14 @@ export const runAgentCommands = async (
// import accepts it; re-validate a provided batch against the full
// per-command contract here (the method/key guards above own their
// specific messages). Legacy single-command calls stay loose except for
// outcome reports and credential writes.
// outcome reports and selected credential commands.
if (
params.commands?.length ||
params.method === 'reportOutcome' ||
params.method === 'reportSkillOutcome' ||
params.method === 'reportProfileAuthentication' ||
params.method === 'saveSecret'
params.method === 'saveSecret' ||
params.method === 'signInStatus'
) {
const list = params.commands?.length ? params.commands : commands;
const parsedCommands: Array<{
Expand Down
18 changes: 18 additions & 0 deletions src/tools/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,23 @@ const LoadSecretCommandSchema = z.object({
}),
});

const SignInStatusCommandSchema = z.object({
method: z
.literal('signInStatus')
.describe(
'After a loadSecret submit, report what the sign-in page shows without unlocking captures. ' +
'Returns { outcome, verification?, challenge?, time } with outcome form_gone | credentials_rejected | verification_required | challenge | no_result, ' +
'verification sms | totp | push | passkey | hardware_key | email | unknown, challenge captcha | identity_check. ' +
'No page content is returned. Waits up to timeout ms (default 10000, max 30000) for a settled answer. ' +
'form_gone does not authorize clearSecrets.',
),
params: z
.object({ timeout: z.number().int().min(0).max(30000).optional() })
.strict()
.optional()
.default({}),
});

const ClearSecretsCommandSchema = z.object({
method: z
.literal('clearSecrets')
Expand Down Expand Up @@ -850,6 +867,7 @@ const specificCommandSchemas = [
ClickCommandSchema,
TypeCommandSchema,
LoadSecretCommandSchema,
SignInStatusCommandSchema,
ClearSecretsCommandSchema,
SaveSecretCommandSchema,
SelectCommandSchema,
Expand Down
32 changes: 32 additions & 0 deletions test/skills/skills.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,38 @@ describe('skills/registry', () => {
}
});

it('checks stalled vault submits before considering capture clearance', () => {
const login = renderSkill('autonomous-login', false);
const submit = login.split('## Submit')[1].split('\n## ')[0];
expect(submit).to.include(
'While capture protection is armed, send `{ method: "signInStatus" }` alone as your next call',
);
expect(submit).to.include('Treat a command error as `no_result`');
expect(submit).to.match(
/capture protection is not armed, take a fresh snapshot/,
);
expect(submit).to.match(
/After an MFA code submit, take a fresh snapshot and re-verify instead of starting MFA again/,
);
expect(submit).not.to.include(
'first use `waitForSelector` for a newly appeared post-submit marker',
);
expect(submit).to.include(
'`credentials_rejected` → do not clear; outcome `INVALID_CREDENTIALS`',
);
expect(submit).to.include(
'`signInStatus` never authorizes `clearSecrets` on its own.',
);
expect(submit).to.include('body:not(:has(<filled-field-selector>))');
expect(submit).to.match(
/`form_gone`[^\n]*require a newly visible signed-in control/,
);
expect(login).not.to.include('an in-place update requires a new marker');
expect(renderSkill('autonomous-registration', false)).to.include(
'for a newly appeared post-submit marker',
);
});

it('checks verification before success and keeps confirmation optional', () => {
const body = renderSkill('autonomous-registration', false);
const verify = body
Expand Down
Loading