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
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Preserve the platform architecture; keep deployment-specific adapters isolated.
1. **代码不做迁移、不做 seed。** `repo.Open()` 只负责连接和 gorm
AutoMigrate 的增量 DDL(补缺失的表/列/索引)。基线 schema、数据迁移
(改数据、删行、删列)和 seed 数据一律写成 `migrations/` 下的 SQL
脚本,由运维**手动执行**,部署时不会自动跑。
脚本。官方 Compose 安装与升级按部署文档执行指定的 SQL。迁移 041 由
`./start.sh pull` 在确认目标镜像兼容且数据库仍有旧资产表后、启动新版前执行。
其余需要运维处理的迁移按发布说明手动执行。
2. 每个分支自带自己的迁移脚本,不做任何自动化生成(没有 seedgen 之类的
工具)。脚本命名 `NNN_描述.sql`,按序号递增。
3. 禁止新增 `ensureXxx`/`migrateXxx`/`seedXxx` 之类的启动自愈逻辑写入
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. Loo
- **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 SOP checkouts use a private repository cache on each execution machine. The platform or Runner refreshes the bare repository with the checkout's Git credentials and copies Git objects into the worktree. This reuses the network fetch and leaves each worktree and checkpoint independent. Docker sandboxes keep direct clones. Conversation workspaces start empty and the agent clones using the current speaker's credentials. Runner 0.12.0 supports cached SOP checkouts.
- Users can choose a preferred sandbox kind in 设置 → AI 助手 → 对话工作区. The preference (`workspaceDriver` in `/api/assistant/preferences`) prioritizes that kind among compatible environments. A task can require another toolchain, and a fixed conversation environment takes precedence. The workbench groups sandboxes by kind, and the header displays the current workspace's sandbox type icon and ID beside the execution machine. Startup AutoMigrate and migration 041 both add the preference column.
- **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, copies ordinary variables from referenced environments, drops install scripts and `PATH` from native sandbox variables, and moves SOPs that used the old default to `generic-docker`, and drops the `dockerfiles` and `environments` tables. Docker images are reused.
- **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`. For an existing Compose database, `./start.sh pull` backs up the database and applies `migrations/041_native_sandbox_inline_assets.sql` with the platform stopped when the target image supports inline Dockerfiles and legacy asset tables still exist. For a manual Compose upgrade, use `./start.sh migrate-sandboxes`. Apply the SQL 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, copies ordinary variables from referenced environments, drops install scripts and `PATH` from native sandbox variables, and moves SOPs that used the old default to `generic-docker`, and drops the `dockerfiles` and `environments` tables. Docker images are reused.

### enterprise IM channels (Feishu and DingTalk chats, proactive notifications, data retention)

Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ ARG LOOPFORGE_RELEASE_VERSION=
ENV LOOPFORGE_RELEASE_VERSION=${LOOPFORGE_RELEASE_VERSION}
RUN --mount=type=bind,source=.,target=/ctx,ro \
sh /ctx/scripts/image-commit.sh /ctx /app/loopforge-commit
# The Compose upgrade checks the target image for support for migration 041.
LABEL io.loopforge.sandbox-catalog="inline"
EXPOSE 8080
ENTRYPOINT ["/app/bin/agentflow"]
2 changes: 1 addition & 1 deletion docs/api/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ curl -u "$AGENTFLOW_USER:$AGENTFLOW_PASS" -X POST \

## Sandbox Profile

docker 沙箱的 Dockerfile 存在沙箱里,随沙箱一起共享,没有单独的 Dockerfile 资产。native 沙箱只有环境变量,使用实际执行它的机器(用户的执行机器、云端 Runner 或平台本机)上已安装的工具,仓库从那台机器的仓库缓存共享克隆。旧的 `/api/dockerfiles`、`/api/environments`、环境安装脚本和 `local` 类型已移除;现有部署升级时,在启动新版本前手动执行 `migrations/041_native_sandbox_inline_assets.sql`。
docker 沙箱的 Dockerfile 存在沙箱里,随沙箱一起共享,没有单独的 Dockerfile 资产。native 沙箱只有环境变量,使用实际执行它的机器(用户的执行机器、云端 Runner 或平台本机)上已安装的工具,仓库从那台机器的仓库缓存共享克隆。旧的 `/api/dockerfiles`、`/api/environments`、环境安装脚本和 `local` 类型已移除;现有部署在启动新版前需要完成 [沙箱迁移 041](../deployment.md#migrating-existing-sandboxes-to-inline-assets)。

### `GET /api/sandboxes`

Expand Down
2 changes: 1 addition & 1 deletion docs/conversation-workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Docker 与 bwrap 下两种模式的 CLI 都在 `<会话根>/ws` 运行(工作

普通对话工作区从空目录开始,Agent 使用当前发言人的 Git 凭据克隆所需仓库。自动选择沙箱时会考虑执行机器的可用类型。平台和 Runner 0.12.0 通过实际启动短命令确认系统轻量隔离是否可用。会话明确指定的沙箱仍按指定配置打开。

local 沙箱类型已移除。`migrations/041_native_sandbox_inline_assets.sql` 把现有 local 沙箱改成 native,移除运行机器、基础目录和仓库路径的绑定,并复制引用环境中的普通变量。迁移删除环境安装脚本和 native 沙箱变量的 `PATH`,将依赖旧默认沙箱的 SOP 改到 `generic-docker`。已有项目若使用了这个保留 ID,迁移会为该沙箱分配新 ID,同步更新显式选用它的 SOP、会话选项和对应的工作区快照。现有部署在启动新版本前手动执行此迁移。尚未迁移的 local 行读出时按 native 处理;冻结了 local 沙箱的旧运行会提示改用 native 后重新发起。
local 沙箱类型已移除。`migrations/041_native_sandbox_inline_assets.sql` 把现有 local 沙箱改成 native,移除运行机器、基础目录和仓库路径的绑定,并复制引用环境中的普通变量。迁移删除环境安装脚本和 native 沙箱变量的 `PATH`,将依赖旧默认沙箱的 SOP 改到 `generic-docker`。已有项目若使用了这个保留 ID,迁移会为该沙箱分配新 ID,同步更新显式选用它的 SOP、会话选项和对应的工作区快照。现有部署在启动新版前需要完成此迁移,执行方式见 [部署与升级说明](deployment.md#migrating-existing-sandboxes-to-inline-assets)。尚未迁移的 local 行读出时按 native 处理;冻结了 local 沙箱的旧运行会提示改用 native 后重新发起。

`PUT /api/assistant/sessions/{id}/sandbox` 接受 `{ "sandboxProfileId": "id 或空字符串" }`,具备项目访问权限的会话参与者均可调用;生成期间和任务会话拒绝变更。已有工作区不受影响,新选择只用于之后新开的工作区。普通会话创建时也可以提交 `sandboxProfileId`,后续普通会话保存不能覆盖已保存的选择或伪造工作区绑定。

Expand Down
13 changes: 9 additions & 4 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Run it as the installation owner, including an ordinary Linux user. If that user

`compose.yaml` is the published-image stack and never builds: `./start.sh`, `scripts/install.sh` and a plain `docker compose --profile platform up` all pull the GHCR release pinned there (currently `ghcr.io/tencent/loopforge:0.4.2`). The pin matches the checkout's migrations and seeds, so check out a release tag when you install. Set `LOOPFORGE_IMAGE` (for example to an `@sha256:` digest) only to override it; a value saved in `.env` takes precedence over later pin changes.

To upgrade, update the checkout first, apply any required upgrade migrations, then refresh the containers. For the sandbox catalog upgrade, follow [Migrating existing sandboxes to inline assets](#migrating-existing-sandboxes-to-inline-assets).
To upgrade, update the checkout first, apply any manual migrations required by the release, then refresh the containers. The Compose upgrade applies sandbox migration 041 before starting the platform when needed. See [Migrating existing sandboxes to inline assets](#migrating-existing-sandboxes-to-inline-assets).

```bash
git fetch --tags && git checkout vX.Y.Z
Expand Down Expand Up @@ -220,19 +220,24 @@ For an external MySQL deployment, review that migration and check column existen
| Kind | Example | What an operator does |
| --- | --- | --- |
| Already applied by the installer and `./start.sh pull` | `001_run_obs_generated_columns.sql`, `migrations/seed/*.sql`, `033_generic_sop_mr_node.sql`, `038_generic_sop_host_credentials.sql` | Nothing; the script above covers it |
| Required upgrade migrations | `009_bot_interactions_utf8mb4.sql`, `036_git_http_credentials.sql`, `041_native_sandbox_inline_assets.sql` | Follow each migration's timing and prerequisites. [Migrating existing GitHub credentials](#migrating-existing-github-credentials) |
| Applied before startup by `./start.sh pull` for an existing Compose database | `041_native_sandbox_inline_assets.sql` | See [Migrating existing sandboxes to inline assets](#migrating-existing-sandboxes-to-inline-assets) |
| Required manual upgrade migrations | `009_bot_interactions_utf8mb4.sql`, `036_git_http_credentials.sql` | Follow each migration's timing and prerequisites. [Migrating existing GitHub credentials](#migrating-existing-github-credentials) |
| Optional backfills and rewrites of existing rows | `016_public_optional_repositories.sql`, `021_assistant_session_sources.sql` | Run them if the installation needs the converted rows |

### Migrating existing sandboxes to inline assets

Check out the upgraded release and stop the old platform and any other processes using the database. Back up the database while MySQL remains running. For Compose installations, apply the migration with these commands.
For a published Compose release, check out the target release and run `./start.sh pull`. If other API or worker processes share the Compose database, stop them first. After pulling the images, the command checks that the target image supports inline Dockerfiles and that the database still has a legacy asset table. When both conditions hold, it stops the platform, saves a database dump in `.local/loopforge-before-041.*/loopforge.sql`, and runs 041 before starting the new platform. An empty database or one whose legacy tables are already gone skips 041.

If the backup or migration fails, the platform stays stopped. Fix the error and rerun `./start.sh pull`. Keep the original backup if you plan to roll back to a release that uses the old sandbox format, and restore it before starting that release.

For a Compose source upgrade, stop the old platform and any other processes using the database, and back up the database while MySQL remains running. Run these commands before starting the new platform with `./start.sh dev`.

```bash
./start.sh stop platform
./start.sh migrate-sandboxes
```

Once the migration succeeds, start the upgraded platform with `./start.sh pull` for a published release or `./start.sh dev` for a source build. For external MySQL deployments, apply `migrations/041_native_sandbox_inline_assets.sql` directly before starting the upgraded platform.
For external MySQL deployments, stop the platform processes, back up the database and apply `migrations/041_native_sandbox_inline_assets.sql` directly before starting the upgraded platform.

The migration copies Dockerfiles into sandboxes, converts local sandboxes to native, drops the legacy Dockerfile and environment tables and includes the built-in Dockerfile fix from `031_generic_backend_openssh.sql`. Fresh installations seed the new sandbox format directly.

Expand Down
8 changes: 5 additions & 3 deletions migrations/041_native_sandbox_inline_assets.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Manual, idempotent MySQL migration: sandboxes carry their own Dockerfile,
-- Idempotent MySQL migration: sandboxes carry their own Dockerfile,
-- native replaces local, and environment install scripts are gone.
--
-- A docker sandbox now stores payload.dockerfile {content, files}; a native
Expand All @@ -25,8 +25,10 @@
--
-- Missing legacy tables are treated as empty so the migration can be repeated.
-- Docker images are keyed by the Dockerfile content and are reused.
-- Apply manually to existing databases before starting the upgraded platform.
-- For Compose, use ./start.sh migrate-sandboxes with the old platform stopped.
-- Apply to existing databases before starting the upgraded platform.
-- ./start.sh pull applies it when the target image and Compose database need it.
-- For a manual Compose upgrade, use ./start.sh migrate-sandboxes with the old
-- platform stopped and the database backed up.

SET NAMES utf8mb4;

Expand Down
Loading
Loading