> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentcard.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Kernel

> Use Agentcard with KERNEL to let your agent make purchases with your users' cards.

[KERNEL](https://kernel.so) runs the browser your agent shops in. There are two ways to connect it to the Vault. Pick one per checkout.

|                             | Native integration                    | Agentcard SDK                               |
| --------------------------- | ------------------------------------- | ------------------------------------------- |
| **Who intercepts the card** | KERNEL, at its network edge           | Agentcard's SDK, over CDP in Playwright     |
| **Extra dependency**        | None                                  | `@agent-cards/checkout` + `playwright-core` |
| **Good for**                | Agents built on the KERNEL SDK or MCP | Agents that already drive Playwright        |

Both need a user with a card in the Vault first. See [Adding a card](/vault/adding-a-card).

## Option A: KERNEL's native integration

KERNEL stores an Agentcard wallet in its vault and swaps the card in at checkout itself. Full reference: [KERNEL docs](https://www.kernel.sh/docs/integrations/payments/agentcard).

Set `AGENTCARD_MODE` to `sandbox` or `live` to match your credentials.

```ts theme={null}
import Kernel from '@onkernel/sdk';

const kernel = new Kernel({ projectID: process.env.KERNEL_PROJECT_ID! });

// 1. One vault per user, one Agentcard wallet inside it.
const vault = await kernel.vaults.upsert({ name: 'user-12345' });
const wallet = await kernel.vaults.items.upsert('agentcard-wallet', {
  id_or_name: vault.id,
  type: 'wallet',
  spec: { provider: 'agentcard' },
});
// First time: show wallet's enrollment action to the user, wait for status "connected".

// 2. A card item per purchase, with what the user will approve.
const card = await kernel.vaults.items.upsert('notebook-order', {
  id_or_name: vault.id,
  type: 'card',
  spec: {
    provider: 'agentcard',
    wallet: wallet.key,
    merchant: 'shop.example.com',
    amount: 2306, // minor units
    currency: 'usd',
  },
});

// 3. A browser with the vault attached. The agent shops and submits the card aliases.
const browser = await kernel.browsers.create({
  vaults: [{ id: vault.id }],
  headless: false,
  timeout_seconds: 1800,
});
```

When the agent submits the checkout form, KERNEL pauses the processor request and the card item's `state.authorization` fills in. Serve its `action.url` to the user through your own authenticated channel, never to the agent. The user approves with Face ID, the request resumes, and you confirm the order with the merchant before reporting success.

## Option B: Agentcard SDK over CDP

Connect Playwright to the KERNEL browser and attach Agentcard the same way as any CDP browser.

```bash theme={null}
npm i @agent-cards/checkout@0.3.0 @onkernel/sdk playwright-core
```

```ts theme={null}
import Kernel from '@onkernel/sdk';
import { chromium } from 'playwright-core';
import { VaultClient, attachToPlaywright } from '@agent-cards/checkout';

const kernel = new Kernel({ apiKey: process.env.KERNEL_API_KEY! });
const kernelBrowser = await kernel.browsers.create({ stealth: true });
const browser = await chromium.connectOverCDP(kernelBrowser.cdp_ws_url);
const context = browser.contexts()[0] ?? (await browser.newContext({ serviceWorkers: 'block' }));
const page = context.pages()[0] ?? (await context.newPage());

const vault = new VaultClient({
  clientId: process.env.AGENTCARD_CLIENT_ID!,
  clientSecret: process.env.AGENTCARD_CLIENT_SECRET!,
});
await vault.syncRegistry();

const checkout = await attachToPlaywright(page, {
  vault,
  user: 'usr_8f3k2m',
  merchant: 'shop.example.com',
  amountCents: 2306,
  currency: 'usd',
  onApprovalUrl: (url) => sendToUser(url),
});
```

Attach before the agent reaches the payment form. A KERNEL session bills until deleted, so call `kernel.browsers.deleteByID(kernelBrowser.session_id)` once the order is confirmed.

## Next

The rest of the flow is identical to any Vault purchase: placeholder card, Face ID approval, real card swapped in, confirm with the merchant. Follow the [Vault Quickstart](/vault/quickstart) from step 4, or read [Completing a purchase](/vault/completing-a-purchase).
