Skip to content

Scrapybara/scrapybara-ts-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scrapybara TypeScript Template

A template project for quickly getting started with the Scrapybara SDK and Act SDK for AI-powered desktop and browser automation.

Prerequisites

Setup

  1. Clone this repository:
git clone https://github.com/scrapybara/scrapybara-ts-template.git
cd scrapybara-ts-template
  1. Install dependencies using pnpm:
pnpm install
  1. Copy the example environment file and add your API keys:
cp .env.example .env

Then edit .env with your API keys:

SCRAPYBARA_API_KEY=your_api_key_here
ANTHROPIC_API_KEY=your_api_key_here  # Optional

Project Structure

.
├── .env                # Environment variables
├── package.json       # pnpm dependencies and project config
├── src/
│   └── index.ts      # Main script with Scrapybara setup
├── tsconfig.json     # TypeScript configuration
├── .cursorrules      # Cursor rules for working with the Scrapybara SDK
└── README.md         # This file

Usage

Run the template script:

pnpm start

The script will:

  1. Initialize a Scrapybara client
  2. Start a new instance
  3. Launch a browser
  4. Use the Act SDK to navigate to scrapybara.com
  5. Print the agent's observations
  6. Clean up resources automatically

Customization

Modifying the Agent's Task

Edit the prompt parameter in src/index.ts to give the agent different instructions:

prompt: "Your custom instructions here";

Adding More Tools

You can add more custom tools by importing them from scrapybara/tools:

import {
  bashTool,
  computerTool,
  editTool,
  browserTool,
} from "scrapybara/tools";

const tools = [
  computerTool(instance),
  bashTool(instance),
  editTool(instance),
  browserTool(instance),
  // Add your new tools here
];

Error Handling

The template includes basic error handling with automatic cleanup:

  • Catches and prints any exceptions
  • Ensures instance cleanup via finally block
  • Stops the browser and instance properly

Advanced Usage

Environment Variables

Add additional environment variables to .env as needed:

SCRAPYBARA_API_KEY=your_key
ANTHROPIC_API_KEY=your_key  # If using your own Anthropic key

Custom Model Configuration

Modify the model initialization to use your own API key:

model: anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

Cursor Rules

We've included a .cursorrules file that contains instructions for working with the Scrapybara SDK.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

MIT

Support

For Scrapybara SDK issues:

For template project issues:

  • Open an issue in this repository

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published