Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public void start() {
logger.info("Using in-memory container storage");
}

logger.info("Using container type: " + this.containerManagerType);

switch (this.containerManagerType) {
case DOCKER:
DockerClientConfig dockerClientConfig;
Expand All @@ -155,6 +157,8 @@ public void start() {
dockerClientConfig.setRedisConfig(managerConfig.getRedisConfig());

DockerClient dockerClient = new DockerClient(dockerClientConfig);
logger.info("Docker client created: " + dockerClient);

this.containerClient = dockerClient;
this.client = dockerClient.connectDocker();
break;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -36,6 +37,7 @@
* <li>If port conflicts occur, SandboxManager will automatically retry</li>
* </ul>
*/
@EnabledIfDockerAvailable
public class ContainerPoolTest {

private SandboxManager manager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import io.agentscope.runtime.sandbox.manager.model.container.SandboxType;
import io.agentscope.runtime.sandbox.manager.model.container.ContainerModel;
import org.junit.jupiter.api.condition.EnabledIf;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import java.util.UUID;

Expand All @@ -35,6 +37,8 @@
* Docker Sandbox Lifecycle Test
* Tests sandbox creation, startup, status checking, stopping and cleanup functionality in Docker environment
*/
@EnabledIfDockerAvailable
@EnabledIf(value = "isCI", disabledReason = "this test is designed to run only in the GitHub CI environment.")
public class DockerLifecycleTest {

private SandboxManager sandboxManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import java.io.File;
import java.io.FileWriter;
Expand All @@ -42,6 +43,7 @@
* Environment Variable Configuration:
* - LOCAL_STORAGE_PATH: Local storage root directory path (optional, defaults to ./test_storage)
*/
@EnabledIfDockerAvailable
public class LocalFileSystemTest {

private String localStoragePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import static org.junit.jupiter.api.Assertions.*;

@EnabledIfDockerAvailable
public class BaseToolsTest {

private SandboxManager sandboxManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import static org.junit.jupiter.api.Assertions.*;

/**
* Test browser tools that require page element interaction
* These tests require pages with specific elements to work properly
*/
@EnabledIfDockerAvailable
public class BrowserInteractiveToolsTest {

private SandboxManager sandboxManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import static org.junit.jupiter.api.Assertions.*;

@EnabledIfDockerAvailable
public class BrowserToolsTest{

private SandboxManager sandboxManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.EnabledIfDockerAvailable;

import static org.junit.jupiter.api.Assertions.*;

@EnabledIfDockerAvailable
public class FilesystemToolsTest{

private SandboxManager sandboxManager;
Expand Down
141 changes: 141 additions & 0 deletions examples/browser_use_fullstack_runtime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Browser Use Demo

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
![Java](https://img.shields.io/badge/language-Java-orange)
![Node.js](https://img.shields.io/badge/node.js-v23.9.0-green)
![React](https://img.shields.io/badge/react-v19.1.0-green)

This demo showcases browser automation capabilities built on AgentScope Runtime, with a Spring Boot backend and a React frontend. Visualization is powered by [Steel-Browser](https://github.com/steel-dev/steel-browser).

<img src="" alt="video of browser-use demo" width="800">

## Project Structure

```bash
├── backend # Java backend (Spring Boot)
│ ├── src/main/java/io/agentscope/browser/
│ │ ├── BrowserAgentApplication.java # Application entrypoint
│ │ ├── agent/AgentscopeBrowseruseAgent.java # Browser agent implementation
│ │ ├── constants/Prompts.java # System prompts
│ │ └── controller/ChatController.java # OpenAI-like & A2A endpoints
│ ├── src/main/resources/application.yml # Spring Boot config
│ └── pom.xml
├── frontend # React frontend
│ ├── public/ # Static assets & HTML template
│ ├── src/ # React source
│ ├── package.json
│ └── tsconfig.json
└── README.md # This file
```

## Features

- Browser navigation, form filling, page data extraction, and automated workflows
- Real-time visualization of browser actions
- OpenAI-compatible SSE streaming and A2A-protocol streaming

## Architecture

```mermaid
graph LR;
subgraph As["AgentScope Runtime"]
E[Sandbox]-->E1[Browser sandbox]
F[Agent Engine]
F-->|tool call| E
end
subgraph Bs["Frontend (React)"]
B['React App']
end
subgraph Cs["Backend (Spring Boot)"]
C['ChatController']
C --> D[AgentscopeBrowseruseAgent]
end
A[User] --> |request| Bs
B --> C
D --> E
D --> F
```

## Getting Started

### Prerequisites

1. Install Node.js
2. Install Java 17+
3. Install Maven 3.6+
4. Set DashScope API Key environment variable:

```bash
export DASHSCOPE_API_KEY=your_api_key_here
# or
export AI_DASHSCOPE_API_KEY=your_api_key_here
```

### Install and Run Frontend

```bash
cd frontend
npm install
npm run start
# The browser will open automatically, or visit http://localhost:3000
```

### Build and Run Java Backend

First build the parent project at repo root:

```bash
cd ../../..
mvn clean install -DskipTests
```

Then build and start the example backend:

```bash
cd examples/browser_use_fullstack_runtime/backend
mvn clean package

# Option 1: Run with Maven
mvn spring-boot:run

# Option 2: Run the JAR
java -jar target/browser-agent-backend-1.0.0.jar
```

Default port: 8080 (configurable in `application.yml`).

### Usage

1. Open http://localhost:3000
2. Enter a task, e.g., "Visit www.google.com and search for AgentScope"
3. The frontend will display browser actions and model outputs in real-time

## API Summary (Backend)

- Chat Completions (SSE): `POST /v1/chat/completions`, `POST /chat/completions`
- Browser Env Info: `GET /env_info`
- A2A Completions (SSE): `POST /a2a/`

## Logging & Troubleshooting

- Adjust log level (`application.yml`):

```yaml
logging:
level:
io:
agentscope:
browser: DEBUG
```

- Port conflict: set `server.port: 9000` (or other) in `application.yml` and update the frontend connection accordingly.
- Check API Key: `echo $DASHSCOPE_API_KEY`
- Docker (browser sandbox): ensure Docker is running: `docker ps`

## License

Apache 2.0

## Disclaimer

##### This project is for demonstration purposes only and not intended for production use.
32 changes: 32 additions & 0 deletions examples/browser_use_fullstack_runtime/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# IDE
.idea/
*.iml
.vscode/
.settings/
.project
.classpath

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db

# Environment
.env
.env.local

Loading
Loading