Skip to content

Latest commit

 

History

History
158 lines (116 loc) · 3.4 KB

File metadata and controls

158 lines (116 loc) · 3.4 KB
title description
Quickstart
Create your first Moru sandbox

The fastest way to try Moru is with the CLI.

CLI Quickstart

Install the CLI

curl -fsSL https://moru.io/cli/install.sh | bash

Hello World

# Login
moru auth login

# Run a command and get destroyed automatically
moru sandbox run base echo 'hello world!'

# List sandboxes
moru sandbox list

# View logs
moru sandbox logs <id>

Create/Kill

# Create a sandbox
moru sandbox create base

# Run a command inside
moru sandbox exec <id> 'sh -c "echo Hello Moru > /tmp/note.txt"'

# Run another command
moru sandbox exec <id> cat /tmp/note.txt

# Kill when done
moru sandbox kill <id>

SDK Quickstart

Install the SDK

```bash Python pip install moru ```
npm install @moru-ai/core

API Key Set Up

export MORU_API_KEY=your_api_key

Go to the API Keys tab if you didn't create an API key yet.

Create/Kill

```python Python from moru import Sandbox

Create a sandbox using the 'base' template (default)

sandbox = Sandbox.create() print(f"Sandbox created: {sandbox.sandbox_id}")

Run a command

result = sandbox.commands.run("echo 'Hello from Moru!'") print(f"Output: {result.stdout}")

Clean up

sandbox.kill()


```javascript JavaScript
import Sandbox from '@moru-ai/core'

// Create a sandbox using the 'base' template (default)
const sandbox = await Sandbox.create()
console.log(`Sandbox created: ${sandbox.sandboxId}`)

// Run a command
const result = await sandbox.commands.run("echo 'Hello from Moru!'")
console.log(`Output: ${result.stdout}`)

// Clean up
await sandbox.kill()

Streaming Output

Stream stdout/stderr in real-time for long-running commands.

```python Python sandbox.commands.run( "for i in 1 2 3; do echo $i; sleep 1; done", on_stdout=lambda data: print(data), on_stderr=lambda data: print(data), ) ```
await sandbox.commands.run("for i in 1 2 3; do echo $i; sleep 1; done", {
  onStdout: (data) => console.log(data),
  onStderr: (data) => console.error(data),
})

Monitor Sandbox Logs

After running your sandbox, you can view logs, monitor activity, and debug issues from the Sandboxes tab in your dashboard.

Using a Custom Template

With custom templates, you can build your own VM snapshot with your own agent pre-installed. See the Maru agent example and the templates documentation for more information.

```python Python sandbox = Sandbox.create("my-template") ```
const sandbox = await Sandbox.create('my-template')

Next Steps

Understand sandbox states and lifecycle management. Learn all file and directory operations. Master foreground, background, and interactive commands. Build templates with your specific dependencies.