GuidesAutomation SDK

Getting started with Pluto Automation Packages

This guide uses the Pluto Automation Package for JavaScript with Playwright.

1. Install dependencies

npm install @plutoxyz/automation

2. Create a main.js file with a basic automation script:

import { createSession } from "@plutoxyz/automation";
 
// Create a new Pluto Frame session
const session = await createSession();
 
// Prompt the user for their username/password
const input = await session.prompt({
  title: "Login to Pseudo Bank",
  description: "Enter your username and password to login to Pseudo Bank",
  prompts: [
    { label: "Username", type: "text", attributes: { min_length: 3 } },
    { label: "Password", type: "password", attributes: {} },
  ],
});
 
// Launch Chrome locally for debugging and testing
const page = await session.launch();
 
await page.goto("https://pseudo-bank.pluto.dev");
await page.getByRole("textbox", { name: "Username" }).fill(input[0]);
await page.getByRole("textbox", { name: "Password" }).fill(input[1]);
await page.getByRole("button", { name: "Login" }).click();
await page.waitForSelector("text=Your Accounts", { timeout: 5000 });
 
const balanceLocator = page.locator("#balance-2");
await balanceLocator.waitFor({ state: "visible", timeout: 5000 });
const balanceText = (await balanceLocator.textContent()) || "";
const balance = parseFloat(balanceText.replace(/[$,]/g, ""));
 
// Prove the bank balance
await session.prove("bank_balance", balance);
 
console.log(`🎉 Session complete`);
await session.close(); // call this at the very end

3. Run the script

node main.js

You should see output similar to this:

💬 Login to Pseudo Bank
Enter your username and password to login to Pseudo Bank
-----------------------------
Username: Bob
Password: ********
-----------------------------
✅ Prove 'bank_balance' with value '8910.3'
🎉 Session complete

That’s it - you just ran your first Pluto-powered automation script using our secure TEE infrastructure.

Local Session Storage

Each automation script manages its Session Storage in ~/.pluto/session-cache. To delete the cache you can either manually delete the directory or call session.clearCache() in your automation script.

Direct access to CDP (Chrome Developer Protocol)

You may want to configure direct CDP access. Use the following:

import { createSession } from "@plutoxyz/automation"; // Adjust path if necessary
import { chromium } from "playwright-core";
 
const session = await createSession();
 
const browser = await chromium.connectOverCDP(await session.cdp());
const context = browser.contexts()[0];
const page = context.pages()[0];
 
// script ...
 
await page.close();
await browser.close();
await session.close();