npm.io
2.1.1 • Published 1 month ago

novita-sandbox

Licence
—
Version
2.1.1
Deps
10
Size
3.5 MB
Vulns
0
Weekly
0

Novita Agent Sandbox JS SDK

A TypeScript/JavaScript SDK for Novita Agent Sandbox environments that provides code execution, desktop automation, and cloud computing capabilities..

Table of Contents

Installation

npm install novita-sandbox

Features

  • Code Interpreter: Execute Python, JavaScript, and other languages in isolated environments
  • Desktop Automation: Control desktop applications and GUI interactions
  • Cloud Computing: Scalable sandbox environments for various computing tasks
  • Data Visualization: Built-in charting and visualization capabilities
  • File System Operations: Complete file system management and monitoring

Authentication

Get your Novita API key from here.

Usage

Core Sandbox

Use the high-level Novita client to share one set of credentials across namespaces.

import { Novita } from 'novita-sandbox';

const novita = new Novita({
  apiKey: process.env.NOVITA_API_KEY || '',
});

// Using the official template `base` by default.
const sandbox = await novita.sandbox.create('base');

// File operations
await sandbox.files.write('/tmp/test.txt', 'Hello, World!');
const content = await sandbox.files.read('/tmp/test.txt');

// Command execution
const result = await sandbox.commands.run('ls -la /tmp');
console.log(result.stdout);

// Real-time monitoring
sandbox.files.watchDir('/tmp', (event) => {
  console.log(`File ${event.name} was ${event.type}`);
});
Code Interpreter

The Code Interpreter sandbox is available through the same client.

import { Novita } from 'novita-sandbox';

const novita = new Novita({
  apiKey: process.env.NOVITA_API_KEY || '',
});

const sandbox = await novita.codeInterpreter.create();

// Execute Python code
const result = await sandbox.runCode('print("Hello, World!")');
console.log(result.logs);
Desktop Automation

The Desktop sandbox is available through the same client.

import { Novita } from 'novita-sandbox';

const novita = new Novita({
  apiKey: process.env.NOVITA_API_KEY || '',
});

const desktop = await novita.desktop.create();

// Take a screenshot
const screenshot = await desktop.screenshot();

// Automate mouse and keyboard
await desktop.leftClick(100, 200);
await desktop.press('Enter');
await desktop.write('Hello, World!');

Documentation

For comprehensive guides and API reference, visit the official documentation.

Keywords