Skip to content
Open
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
35 changes: 31 additions & 4 deletions .github/workflows/platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
run: bash scripts/build-chatbot.sh
- name: Let Chromium use its sandbox as an unprivileged user
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
# Engine and API tests run SOP nodes in the shared test-native sandbox,
# which is bwrap on Linux.
- name: Install bubblewrap for the native sandbox
run: sudo apt-get update && sudo apt-get install -y bubblewrap
- name: Warm up Chromium so the first real-browser test does not pay the cold start
run: |
for name in chromium chromium-browser google-chrome-stable google-chrome; do
Expand Down Expand Up @@ -87,6 +91,19 @@ jobs:
working-directory: e2e
- run: bash ../scripts/install-playwright-deps.sh npx playwright
working-directory: e2e
# The e2e SOPs and the runner the suite starts use the native e2e sandbox,
# which is bwrap on Linux.
- name: Let bubblewrap create user namespaces
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Install bubblewrap for the native sandbox
run: sudo apt-get update && sudo apt-get install -y bubblewrap
# The welcome SOP runs in generic-docker. As in a Compose installation, it
# uses the pinned platform image instead of building one during the tests.
- name: Pull the pinned platform image for the generic-docker sandbox
run: |
pinned=$(sed -n 's/^ *image: \${LOOPFORGE_IMAGE:-\(.*\)}$/\1/p' compose.yaml)
docker pull --quiet "$pinned"
echo "AGENTFLOW_ISOLATED_IMAGE=$pinned" >> "$GITHUB_ENV"
- name: Start clean local installation
run: |
bash scripts/dev.sh > /tmp/loopforge.log 2>&1 &
Expand Down Expand Up @@ -172,6 +189,8 @@ jobs:
# The path a new user takes: one-command install, then accounts created in the browser.
# Pulls the GHCR release pinned in compose.yaml; release.yml smoke-tests each newly published image.
# A pin bumped ahead of its tag has no image yet, so that commit is checked from source.
# So is a commit whose schema scripts differ from the pinned tag: the installer applies
# this checkout's scripts, which the released image may not be able to read.
runs-on: ubuntu-latest
timeout-minutes: 30
env:
Expand All @@ -187,14 +206,22 @@ jobs:
working-directory: e2e
- run: bash ../scripts/install-playwright-deps.sh npx playwright
working-directory: e2e
- name: Install the pinned release, or build it while that release is not published yet
- name: Install the pinned release, or build this checkout when the release cannot run it
run: |
pinned=$(sed -n 's/^ *image: \${LOOPFORGE_IMAGE:-\(.*\)}$/\1/p' compose.yaml)
if docker manifest inspect "$pinned" > /dev/null 2>&1; then
./start.sh -d
else
tag="v${pinned##*:}"
schema=(migrations scripts/install-schema-extensions.sh scripts/install-observability-schema.sh)
if ! docker manifest inspect "$pinned" > /dev/null 2>&1; then
echo "::notice::$pinned is not published yet; building this checkout"
./start.sh dev
elif ! git fetch --quiet --depth=1 origin "refs/tags/$tag:refs/tags/$tag"; then
echo "::warning::could not fetch $tag to compare schema scripts; installing $pinned"
./start.sh -d
elif ! git diff --quiet "$tag" -- "${schema[@]}"; then
echo "::notice::schema scripts changed since $tag; building this checkout"
./start.sh dev
else
./start.sh -d
fi
- name: Generate test passwords
run: |
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Preserve the platform architecture; keep deployment-specific adapters isolated.

| 领域 Repo | 拥有 |
|---|---|
| `CatalogRepo` | agents/rules/skills/MCP servers/executors/dockerfiles/environments/sandboxes/workflows/repositories/sync config/schedule jobs/definition revisions/generic templates |
| `CatalogRepo` | agents/rules/skills/MCP servers/executors/sandboxes(docker 内嵌 Dockerfile,native 只有环境变量)/workflows/repositories/sync config/schedule jobs/definition revisions/generic templates |
| `ProjectsRepo` | projects、project members |
| `IssuesRepo` | issues、issue comments |
| `TasksRepo` | tasks(跨实例幂等记录) |
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. LoopForge Local packages use `local-vX.Y.Z` tags and are published by manually running the `release-local` workflow.

## Unreleased

- **Breaking:** the `local` sandbox type is removed and native sandboxes only carry environment variables. A native sandbox runs on whichever machine executes the work (a user's execution machine, a cloud runner or the platform host) with that machine's own toolchains; environment install scripts, `$PREFIX` and install PATH entries are gone, and settings such as `JAVA_HOME` go into the sandbox's environment variables. SOPs and conversation workspaces can use Docker or native sandboxes; the default sandbox is `generic-docker`, and `AGENTFLOW_LOCAL_SANDBOX` is removed. A local row that was not migrated reads as native; a run frozen with a local sandbox asks to be started again with a native one.
- Native workspaces check repositories out from a per-machine repository cache. Each Runner and the platform host keep a bare cache per repository record under their workspace root (`.repository-cache/<repository id>.git`), fetched outside the sandbox under a lock and never garbage-collected. SOP checkouts in native sandboxes become `git clone --shared` of the refreshed cache with origin set back to the repository URL, falling back to a full clone; Docker sandboxes keep full clones. Opening a native conversation workspace warms the project's repository caches in the background, and the repository list sent to the agent tells it to clone from `$LOOPFORGE_REPOSITORY_CACHE` (read-only inside the sandbox) before falling back to a normal clone. Workspace checkpoints copy the borrowed objects in first, so they restore on machines without the cache. Runner 0.12.0 checks out from and warms the cache; older Runners keep full clones.
- 设置 → AI 助手 gains 「对话工作区」: users choose the sandbox kind (Docker or native) the assistant prefers when it opens a conversation workspace itself. The preference (`workspaceDriver` in `/api/assistant/preferences`) puts that kind first in the assistant's choices and is used when it names no environment; the assistant still switches when only another environment has the toolchain a task needs, and a conversation's fixed environment still wins. The workbench environment picker now also lists native sandboxes, grouped by kind. Startup AutoMigrate adds the column; the migration below also adds it for deployments that apply DDL by hand.
- **Breaking:** a docker sandbox now carries its own Dockerfile, and the 环境资产 page becomes 「沙箱管理」 without type tabs: the sandbox editor holds the Dockerfile and its build-context files for docker, and only environment variables for native. Dockerfiles and install scripts are no longer separate assets. `/api/dockerfiles`, `/api/environments`, the `dockerfiles_*` / `environments_*` assistant and MCP tools and the `dockerfiles` / `environments` bootstrap fields are removed; `PUT /api/sandboxes` takes `dockerfile {content, files}` in place of `dockerfileId`, and rejects `driver: local`. Before starting the upgraded platform, apply `migrations/041_native_sandbox_inline_assets.sql` to existing databases with `./start.sh migrate-sandboxes` for Compose or directly for external MySQL. It copies each referenced Dockerfile into its sandbox, turns one that no sandbox used into a sandbox of its own, turns local sandboxes into native ones, drops install scripts and `PATH` from native sandbox variables, moves the built-in SOPs that used the old `local` profile to `generic-docker`, and drops the `dockerfiles` and `environments` tables. Docker images are reused.

## 0.4.1 — Git and MCP credentials, SOP orchestration and conversation workspaces

- Configure HTTPS Git credentials per host, authorize the IP addresses of self-hosted HTTPS Git servers, and distribute trusted SSH host keys to execution machines. MCP servers, market items and SOP nodes can use configured credentials.
Expand Down
20 changes: 15 additions & 5 deletions chatbot/src/SandboxPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ import { SelectMenu } from "./ui";
import HarnessIcon from "./HarnessIcon";
import "./sandbox-picker.css";

const SANDBOX_KINDS = ["docker", "native"];
const SANDBOX_KIND_LABELS = {
docker: "Docker",
native: "系统轻量隔离",
};

function sandboxKind(sandbox) {
return !sandbox.driver || sandbox.driver === "docker" ? "docker" : "native";
}

export function conversationSandboxOptions(sandboxes, project, selected = "") {
const available = (sandboxes || []).filter(
(s) => s.driver === "docker" && (s.projectId === project?.id || s.shared),
);
const available = (sandboxes || [])
.filter((s) => s.projectId === project?.id || s.shared)
.sort((a, b) => SANDBOX_KINDS.indexOf(sandboxKind(a)) - SANDBOX_KINDS.indexOf(sandboxKind(b)));
const options = [
{ value: "", label: "由 Agent 选择" },
...available.map((s) => ({ value: s.id, label: s.name || s.id })),
...available.map((s) => ({ value: s.id, label: s.name || s.id, kind: sandboxKind(s) })),
];
if (selected && !available.some((s) => s.id === selected)) {
options.push({
Expand Down Expand Up @@ -58,7 +68,7 @@ export default function SandboxPicker({ chat, onCreate }) {
.map((o) => ({
id: o.value,
label: o.label,
description: o.value ? "" : "按要改的代码自动选择,拿不准时用平台通用 Docker",
description: o.value ? SANDBOX_KIND_LABELS[o.kind] : "按 AI 助手设置里倾向的沙箱和任务需要自动选择",
icon: o.value ? "terminal" : "folder",
}));
return (
Expand Down
2 changes: 0 additions & 2 deletions chatbot/src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ const entities = {
assistant_tasks: "助手定时任务",
runs: "运行",
issues: "需求",
environments: "环境",
sandboxes: "沙箱",
dockerfiles: "Dockerfile",
executors: "执行器",
};
const verbs = {
Expand Down
12 changes: 9 additions & 3 deletions chatbot/tests/sandbox-picker.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const sandboxes = [
{ id: "business", name: "PHP 业务环境", projectId: "p", driver: "docker" },
{ id: "shared", name: "共享环境", shared: true, driver: "docker" },
{ id: "private", name: "其他业务私有环境", projectId: "other", driver: "docker" },
{ id: "local", name: "宿主机", shared: true, driver: "local" },
];

describe("conversation environment selection", () => {
Expand All @@ -28,14 +27,21 @@ describe("conversation environment selection", () => {
expect(select).not.toHaveBeenCalled();
});

test("defaults to the agent's choice and lists only accessible containers", () => {
test("defaults to the agent's choice and lists only accessible sandboxes", () => {
const options = conversationSandboxOptions(sandboxes, project);
expect(options.map((o) => o.value)).toEqual(["", "business", "shared"]);
expect(options[0].label).toBe("由 Agent 选择");
const missing = conversationSandboxOptions(sandboxes, project, "deleted").at(-1);
expect(missing).toMatchObject({ value: "deleted", disabled: true });
});

test("lists native sandboxes after the Docker ones", () => {
const rows = [{ id: "light", name: "轻量沙箱", projectId: "p", driver: "native" }, ...sandboxes];
const options = conversationSandboxOptions(rows, project, "");
expect(options.map((o) => o.value)).toEqual(["", "business", "shared", "light"]);
expect(options.find((o) => o.value === "light")).toMatchObject({ kind: "native" });
});

test("a task conversation shows the task environment", () => {
render(<SandboxPicker chat={{
projectId: "p", projects: [project],
Expand All @@ -62,7 +68,7 @@ describe("conversation environment selection", () => {
trigger.getBoundingClientRect = () => ({top:500,bottom:528,left:200,right:450,width:250,height:28});
const user = userEvent.setup();
await user.click(trigger);
await user.click(screen.getByRole("option", { name: "PHP 业务环境" }));
await user.click(screen.getByRole("option", { name: /^PHP 业务环境/ }));
expect(select).toHaveBeenCalledWith("business");
});
});
2 changes: 1 addition & 1 deletion cmd/agentflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
runtime.SetRepositoryCacheRoot(root)
s, err := repo.Open(strings.TrimSpace(*mysqlDSN))
if err != nil {
log.Fatal(err)
}
log.Printf("storage driver=%v database=%v role=%s", s.StorageInfo()["driver"], s.StorageInfo()["database"], role)
e := engine.New(s, runtime.NewManagerWithLimit(root, *workerConcurrency))
runtime.PrebuildIsolatedImage()
host, _ := os.Hostname()
instanceID := strings.TrimSpace(os.Getenv("AGENTFLOW_INSTANCE_ID"))
if instanceID == "" {
Expand Down
1 change: 0 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ services:
AGENTFLOW_PREVIEW_PUBLIC_URL: ${AGENTFLOW_PREVIEW_PUBLIC_URL:-}
AGENTFLOW_PLATFORM_MCP_URL: ${AGENTFLOW_PLATFORM_MCP_URL:-http://platform:8080}
AGENTFLOW_DOCKER_NETWORK: ${COMPOSE_PROJECT_NAME:-loopforge}_default
AGENTFLOW_LOCAL_SANDBOX: docker
AGENTFLOW_ISOLATED_IMAGE: ${LOOPFORGE_IMAGE:-ghcr.io/tencent/loopforge:0.4.1}
HOME: ${LOOPFORGE_DATA_DIR:?Run scripts/configure.sh first}/home
AGENTFLOW_RUNNER_BINARY: /app/bin/agentflow-runner-{os}-{arch}
Expand Down
4 changes: 2 additions & 2 deletions design.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ Bot 管理页(`#botsView`)按需求列表与运行记录列表的 Harness

界面上称「AI 助手」,避免和「Bot 管理」里的企业微信机器人混淆。设置页、SOP 建议卡片和子 Agent 面板都用这个名字。

AI 助手页(`#assistantView`,路由 `#/assistant`)在设置导航「管理与记录」下紧跟 Bot 管理,图标为 Harness `sparkles`。页头只有 H1 和一句说明(先讲它是谁,再讲能设置什么);内容和其他设置页一样铺满 1200px 居中容器,使用三块 14px 圆角面板:「消息发送」提供「生成中发送消息」下拉选项,默认「排队」,也可选「立即发送」,说明会打断当前回复、保留已输出内容并继续处理新消息;「主动派发」里是「主动派角色」「主动走 SOP」两行(默认关闭,面板说明写明打开后更主动,以及角色直接派、SOP 先确认),左侧标题 + 说明,右侧 `role="switch"` 开关;「自定义规则」是一个可纵向拉伸的输入框,右下角显示「N / 4000」。底部「保存」是页面唯一的实心按钮,没有改动或保存中时禁用;未登录只显示提示。样式在 `web/app/assistant-settings.css`,规则限定在 `#assistantView` 内,只引用 `--hui-*` 令牌。
AI 助手页(`#assistantView`,路由 `#/assistant`)在设置导航「管理与记录」下紧跟 Bot 管理,图标为 Harness `sparkles`。页头只有 H1 和一句说明(先讲它是谁,再讲能设置什么);内容和其他设置页一样铺满 1200px 居中容器,使用四块 14px 圆角面板:「消息发送」提供「生成中发送消息」下拉选项,默认「排队」,也可选「立即发送」,说明会打断当前回复、保留已输出内容并继续处理新消息;「主动派发」里是「主动派角色」「主动走 SOP」两行(默认关闭,面板说明写明打开后更主动,以及角色直接派、SOP 先确认),左侧标题 + 说明,右侧 `role="switch"` 开关;「对话工作区」提供「倾向的沙箱」下拉选项,默认「由 Agent 选择」,也可选 Docker 或 native 沙箱,说明写明会话固定了环境时不生效、任务需要时仍会换;「自定义规则」是一个可纵向拉伸的输入框,右下角显示「N / 4000」。底部「保存」是页面唯一的实心按钮,没有改动或保存中时禁用;未登录只显示提示。样式在 `web/app/assistant-settings.css`,规则限定在 `#assistantView` 内,只引用 `--hui-*` 令牌。

发送方式按用户保存为 `steerOnSend`,设置保存后通知已打开的工作台即时刷新。立即发送复用排队消息的「引导」操作;引导切换期间再次发送的消息先排队,引导请求失败也保留消息。手动「引导」仍可用于排队模式。
发送方式按用户保存为 `steerOnSend`,倾向的沙箱按用户保存为 `workspaceDriver`,设置保存后通知已打开的工作台即时刷新。立即发送复用排队消息的「引导」操作;引导切换期间再次发送的消息先排队,引导请求失败也保留消息。手动「引导」仍可用于排队模式。

没有 @ SOP、也没有点名要走 SOP 时,AI 助手自己决定交给 SOP 的事是建议。每次批准由用户在卡片上确认;帮我批准由独立审查决定,未通过时同样变成建议卡片;完全权限下直接启动。角色始终直接派发,不弹卡片。`timing=start` 的建议 3 分钟无人处理就超时,服务端把事情交回 AI 助手自己做,不依赖浏览器还开着。决定通过 `POST /api/assistant/sessions/{id}/proposals` 提交。开关和自定义规则按用户存在 `assistant_preferences`,由 AutoMigrate 建表,接口是 `GET` / `PUT /api/assistant/preferences`。

Expand Down
2 changes: 0 additions & 2 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ curl -H "Authorization: Bearer $AGENTFLOW_TOKEN" "$AGENTFLOW_URL/api/health"
| `GET`, `PUT` | `/api/mcp-servers` |
| `POST` | `/api/mcp-servers/import` |
| `GET` | `/api/executors` |
| `GET`, `PUT`, `DELETE` | `/api/dockerfiles` |
| `GET`, `PUT`, `DELETE` | `/api/environments` |
| `GET`, `PUT`, `DELETE` | `/api/sandboxes` |

### 编排、运行与观测
Expand Down
Loading
Loading