Skip to content
Merged
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
4 changes: 1 addition & 3 deletions .changeset/protocol-three-hard-cut.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ and add the `semantic-elements-v1` capability.

Add bounded semantic capture, deterministic find, inspect, continuation,
same-document deltas, fixed action failures, device-policy, physical-window
inventory, suspended-session adoption, attended-idle, and extension-local
payment-card command contracts. Card submission returns only fixed not-started
or outcome-unknown results.
inventory, suspended-session adoption, and attended-idle.
41 changes: 9 additions & 32 deletions .claude/skills/understudy-browser/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: understudy-browser
description: Drive the user's real, logged-in Chrome through Understudy MCP: open sessions, find and inspect bounded semantic elements, click, type non-sensitive text, submit an extension-local payment card, and diagnose device or origin-policy failures.
description: Drive the user's real, logged-in Chrome through Understudy MCP: open sessions, find and inspect bounded semantic elements, click, type non-sensitive text, and diagnose device or origin-policy failures.
---

# Drive a real browser with Understudy
Expand Down Expand Up @@ -46,10 +46,6 @@ include `https://www.example.com`. Dashboard edits are pushed to the device:
removals fence affected sessions immediately; additions become usable after
the extension acknowledges the new policy. Re-pairing is not required.

Payment origins are a second, extension-local allowlist. A card can be used
only when both the general session policy and the local payment policy permit
the exact top-level origin.

## Browser loop

```text
Expand Down Expand Up @@ -79,32 +75,16 @@ validation. Never invent, parse, or modify a ref.
Commands are serialized per account. Do not issue browser actions in parallel.
If a result is pending, use `browser_get_result`; do not resubmit the action.

## Sensitive data and payments

`browser_type` is for non-sensitive text only. Never send passwords, API keys,
payment-card data, or government identifiers through it. Understudy has no
server-side secret vault and no generic credential-fill tool.

Cards are enrolled, edited, and deleted only in the extension side panel. The
model can see aliases and approved payment origins through
`browser_list_cards`; PAN, expiry, CVV, ciphertext, masked card data, and key
material never leave the extension.

To submit a card:

1. Snapshot the checkout form.
2. Map distinct refs for number, expiry, CVV, optional cardholder name, and the
submit control.
3. Call `browser_submit_card` once with the local alias and those refs.
4. Treat `outcome_unknown` as final. Never retry it automatically and never
inspect the destroyed payment tab to infer approval. A fresh session may
inspect a separate receipt or order-status page.
## Sensitive data

`not_started` means no card byte was inserted. Take a fresh snapshot before a
manual retry. Once any byte is inserted, every result is `outcome_unknown`.
`browser_type` is for non-sensitive text only. NEVER send passwords, API keys,
card numbers, card security codes, other credentials, or government identifiers
through it. Understudy has no server-side secret vault and no generic
credential-fill tool.

Stop before any other irreversible action: purchase, send, delete, publish, or
an OAuth grant. Obtain the user's explicit approval for that exact action.
Stop before any irreversible action, including a purchase, message, deletion,
publication, or OAuth grant. Obtain the user's explicit approval for that exact
action.

## Failure handling

Expand All @@ -114,7 +94,6 @@ an OAuth grant. Obtain the user's explicit approval for that exact action.
| Device offline or unavailable | Chrome is closed, reconciling policy/inventory, or the extension is disconnected | Ask the user to open Chrome and check the side panel; use `browser_status`. |
| At capacity | Other active sessions hold the device's slots | Ask the user to close another controlled session. |
| Origin refused | The exact origin is absent from current session/device policy | Ask the user to edit dashboard origins and wait for policy acknowledgement. |
| Payment origin refused | General policy or extension-local payment policy is missing the exact origin | Ask the user to update the relevant policy; do not bypass it. |
| Stale ref | Navigation or a newer snapshot invalidated the ref | Snapshot again and remap. |
| Command still running | The original request remains authoritative | Use `browser_get_result`. |
| OUTCOME UNKNOWN | The write may have executed | Never retry automatically; observe later from a fresh safe context. |
Expand All @@ -131,7 +110,5 @@ an OAuth grant. Obtain the user's explicit approval for that exact action.
| `browser_navigate`, `browser_click`, `browser_type` | General navigation and non-sensitive input |
| `browser_press_key`, `browser_scroll`, `browser_wait` | Interaction and waiting |
| `browser_get_result` | Collect a pending command without retrying it |
| `browser_list_cards` | Return local aliases and exact payment origins only |
| `browser_submit_card` | Atomic local-card fill and submit with fixed outcomes |

There is no `browser_fill_secret` or `browser_list_secrets` tool.
37 changes: 3 additions & 34 deletions DEFERRED.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,8 @@

# Track deferred work

## API-credential vault
## Website credential storage

Understudy 0.2.0 deliberately removes the cloud secret vault and generic
`fill_secret` capability. The extension-local payment-card vault is not an
API-credential vault and must not be generalized into one.
Understudy stores no website passwords, API tokens, or payment data in the extension or the service. Sign in to each website in your own browser so agents can reuse that session. Consumers may store usernames. They must never store passwords.

A future API-credential feature requires a separate design and security review
before implementation. The review starts from these constraints:

- Use separate IndexedDB records and a separate object store from payment
cards. Do not overload the card schema, aliases, key-purpose AAD, handlers, or
UI.
- Support only reviewed, service-specific adapters. Each adapter fixes the
service identity, exact destination origin, credential type, injection point,
and permitted operation.
- Do not expose generic header injection, form/ref injection, arbitrary fetch,
arbitrary DOM/runtime evaluation, or a plaintext-returning API.
- Do not share a plaintext API, decrypted value type, generic executor, or
message shape with the card vault.
- Keep plaintext, ciphertext, key material, masked values, and recovery data
inside the extension boundary. Define key loss, corruption, deletion,
migration, update, and uninstall behavior explicitly.
- Preserve the intersection of backend-authoritative device/session policy and
a local exact-origin approval. Revocation and policy narrowing must fence
active use.
- Specify page-derived output suppression and fixed result enums for each
adapter. Do not infer remote success from an untrusted page.
- Threat-model the controlling agent, approved service origin, extension/update
authority, operating system, logs, crash reports, sync, backups, clipboard,
downloads, network tooling, and other extensions.
- Add adversarial unit and real-Chrome tests proving no credential marker
appears outside the adapter and approved destination.

Out of scope until that design is accepted: password storage, bearer tokens,
API keys, OAuth refresh tokens, SSH keys, arbitrary login automation, and
migration from any retired cloud-vault data.
Owner decision, 2 December 2026 (Dubai time).
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Read [`docs/technical-plan.md`](docs/technical-plan.md) for the architecture, sa
| `packages/protocol` | Published Zod 4 command, event, control-frame, and status contracts |
| `packages/connector` | Published Breakwater connectors for browser observation and governed non-secret actions |
| `apps/backend` | Hono Worker, session and device Agents, tenant coordinator, quotas, and telemetry |
| `apps/extension` | WXT and React extension with attended control, two-session unattended hosting, and a local payment-card vault |
| `apps/extension` | WXT and React extension with attended control and two-session unattended hosting |
| `apps/cdp-spike` | Historical Manifest V3 CDP capability harness |

`@understudy/[email protected]` and `@understudy/[email protected]` are the current published versions. The pending coordinated changeset releases protocol 0.9.0 and connector 0.6.0; a local build does not publish them.
Expand All @@ -31,7 +31,7 @@ Understudy never:
- Records video, GIF, Document Object Model history, or session content
- Replaces consumer approval or durable audit

Protocol 3 provides at-most-once write execution with explicit pending and unknown outcomes. It removes the cloud secret oracle. Payment cards remain encrypted inside the extension and are submitted through a dedicated sensitive boundary that returns no page-derived result.
Protocol 3 provides at-most-once write execution with explicit pending and unknown outcomes. It removes the cloud secret oracle.

## Develop the repository

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Minor Changes

- Remove the cloud vault and secret-fill oracle; reject legacy API and OAuth credentials through the protocol-3 authentication hard cut.
- Add device-bound MCP/OAuth credentials, mandatory S256 PKCE, direct pairing offers, versioned per-device origin policy, OAuth connection revocation, and extension-local card MCP tools.
- Add device-bound MCP/OAuth credentials, mandatory S256 PKCE, direct pairing offers, versioned per-device origin policy, and OAuth connection revocation.
- Add physical-window inventory, exact orphan cleanup, suspended-session adoption, attended idle detach, HSTS, and Worker deployment provenance.
- Add structured MCP output schemas, bounded semantic find/inspect/pagination
tools, same-document deltas, fixed failure rendering, and exact snapshot
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The backend is a Hono Cloudflare Worker with Durable Objects for accounts, devic
| `src/auth.ts` | Caller authentication, HMAC session ownership, `udt_v2` device credentials, and connect tickets | Changing credentials, session ownership, or WebSocket tickets |
| `src/dashboard/app.ts` | Sign-in, CSRF, direct pairing, policy, browser-bound tokens, OAuth grants, and revocation | Changing dashboard actions, authentication, policy, or consent |
| `src/dashboard/pages.ts` | Nonce-bearing dashboard, consent, privacy, and onboarding HTML | Changing dashboard rendering, content security policy, or onboarding copy |
| `src/mcp/tools.ts` | Protocol-3 browser tools and fixed local-card contracts | Adding or changing MCP tools, schemas, or tool guidance |
| `src/mcp/tools.ts` | Protocol-3 browser tools | Adding or changing MCP tools, schemas, or tool guidance |
| `src/mcp/props.ts` | Current OAuth/token props: device, auth epoch, and contract version | Changing MCP credential claims or connection state |
| `src/mcp/static-auth.ts` | `usk_v2` request authentication with current device/epoch validation | Changing static MCP authentication or revocation behavior |
| `src/validation.ts` | Bounded strict input and exact-origin canonicalization | Adding request validation or changing origin handling |
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Operate the Understudy backend

The backend is a Cloudflare Worker with Hono, OAuth Provider, Agents SDK Durable Objects, SQLite coordination, Analytics Engine telemetry, and a rate-limit backstop. It coordinates browser work but never runs Chromium or stores payment cards.
The backend is a Cloudflare Worker with Hono, OAuth Provider, Agents SDK Durable Objects, SQLite coordination, Analytics Engine telemetry, and a rate-limit backstop. It coordinates work in the paired browser.

## Object topology

Expand Down Expand Up @@ -132,7 +132,7 @@ The canonical host is `https://understudy.proofof.tech`. Canonical HTTP requests

## Telemetry boundary

Telemetry is content-free. Never add page URL, title, content, dialog text, screenshot data, refs, card aliases, card values, credentials, tickets, or complete socket URLs.
Telemetry is content-free. Never add page URL, title, content, dialog text, screenshot data, refs, credentials, tickets, or complete socket URLs.

## Verify

Expand Down
19 changes: 0 additions & 19 deletions apps/backend/src/account-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,6 @@ export class AccountAgent extends DurableObject<Env> {
}
if (result.kind !== "terminal") return;
const event = result.event;
if (input.draft.type === "submit_card" && event.type === "card_submission_result") {
await this.applyCardResultBookkeeping(actor, event);
return;
}
if (await this.applySnapshotResultBookkeeping(actor, event)) return;
if (event.type !== "action_result") return;
const snapshot = await this.snapshotState(actor);
Expand Down Expand Up @@ -809,10 +805,6 @@ export class AccountAgent extends DurableObject<Env> {
}

private async applyPolledEventBookkeeping(actor: McpActorRef, event: Event): Promise<void> {
if (event.type === "card_submission_result") {
await this.applyCardResultBookkeeping(actor, event);
return;
}
if (await this.applySnapshotResultBookkeeping(actor, event)) return;
if (event.type !== "action_result") return;
const snapshot = await this.snapshotState(actor);
Expand Down Expand Up @@ -883,15 +875,4 @@ export class AccountAgent extends DurableObject<Env> {
});
return true;
}

private async applyCardResultBookkeeping(
actor: McpActorRef,
event: Extract<Event, { type: "card_submission_result" }>,
): Promise<void> {
if (event.status === "outcome_unknown") {
await this.clearBinding(actor);
return;
}
await this.invalidateSnapshot(actor);
}
}
2 changes: 1 addition & 1 deletion apps/backend/src/dashboard/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function privacyPage(): Fragment {

<div class="card">
<h2>Local extension storage</h2>
<p>The extension stores device credentials, profile configuration, and locally encrypted payment-card records in extension-owned storage. Card plaintext, ciphertext, and encryption keys are not sent to the service. Browser-session storage may contain lease assignments, owned-window identifiers, recovery state, write-journal status, and pending dialog records.</p>
<p>The extension stores device credentials and profile configuration in extension-owned storage. Browser-session storage may contain lease assignments, owned-window identifiers, recovery state, write-journal status, and pending dialog records.</p>
<p>The extension does not persist command bodies, typed text, secret plaintext, secret references, screenshots, accessibility trees, or general navigation history in local extension storage. A pending dialog record includes the page URL where the dialog appeared until the service acknowledges that record.</p>
</div>

Expand Down
41 changes: 0 additions & 41 deletions apps/backend/src/mcp/outcomes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,47 +332,6 @@ function mapTerminalEvent(
},
};
}
case "cards_result": {
const result = textResult(
`Local card aliases: ${event.aliases.length === 0 ? "(none)" : event.aliases.join(", ")}.\n` +
`Locally approved payment origins: ${
event.approvedOrigins.length === 0
? "(none)"
: event.approvedOrigins.join(", ")
}. Card values and masked card data remain inside the extension.`,
);
return {
...result,
structuredContent: {
source: "understudy",
result: {
aliases: event.aliases,
approvedOrigins: event.approvedOrigins,
},
},
};
}
case "card_submission_result": {
const result =
event.status === "not_started"
? errorResult(
`Card submission did not start (${event.reason}). Take a new browser_snapshot before retrying.`,
event.reason,
)
: errorResult(
`OUTCOME UNKNOWN (${event.reason}): card data may have been submitted. ` +
"Do not retry automatically. Open a fresh session to inspect a receipt or status page.",
event.reason,
);
return {
...result,
structuredContent: {
source: "understudy",
error: { reason: event.reason, retryable: false },
result: { status: event.status },
},
};
}
default:
return textResult(`Completed with a ${event.type} event.`);
}
Expand Down
73 changes: 3 additions & 70 deletions apps/backend/src/mcp/tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* The MCP catalog: browser execution plus the extension-local card vault.
* The MCP catalog for browser execution.
* resolve_ref (internal dry-run probe), switch_tab (protocol-3 no-op), and
* snapshot mode:"dom" (extension returns unsupported) are deliberately not
* tools, because a tool that can only fail teaches the model wrong
Expand All @@ -14,7 +14,7 @@

import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { CardAliasSchema, utf8ByteLength } from "@understudy/protocol";
import { utf8ByteLength } from "@understudy/protocol";
import type {
CommandDraft,
McpActorRef,
Expand Down Expand Up @@ -421,7 +421,7 @@ export function registerTools(server: McpServer, host: McpToolHost): void {
title: "Type text",
description:
"Type non-sensitive text into the element behind a ref. NEVER type passwords, API keys, " +
"payment-card data, or other credentials with this tool.",
"card numbers, card security codes, or other credentials with this tool.",
inputSchema: {
ref: REF_INPUT,
text: z.string().max(65536),
Expand Down Expand Up @@ -452,73 +452,6 @@ export function registerTools(server: McpServer, host: McpToolHost): void {
),
);

server.registerTool(
"browser_list_cards",
{
title: "List local payment cards",
description:
"List card aliases and exact payment origins approved inside this Chrome extension. " +
"Card numbers, expiry values, CVVs, and masked card data are never returned.",
inputSchema: {},
outputSchema: BROWSER_OUTPUT_SCHEMA,
annotations: { readOnlyHint: true },
},
() =>
withProps((props) =>
runCommand(props, "browser_list_cards", { type: "list_cards" }, {
write: false,
usesRef: false,
}),
),
);

server.registerTool(
"browser_submit_card",
{
title: "Submit a local payment card",
description:
"Use a locally enrolled card to fill model-selected refs and invoke submitRef as one " +
"atomic sensitive operation. The current top-level origin must be allowed by both the " +
"session policy and the extension's local payment policy. Once any card byte is inserted, " +
"the outcome is always OUTCOME UNKNOWN and must never be retried automatically.",
inputSchema: {
cardAlias: CardAliasSchema,
numberRef: REF_INPUT,
expiry: z.discriminatedUnion("kind", [
z.object({ kind: z.literal("combined"), ref: REF_INPUT }).strict(),
z.object({
kind: z.literal("split"),
monthRef: REF_INPUT,
yearRef: REF_INPUT,
}).strict(),
]),
cvvRef: REF_INPUT,
cardholderNameRef: REF_INPUT.optional(),
submitRef: REF_INPUT,
},
outputSchema: BROWSER_OUTPUT_SCHEMA,
},
(args) =>
withProps((props) =>
runCommand(
props,
"browser_submit_card",
{
type: "submit_card",
cardAlias: args.cardAlias,
numberRef: args.numberRef,
expiry: args.expiry,
cvvRef: args.cvvRef,
...(args.cardholderNameRef === undefined
? {}
: { cardholderNameRef: args.cardholderNameRef }),
submitRef: args.submitRef,
},
{ write: true, usesRef: true },
),
),
);

server.registerTool(
"browser_press_key",
{
Expand Down
Loading