Skip to content

Commit 0b86c36

Browse files
authored
feat(sandbox): migrate to standalone Rust proxy and implement stateless WSS gateway with dynamic file sync (#7034)
* feat(sandbox): implement stateless WSS gateway, Rust agent-proxy service, and interactive terminal - Implement stateless WSS gateway for agent-sandbox connection. - Migrate WSS proxy to a standalone Rust service. - Integrate interactive PTY terminal and clean up obsolete APIs. - Add unit & integration tests for Rust proxy & agent with CI workflow. - Unify proxy secrets under AGENT_SANDBOX_PROXY_SECRET. - Implement fine-grained session ticket permissions & enhance proxy log security. * refactor(sandbox): upgrade agent & proxy to Rust 2024, optimize file operations, and support connection limiting - Implement dynamic file change sync with debounce and robust connection limiting. - Upgrade Rust dependencies, split ide agent modules and enhance file access security. - Optimize Docker build targets, configure default Sealos image, and implement native file operations. - Support dynamic gateway hostnames, add proxy ping keepalive, and refine terminal resize checks. - Upgrade to Rust 2024, secure workspace operations, and refine adapter helpers. * feat(skill): redesign skill detail page with split layout and refine sandbox editor styling * refactor(sandbox): optimize edit-debug hot-reload and skip S3 pull on cold-start - Refine edit-debug sandbox hot-reload and auto resume logic. - Skip S3 pull on cold-start when volume exists and fix OpenSandbox getInfo. * feat(sandbox): implement cold archive and restore, unify file limits, and relax proxy secret * style(skill): adjust chatbox and input layout padding for skill detail page * feat(sandbox): add archive migration API and restore support for empty or archived workspaces refactor(sandbox): enhance workspace archiving/restore, zip safety, and websocket stability * feat(sandbox): migrate archived records across providers, adjust probe timeout and command limits * feat(skill): add preview empty state, disable sending before sandbox ready, and unify error handling * refactor(skill): simplify export, fix import encoding, and use default LLM * feat(sandbox): ensure zip availability and track archiving failures * feat(sandbox): refactor workspace fs watcher with debouncer, improve terminal styling, and add archive progress tracking - rust ide agent: Integrate notify-debouncer-full to debounce workspace file system events and broadcast batches with sequential numbers to handle lagged events. - frontend/sandbox: Remove client-side debounce in favor of backend debouncing, refine workspace file tree refreshing, and adjust terminal background and horizontal padding. - archive: Introduce onProgress callback for resource archiving and utilize it in initSandboxArchive API to log real-time progress and errors. * docs(skill): comprehensive user guides for agent skills * refactor(sandbox): improve TS safety, simplify markdown frontmatter, and support sandboxToolMap info
1 parent 4b1f79f commit 0b86c36

229 files changed

Lines changed: 15295 additions & 4422 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-agent-sandbox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
id: build
6868
uses: docker/build-push-action@v6
6969
with:
70-
context: projects/agent-sandbox
70+
context: .
7171
file: projects/agent-sandbox/Dockerfile
7272
platforms: linux/${{ matrix.arch }}
7373
labels: |
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build fastgpt-ide-agent images
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-fastgpt-ide-agent-images:
8+
permissions:
9+
packages: write
10+
contents: read
11+
strategy:
12+
matrix:
13+
include:
14+
- arch: amd64
15+
- arch: arm64
16+
runs-on: ubuntu-24.04-arm
17+
runs-on: ${{ matrix.runs-on || 'ubuntu-24.04' }}
18+
steps:
19+
# install env
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
with:
27+
driver-opts: network=host
28+
- name: Cache Docker layers
29+
uses: actions/cache@v4
30+
with:
31+
path: /tmp/.buildx-cache
32+
key: ${{ runner.os }}-ide-agent-buildx-${{ github.sha }}
33+
restore-keys: |
34+
${{ runner.os }}-ide-agent-buildx-
35+
36+
# Push per-arch images by digest first; the release job publishes the latest manifest.
37+
- name: Login to GitHub Container Registry
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.repository_owner }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Build for ${{ matrix.arch }}
45+
id: build
46+
uses: docker/build-push-action@v6
47+
with:
48+
context: projects/fastgpt-ide-agent
49+
file: projects/fastgpt-ide-agent/Dockerfile
50+
platforms: linux/${{ matrix.arch }}
51+
labels: |
52+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
53+
org.opencontainers.image.description=fastgpt-ide-agent image
54+
outputs: type=image,"name=ghcr.io/${{ github.repository_owner }}/fastgpt-ide-agent",push-by-digest=true,push=true
55+
cache-from: type=local,src=/tmp/.buildx-cache
56+
cache-to: type=local,dest=/tmp/.buildx-cache
57+
58+
- name: Export digest
59+
run: |
60+
mkdir -p ${{ runner.temp }}/digests
61+
digest="${{ steps.build.outputs.digest }}"
62+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
63+
64+
- name: Upload digest
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: digests-fastgpt-ide-agent-${{ github.sha }}-${{ matrix.arch }}
68+
path: ${{ runner.temp }}/digests/*
69+
if-no-files-found: error
70+
retention-days: 1
71+
72+
release-fastgpt-ide-agent-images:
73+
permissions:
74+
packages: write
75+
contents: read
76+
needs: build-fastgpt-ide-agent-images
77+
runs-on: ubuntu-24.04
78+
steps:
79+
- name: Login to GitHub Container Registry
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ghcr.io
83+
username: ${{ github.repository_owner }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
- name: Download digests
86+
uses: actions/download-artifact@v4
87+
with:
88+
path: ${{ runner.temp }}/digests
89+
pattern: digests-fastgpt-ide-agent-${{ github.sha }}-*
90+
merge-multiple: true
91+
92+
- name: Set up Docker Buildx
93+
uses: docker/setup-buildx-action@v3
94+
95+
- name: Set image name and tag
96+
run: |
97+
echo "Git_Latest=ghcr.io/${{ github.repository_owner }}/fastgpt-ide-agent:latest" >> $GITHUB_ENV
98+
99+
- name: Create manifest list and push
100+
working-directory: ${{ runner.temp }}/digests
101+
run: |
102+
docker buildx imagetools create -t "${Git_Latest}" \
103+
$(printf 'ghcr.io/${{ github.repository_owner }}/fastgpt-ide-agent@sha256:%s ' *)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 'Rust-Agent-Test'
2+
on:
3+
pull_request:
4+
paths:
5+
- 'projects/agent-sandbox-proxy/**'
6+
- 'projects/fastgpt-ide-agent/**'
7+
- '.github/workflows/test-rust-agent.yaml'
8+
push:
9+
branches:
10+
- main
11+
paths:
12+
- 'projects/agent-sandbox-proxy/**'
13+
- 'projects/fastgpt-ide-agent/**'
14+
- '.github/workflows/test-rust-agent.yaml'
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
env:
21+
CARGO_TERM_COLOR: always
22+
CARGO_INCREMENTAL: 0
23+
24+
jobs:
25+
test-rust-projects:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v6
29+
30+
- name: Install Rust toolchain
31+
uses: dtolnay/rust-toolchain@stable
32+
with:
33+
components: clippy, rustfmt
34+
35+
- name: Rust Cache
36+
uses: Swatinem/rust-cache@v2
37+
with:
38+
shared-key: "fastgpt-rust-agent-cache"
39+
workspaces: |
40+
projects/agent-sandbox-proxy
41+
projects/fastgpt-ide-agent
42+
43+
# --- agent-sandbox-proxy Checks & Tests ---
44+
- name: Run agent-sandbox-proxy fmt check
45+
run: cargo fmt --check
46+
working-directory: projects/agent-sandbox-proxy
47+
48+
- name: Run agent-sandbox-proxy clippy check
49+
run: cargo clippy --locked -- -D warnings
50+
working-directory: projects/agent-sandbox-proxy
51+
52+
- name: Run agent-sandbox-proxy tests
53+
run: cargo test --locked
54+
working-directory: projects/agent-sandbox-proxy
55+
56+
# --- fastgpt-ide-agent Checks & Tests ---
57+
- name: Run fastgpt-ide-agent fmt check
58+
run: cargo fmt --check
59+
working-directory: projects/fastgpt-ide-agent
60+
61+
- name: Run fastgpt-ide-agent clippy check
62+
run: cargo clippy --locked -- -D warnings
63+
working-directory: projects/fastgpt-ide-agent
64+
65+
- name: Run fastgpt-ide-agent tests
66+
run: cargo test --locked
67+
working-directory: projects/fastgpt-ide-agent

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pro/admin/worker/
4242

4343
.turbo
4444
.antigravitycli
45+
.chrome-user-data
4546

4647
# content_benchmark local secrets and generated artifacts
4748
/pro/llm_benchmark/content_benchmark/.env.local

deploy/version/v4.14/docker-compose.template.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ ${{vec.db}}
209209
AGENT_SANDBOX_ENABLE_VOLUME: true
210210
AGENT_SANDBOX_VOLUME_MANAGER_URL: http://fastgpt-volume-manager:3000
211211
AGENT_SANDBOX_VOLUME_MANAGER_TOKEN: *x-volume-manager-auth-token
212-
AGENT_SANDBOX_VOLUME_MANAGER_MOUNT_PATH: /workspace
213212

214213
# ==================== 日志与监控 ====================
215214
# 传递给 OTLP 收集器的服务名称

document/content/guide/build/meta.en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"general",
66
"workflow",
77
"tools",
8+
"skill",
89
"publish",
910
"evaluation",
1011
"faq"

document/content/guide/build/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"general",
66
"workflow",
77
"tools",
8+
"skill",
89
"publish",
910
"evaluation",
1011
"faq"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Development & Debugging
3+
description: This guide details how to create or import a skill, and manage files, use the interactive terminal, and perform debug chat in Web IDE.
4+
---
5+
6+
import { Alert } from '@/components/docs/Alert';
7+
8+
## 1. Creating & Importing Skills
9+
10+
Before writing code, you need to create a development project in the skills list. The platform supports two ways to create or load a skill:
11+
12+
![Creating & Importing Skills](/imgs/create_import_skill.png)
13+
14+
### 1.1 Click the Create Area to Create a Skill
15+
16+
Click the "Create" card (the dashed box area with a plus icon) on the page. In the popup, set the skill name, icon, description, and **requirements**. When the system initializes the skill in the background, it takes different approaches based on your input:
17+
18+
- **Using Default Template**: If you leave the default "Goal/Process/Requirements" template unchanged, the system will use the built-in basic structure and boilerplate code to generate the skill workspace (without invoking AI models, consuming no points).
19+
- **AI-Assisted Generation**: If you input custom functional requirements here (e.g., "help me write a skill that extracts all email addresses from a text"), the system will invoke the **configured default system LLM model** in the background to automatically generate the `SKILL.md` scheme and initialize the code, which will consume points.
20+
21+
### 1.2 Import an Existing Skill ZIP Archive
22+
23+
If you have a skill backed up or shared by others, click the "Import Skill" button at the top right of the page and upload the corresponding ZIP archive. The system will automatically unzip it and restore all code files and configurations in the background, allowing you to resume development immediately.
24+
25+
---
26+
27+
## 2. Workspace File Management
28+
29+
When you open the skill details page, the system initializes and provisions an isolated run workspace in a secure sandbox container, loading your project via the file tree on the right.
30+
31+
![Workspace File Management](/imgs/workspace_file_management.png)
32+
33+
### 2.1 Multi-file Management
34+
35+
You can right-click or use action buttons on the file tree on the right to easily create, delete, rename, and move files or folders to organize your project structure.
36+
37+
### 2.2 Online Code Editing
38+
39+
Clicking any file in the tree opens it in the center editor:
40+
41+
- **Auto-Save**: The editor automatically saves and syncs your edits to the backend sandbox container as you type.
42+
- **Real-Time Workspace Sync**: The file tree automatically monitors and syncs file changes. Whether you edit files, install package dependencies in the terminal, or background processes generate new files, the tree stays updated.
43+
- **Change Isolation**: Any code changes made here only take effect instantly in the debugging environment, and will not directly affect live applications. To apply the latest code to production, you must click the "Publish" button to generate an official version. For details, please see [Versions & Publishing](/en/guide/build/skill/version).
44+
45+
### 2.3 Two-way Interactive Terminal
46+
47+
The command line terminal at the bottom right connects directly to the backend sandbox:
48+
49+
- **Running Commands**: You can enter various command line operations, such as installing required code dependencies online or executing various custom running and debugging scripts.
50+
- **Log Feedback**: The terminal streams command execution logs in real time. If code or script execution errors occur, you can view the error messages directly in the terminal output to assist with debugging.
51+
52+
---
53+
54+
## 3. Agent Debug Chat
55+
56+
The agent debug panel on the left provides a testing environment, allowing you to test and call your custom skill logic in real time by chatting with the agent:
57+
58+
![Agent Debug Chat](/imgs/agent_debug_chat.png)
59+
60+
### 3.1 Immediate Effect
61+
62+
Every time you modify and save your code in the right editor, you don't need to manually compile, build, or redeploy. Simply send a new message in the chat box on the left, and the system will run the latest code in the background, allowing you to see the changes instantly.
63+
64+
### 3.2 Conversational Workspace Modification
65+
66+
You can directly chat with the agent to have it help you edit the file contents on the right (including creating, deleting, and modifying files). The file tree and editor on the right will reflect these changes in real time.
67+
68+
### 3.3 Real-time File Export
69+
70+
You can click "Export Config" in the top-right menu to package all code and configuration files in the current workspace into a ZIP archive and download it locally for backup or sharing.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: 开发与调试
3+
description: 详细介绍如何新建或导入技能,并在 Web IDE 中管理文件、使用交互终端以及进行对话调试。
4+
---
5+
6+
import { Alert } from '@/components/docs/Alert';
7+
8+
## 1. 新建与导入技能
9+
10+
在开始编写代码前,你需要先在技能列表中创建一个开发项目。系统支持以下两种方式来创建或载入技能:
11+
12+
![新建与导入技能](/imgs/create_import_skill.png)
13+
14+
### 1.1 点击新建区域创建技能
15+
16+
在页面中点击带有加号的“新建”卡片,在弹出的窗口中设置技能名称、图标、介绍以及**需求描述**。系统在后台初始化该技能时,会根据你的输入采取不同的方式:
17+
18+
- **使用默认模板**:如果你保留默认的“目标/流程/要求”模板未作修改,系统将直接使用内置的基础结构和样例代码生成技能工作区(不调用 AI 模型,不产生积分消耗)。
19+
- **AI 辅助生成**:如果你在此输入了具体的功能需求(例如“帮我编写一个从文本中提取所有邮箱地址的技能”),系统在后台会调用**系统配置的默认大语言模型**,根据你的描述自动生成技能方案 `SKILL.md` 并完成代码初始化,这会产生相应的积分消耗。
20+
21+
### 1.2 导入已有技能 ZIP 压缩包
22+
23+
如果你手头有自己备份或他人分享的技能,可以点击页面右上角的“导入技能”按钮,上传对应的 ZIP 格式技能压缩包,系统会自动解压并在后台还原所有代码文件与配置,让你能够立即在此基础上继续开发。
24+
25+
---
26+
27+
## 2. 工作区文件管理
28+
29+
当你在后台打开技能详情页时,系统会在安全的沙盒容器中为你初始化并拉起一个独立的运行空间,同时在右侧通过文件树加载你的项目。
30+
31+
![工作区文件管理](/imgs/workspace_file_management.png)
32+
33+
### 2.1 多文件管理
34+
35+
你可以在右侧的文件树上右键或点击按钮,轻松进行文件的新建、删除、重命名和移动,灵活组织项目的目录结构。
36+
37+
### 2.2 代码在线编辑
38+
39+
在文件树中点击任意文件即可在中央编辑器中打开并编辑代码:
40+
41+
- **自动保存**:编辑器自带自动保存机制,代码修改完成后,系统会自动同步并写入后台沙盒中。
42+
- **实时状态刷新**:无论是你编辑保存、在终端安装依赖包,还是后台进程生成了新文件,右侧的文件树都会实时感知并刷新,自动同步展示最新状态。
43+
- **变更隔离**:此处进行的所有代码修改仅在调试区即时生效,不会直接影响到线上已发布运行的应用。若需应用最新的代码,需要先点击“发布”生成正式版本,具体发布逻辑请详见 [版本与发布](/guide/build/skill/version)
44+
45+
### 2.3 终端双向交互
46+
47+
右侧底部的命令行窗口(Terminal)直接连接到后台沙盒:
48+
49+
- **运行命令**:你可以在这里输入各种命令行操作,例如在线安装代码所需的依赖包,或是运行各类自定义测试与调试脚本等。
50+
- **日志反馈**:终端会实时输出命令执行的过程和日志。如果代码或脚本运行出错,可以直接通过终端输出的报错信息来辅助定位问题。
51+
52+
---
53+
54+
## 3. 智能体对话调试
55+
56+
左侧的智能体调试面板提供了一个测试环境,允许你通过与智能体对话来实时测试和调用你编写的技能逻辑:
57+
58+
![智能体对话调试](/imgs/agent_debug_chat.png)
59+
60+
### 3.1 即改即生效
61+
62+
每次你在右侧编辑器中修改并保存代码后,无需手动进行编译、打包或重新部署。只需在左侧调试框中发送下一条消息,系统便会在后台自动运行你最新的代码,让你能够立即看到修改后的效果。
63+
64+
### 3.2 对话式工作区修改
65+
66+
你可以直接通过与智能体对话,让它帮你编辑右侧的文件内容(包括文件的创建、删除、修改等),右侧的文件树和编辑器会实时同步展示这些变化。
67+
68+
### 3.3 实时文件导出
69+
70+
你可以点击页面右上角菜单中的“导出配置”,将当前工作区中实时的所有代码与配置文件打包成 ZIP 压缩包下载到本地,方便进行本地备份或分享。
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Agent Integration
3+
description: How to bind published skills to AI agents and execute them.
4+
---
5+
6+
import { Alert } from '@/components/docs/Alert';
7+
8+
## How to Bind a Skill to an Agent?
9+
10+
1. Go to the editing page of the **"Agent"** application where you want to integrate this skill (currently, only Agent applications support direct skill binding; simple apps and workflows do not support it).
11+
2. In the configuration panel on the left, locate the **"Associated Skill"** section.
12+
3. Click the **"Select"** button on the right, and in the popup list, select your published skill.
13+
14+
![Associate Skill & VM](/imgs/associated_skills_vm.png)
15+
16+
<Alert icon="💡" context="warning">
17+
**Note:** Skill code needs to execute within a secure and isolated environment. Therefore, when
18+
you associate a skill, the system will automatically enable the "Virtual Machine" for you; you
19+
cannot disable the virtual machine while a skill remains associated.
20+
</Alert>
21+
22+
---
23+
24+
## How Agents Call Skills
25+
26+
Once bound, the agent possesses this skill capability:
27+
28+
- **Multi-Skill Injection**: An agent can be bound to **multiple different skills** at the same time. When the sandbox (virtual machine) starts, all bound skill codes and configurations are automatically injected and deployed into the sandbox workspace. The skills are isolated from each other and will not conflict.
29+
- **Automated Invocation**: **Provided that the LLM used is sufficiently intelligent**, you don't need to manually command the agent to run code. The AI will automatically judge whether to trigger the skill based on your input, and execute it securely in the background sandbox.
30+
- **Virtual Machine File View**: You can click the **"Virtual Machine"** button at the bottom of the chat bubble (or the computer icon in the top right corner) to view all the latest files and code status in the virtual machine directly in the popup sidebar.
31+
32+
![Virtual Machine File View](/imgs/agent_chat_vm_files.png)

0 commit comments

Comments
 (0)