Trayntrayn.ai

Getting Started

Train browser agents on realistic, deterministic playgrounds built from your recordings.

What is Trayn?

Browser agents need to practice on real websites — but real websites change constantly (A/B tests, inventory, auth walls). Hand-built clones take months and don't match production.

Trayn turns a single recorded workflow into a fully interactive playground — same screens, same buttons, same behavior. Every time. Forever. Then your agent trains on it and learns from its mistakes.

flowchart LR
  R["Record workflow"] --> A["Anonymize offline"]
  A --> S["Interactive playground"]
  S --> T["Agent trains"]
  T --> G["Graded + memories"]
  G -->|"next attempt"| T
ApproachRealisticDeterministicScales
Live websitesYesNo
Hand-built clonesNoYesNo
TraynYesYesYes

Installation

npm install @trayn/agent-sdk

The SDK requires Playwright. Install browsers after:

npx playwright install chromium

Quick Start

Install the browser extension

Install the Trayn browser extension (Chrome or Firefox). This captures your workflow — every screen state and every interaction.

Record a workflow

Navigate to any website and click Record in the extension. Complete the workflow you want your agent to learn — searching, clicking, filling forms, anything. When done, hit Stop.

View in the Trayn app

Open app.trayn.ai. Your recordings appear in the timeline. Trayn processes each recording:

  1. Anonymize — All personal data (names, emails, avatars) is detected and replaced entirely offline in your browser before anything is stored.
  2. Create playground — Trayn generates a hyper-realistic, fully interactive clone of the original application. Every button, input, dropdown, and navigation works as an agent would expect on the real site — not a replay, but a standalone environment.
  3. Generate task — AI analyzes the recording and creates a task definition with goal text, verifiers, and expected actions.

Copy the playground URL

Each playground has a unique URL. Copy it from the web app:

https://app.trayn.ai/playground/{host}/{sessionId}

Train your agent

Point the CLI at the playground. The SDK fetches the task, launches a browser, runs your agent, grades it, and stores memories for learning.

trayn --url https://app.trayn.ai/playground/{host}/{sessionId} --max-steps 15 --reps 3

Authentication

On first run, the CLI prompts for your email. This links runs to your Trayn account.

trayn --url https://app.trayn.ai/playground/...
#  Email: you@company.com (saved to ~/.config/trayn/config.json)
#  ✓ Saved

CLI Reference

trayn [options]
FlagTypeDefaultDescription
--urlstringPlayground URL (primary workflow)
--agentstringtraynAgent to use (trayn or openclaw)
--max-stepsnumber5Maximum actions per task
--repsnumber3Repetitions (rep 1 = baseline, rep 2+ = with memory)
--headlessbooleanfalseRun browser without UI
--verbosebooleanfalseShow accessibility tree previews
--debugbooleanfalseEnable debug logging
--grader-endpointstringTrayn APICustom grading endpoint (or none to skip)
--session-idstringautoOverride session ID
--confirmbooleanfalseReview and edit the task before running

Examples

Run against a recorded playground with visible browser:

trayn --url https://app.trayn.ai/playground/{host}/{sessionId} --max-steps 15 --headless false

Use the OpenClaw agent instead of the built-in TraynAgent:

trayn --agent openclaw --url https://app.trayn.ai/playground/{host}/{sessionId}

Programmatic Usage

import { harness } from "@trayn/agent-sdk";
 
await harness({
  agentargs: {
    agent_name: "my-agent",
    make_agent: () => ({
      get_action: async (obs) => {
        // obs.goal — task objective fetched from the backend
        // obs.url — current playground page URL
        // obs.axtree_txt — accessibility tree with element BIDs
        // obs.last_action_error — feedback from previous action
        return ["click('42')", { think: "clicking the submit button" }];
      },
      store_grades: async (result) => {
        console.log("Completed:", result.taskCompleted);
      },
    }),
  },
  url_override: "https://app.trayn.ai/playground/{host}/{sessionId}",
}).run();

Pluggable Architecture

Every layer of the SDK is replaceable via dependency injection. Swap any adapter to customize behavior:

AdapterInterfaceDefaultDocs
GradingGraderAdapterHttpGraderAdapter (Trayn API)Grading
RetrievalRetrieverAdapterDefaultRetriever (IoU + cosine)Retrieval
StorageStorageAdapterCloud storage (built-in)Storage
EmbeddingsEmbeddingAdapterGoogleEmbeddingAdapterEmbeddings
import { setGrader, setRetriever, setStorage, setEmbedding } from "@trayn/memory";
 
setStorage(new MyCustomStorage());
setEmbedding(new MyCustomEmbedding());
setGrader(new MyCustomGrader());
setRetriever(new MyCustomRetriever());

On this page