From 19414cb4080d1a2add00fc25e30ef2647288d053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=BE=99=E5=AE=89?= <297888591+wanglongan587@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:59:47 +0800 Subject: [PATCH 1/4] feat(v2): prepare offline deployment and same-origin frontend hosting --- v2-server/README.md | 24 ++- v2-server/Taskfile.yml | 4 + v2-server/deployment.go | 31 ++++ v2-server/deployment_test.go | 80 +++++++++ v2-server/docs/deployment.en.md | 90 ++++++++++ v2-server/docs/deployment.md | 72 ++++++++ v2-server/internal/preparedassets/assets.go | 97 +++++++++++ .../internal/preparedassets/assets_test.go | 47 ++++++ v2-server/internal/server/frontend.go | 88 ++++++++++ v2-server/internal/server/frontend_test.go | 103 ++++++++++++ v2-server/internal/server/market_sources.go | 2 +- .../internal/server/market_sources_test.go | 67 ++++++++ v2-server/internal/server/server.go | 1 + v2-server/internal/store/market_sources.go | 7 +- .../internal/store/market_sources_test.go | 17 ++ v2-server/internal/store/plugins.go | 15 +- v2-server/internal/store/plugins_test.go | 31 ++++ v2-server/internal/store/store.go | 12 +- v2-server/main.go | 159 ++++++++++-------- v2-server/market-sources.openapi.json | 7 +- v2-server/scripts/build-offline.sh | 25 +++ v2-server/scripts/deepseek.sh | 1 + v2-server/scripts/demo.sh | 1 + v2-server/scripts/package-offline.py | 49 ++++++ v2-server/scripts/package_offline_test.py | 51 ++++++ v2-server/scripts/prepare-node.sh | 4 +- v2-server/scripts/start-offline.sh | 13 ++ 27 files changed, 1014 insertions(+), 84 deletions(-) create mode 100644 v2-server/deployment.go create mode 100644 v2-server/deployment_test.go create mode 100644 v2-server/docs/deployment.en.md create mode 100644 v2-server/docs/deployment.md create mode 100644 v2-server/internal/preparedassets/assets.go create mode 100644 v2-server/internal/preparedassets/assets_test.go create mode 100644 v2-server/internal/server/frontend.go create mode 100644 v2-server/internal/server/frontend_test.go create mode 100644 v2-server/internal/server/market_sources_test.go create mode 100644 v2-server/scripts/build-offline.sh create mode 100755 v2-server/scripts/package-offline.py create mode 100644 v2-server/scripts/package_offline_test.py create mode 100644 v2-server/scripts/start-offline.sh diff --git a/v2-server/README.md b/v2-server/README.md index a5708b33a..fe58318a8 100644 --- a/v2-server/README.md +++ b/v2-server/README.md @@ -16,22 +16,24 @@ Cloud v2 的**临时**单体后端:一个进程、一个 PostgreSQL 库,实 ```sh docker compose -p cloud up -d --wait # 在仓库根目录 -go run . # 监听 127.0.0.1:8090 +V2_LOGIN=email go run . # 开发模式,监听 127.0.0.1:8090 ``` 收到 SIGTERM 或中断信号时,进程会取消 HTTP 请求上下文,让保持打开的对话 SSE 关闭观察并等待其读取协程退出,再结束 HTTP、公共执行服务和数据库。关闭浏览器或单条 SSE 只停止对应观察者,不取消执行 worker;进程退出时的执行停止与完整终态保存仍由公共执行服务负责。 | 环境变量 | 默认值 | 说明 | |---|---|---| +| `V2_LOGIN` | 必填 | `email` 仅开发;`idaas` 为部署模式,当前构建不提供 IDaaS 登录并拒绝启动 | +| `V2_FRONTEND_DIR` | 未设置 | 前端构建目录;未设置保留 API-only | | `V2_ADDR` | `127.0.0.1:8090` | 监听地址 | | `V2_DATABASE_URL` | `postgres://ora:ora-local@127.0.0.1:55432/ora_v2?sslmode=disable` | PostgreSQL | | `V2_DATA_DIR` | `$HOME/.ora-v2` | 仓库 mirror、marketplace checkout、Node 与对话目录;同一目录只允许一个进程持有,使用短路径以满足 Unix socket 长度限制;用 release 构建的 Node 时,它和各级父目录都不能组可写或其他人可写(不能放在 `/tmp` 下),否则启动时报错退出 | | `V2_USERS_FILE` | `users.json` | 启动时预置的账号文件(相对进程工作目录):`users` 里的 `email`、可选的 `displayName`、`role`(`owner` / `member`);`retired` 里列出要从成员页移除的旧预置 `email`。`users` 幂等写入,已存在的账号只更新名字和角色;不在 `users` 里的账号默认保留,只有 `retired` 中的地址会在首次启动时软删除。文件缺失、没有 owner、邮箱重复或 `users` 与 `retired` 重叠时拒绝启动 | -| `V2_PLUGIN_MARKETPLACE_URL` | `https://github.com/ora-space/marketplace` | 插件市场 Git HTTPS 地址;禁止携带凭据、query 或 fragment。离线测试直接构造 Syncer 使用本地仓库 | +| `V2_PLUGIN_MARKETPLACE_URL` | `https://github.com/ora-space/marketplace` | 未设置使用开发默认,显式空字符串关闭官方源;插件市场 Git HTTPS 地址;禁止携带凭据、query 或 fragment。离线测试直接构造 Syncer 使用本地仓库 | | `V2_PLUGIN_MARKETPLACE_BRANCH` | `main` | 市场同步分支;启动时浅克隆并拉取,之后按间隔快进工作副本 | | `V2_PLUGIN_MARKETPLACE_INTERVAL` | `5m` | 市场刷新间隔;必须为正 duration。失败时保留上一版 PostgreSQL 快照 | | `V2_MARKET_SOCKS_PROXY` | 未设置 | 自定义来源启用代理时使用的部署级 SOCKS5 地址;Git 与 Skill 包下载都使用,客户端只把已校验的公网 IP 交给代理 | -| `V2_MARKET_CREDENTIAL_KEY` | 未设置 | 来源凭据和租户 MCP 设置的 AES-256-GCM 密钥(Base64 编码的 32 字节),保存 MCP 设置、S3 来源或 Git 认证时必须持久提供 | +| `V2_MARKET_CREDENTIAL_KEY` | 未设置 | 来源凭据、租户 MCP 设置与私有项目仓库令牌的 AES-256-GCM 密钥(Base64 编码的 32 字节);保存 MCP 设置、启用 S3 来源、自定义来源 Git 认证或私有项目仓库令牌时必须持久提供 | | `V2_NODE_ASSETS_DIR` | 未设置 | `task v2:node:prepare` 生成的固定 Node、reaper、Deno、OpenCode 和 Claude Code 资源;未设置时只启用纯模型路径 | | `V2_MODEL_BASE_URL` / `V2_MODEL_API_KEY` / `V2_MODEL_NAME` | 未设置 | 可选的一组 HTTPS OpenAI 兼容 provider;必须同时设置,OpenCode 与纯模型共用,清单只公开模型名称与版本 | | `V2_ANTHROPIC_MODEL_BASE_URL` / `V2_ANTHROPIC_MODEL_API_KEY` / `V2_ANTHROPIC_MODEL_NAME` | 未设置 | 可选的一组 HTTPS Anthropic 兼容 provider(Messages API,base URL 写到 `/v1`,如 `https://api.anthropic.com/v1`);必须同时提供地址、凭据和模型名,只供 Claude Code 使用。使用 Bearer 网关时以 `V2_ANTHROPIC_MODEL_AUTH_TOKEN` 代替 `V2_ANTHROPIC_MODEL_API_KEY`,二者不能同时配置;Claude Code 的 base URL 若以 `/compatible` 结尾,这里填 `/compatible/v1` | @@ -652,7 +654,7 @@ fixture 只替代模型,Git、Node、OpenCode / Claude Code 与 shell 工具 ```sh # 在仓库根目录准备资源,随后到 v2-server;资源和数据目录均使用 Linux 原生磁盘。 task v2:node:prepare -V2_NODE_ASSETS_DIR=/absolute/path/to/assets go run . -fixture-check +V2_LOGIN=email V2_NODE_ASSETS_DIR=/absolute/path/to/assets go run . -fixture-check # 公共 Service 的真实工具写入、End 和 PostgreSQL 重启读取 V2_NODE_ASSETS_DIR=/absolute/path/to/assets TEST_DATABASE_URL='postgres://ora:ora-local@127.0.0.1:55432/ora?sslmode=disable' go test -race -count=1 -run TestReal -v ./internal/executionruntime ``` @@ -661,7 +663,7 @@ V2_NODE_ASSETS_DIR=/absolute/path/to/assets TEST_DATABASE_URL='postgres://ora:or 首次安装要解压和校验,明显慢于之后的启动;安装结果留在 `V2_DATA_DIR` 的项目 Node 目录里, 之后重启服务再用只需约一秒。演示前先在每个演示项目里跑一轮 Claude Code,可避开这次等待。 -End 和重启不自动删除目录。停止服务后 `go run . -cleanup` 只删除确认停止后的登记 Node 与对话目录, +End 和重启不自动删除目录。停止服务后 `V2_LOGIN=email go run . -cleanup` 只删除确认停止后的登记 Node 与对话目录, 保留项目 mirror 和数据库历史;命令拒绝与持有同一数据目录的服务并行运行。 外部 provider 的显式验收入口与配置见执行服务包 README;默认 skip 不代表外部 provider 验收通过。 @@ -869,3 +871,15 @@ npm run e2e -- e2e/workflow-runs.spec.ts e2e/workflow-containers.spec.ts e2e/sch `form` 负责冻结证据并等待确认,`createTasks` 根据确认结果创建或关联任务;二者使用 `workflows.openapi.json` 中的 v2 契约。表单的 GET/PUT/POST `/api/v2/tenants/{tid}/workflow-runs/{rid}/form` 与 POST `…/form/retry` 属于正式 Cloud 尚未提供的候选接口。行为、权限、幂等、去重与恢复边界见 [动态表单说明](internal/workflowforms/README.md)。等待确认的轮次不占用下一晚的自动执行资格,但仍保留未完成状态和终态跟踪。DTS 只有前端演示回执,不代表外部工单已提交。 任务时间轴中的 `TaskRun.demoSeed` 明确区分未执行的预置历史样例。它依据 seed 专用会话身份与启动键的一致关系投影,既有样例也会标记,不需要数据迁移;实际运行即使使用 fixture 模型也为 false。团队概览排除这类样例的运行数和 Agent 产出,会话分析仍保留样例以供检查。 + +## 内网部署 + +首次部署构建和长期安装/升级步骤见 [部署说明](docs/deployment.md)([English](docs/deployment.en.md))。 +直接开发启动须显式设置 `V2_LOGIN=email`;demo/开发 task 已设置。部署选择 `V2_LOGIN=idaas`, +当前构建不提供 IDaaS 登录,在任何数据操作前明确拒绝启动,不得回落 email。`V2_FRONTEND_DIR` 指向前端构建目录,空值保留 API-only。 +`V2_PLUGIN_MARKETPLACE_URL` 未设置保留开发默认,显式空字符串关闭官方同步和目录,保留自定义源;`V2_MARKET_CREDENTIAL_KEY` 同步保护自定义市场 S3/Git 凭据、租户 MCP 设置与私有项目仓库令牌。 + +部署边界依据:[Cloud 单进程(A1)](https://github.com/ora-space/specs/blob/main/decisions/cloud/lifecycle/0-single-process-cloud-on-enterprise-intranet.md) 和[登录与会话(A6)](https://github.com/ora-space/specs/blob/main/decisions/cloud/login/0-idaas-or-email-login-with-shared-web-and-desktop-sessions.md)。 + +来源列表候选契约 `market-sources.openapi.json` 的 `officialEnabled` 返回部署是否启用官方来源, +不依赖同步结果或目录条目;`items` 仍只列空间自定义来源,不将官方来源作为可编辑条目。 diff --git a/v2-server/Taskfile.yml b/v2-server/Taskfile.yml index cd8ef5a2d..ea2d86e01 100644 --- a/v2-server/Taskfile.yml +++ b/v2-server/Taskfile.yml @@ -1,6 +1,9 @@ version: '3' # Included by the root Taskfile as `v2`; paths are relative to this directory. tasks: + offline:build: + desc: Build a relocatable offline Linux package on an online build host + cmds: [bash scripts/build-offline.sh] execution:test: desc: Verify public Service with real Node, tool output, PostgreSQL and restart history preconditions: @@ -35,6 +38,7 @@ tasks: server: desc: Run v2-server on :8090 against the compose PostgreSQL deps: [db] + env: {V2_LOGIN: email} cmds: [go run .] web: desc: Run the frontend-v2 dev server on :5173 (proxies /api and /auth to :8090) diff --git a/v2-server/deployment.go b/v2-server/deployment.go new file mode 100644 index 000000000..0692057e8 --- /dev/null +++ b/v2-server/deployment.go @@ -0,0 +1,31 @@ +//go:build linux + +package main + +import ( + "errors" + "os" +) + +// envDefault preserves an explicit empty value, which disables optional integrations. +func envDefault(key, fallback string) string { + if value, ok := os.LookupEnv(key); ok { + return value + } + return fallback +} + +// validateLogin fails before database or filesystem effects when the build does not provide IDaaS. +func validateLogin(login string, fixtures bool) error { + switch login { + case "email": + return nil + case "idaas": + if fixtures { + return errors.New("IDaaS deployment forbids cleanup and fixture flags") + } + return errors.New("this build does not provide IDaaS login; deployment startup is unavailable and must not fall back to email") + default: + return errors.New("V2_LOGIN must be explicitly set to email (development) or idaas (deployment)") + } +} diff --git a/v2-server/deployment_test.go b/v2-server/deployment_test.go new file mode 100644 index 000000000..f2bdaad9f --- /dev/null +++ b/v2-server/deployment_test.go @@ -0,0 +1,80 @@ +//go:build linux + +package main + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +func TestLoginPreflightBeforeEffects(t *testing.T) { + for _, login := range []string{"", "unknown", "idaas"} { + t.Run(login, func(t *testing.T) { + t.Setenv("V2_LOGIN", login) + root := filepath.Join(t.TempDir(), "must-not-exist") + t.Setenv("V2_DATA_DIR", root) + err := run("127.0.0.1:0", "invalid database URL", false, false, false) + if err == nil { + t.Fatal("startup accepted unsupported login") + } + if login == "idaas" && (!strings.Contains(err.Error(), "this build does not provide IDaaS login") || !strings.Contains(err.Error(), "must not fall back to email") || strings.Contains(err.Error(), "#")) { + t.Fatalf("integration prerequisite missing: %v", err) + } + if _, err := os.Stat(root); !os.IsNotExist(err) { + t.Fatal("startup touched filesystem before rejecting deployment") + } + }) + } + if err := validateLogin("email", false); err != nil { + t.Fatal(err) + } + if err := validateLogin("idaas", true); err == nil { + t.Fatal("deployment accepted fixtures") + } +} + +func TestOptionalIntegrationUnsetAndEmpty(t *testing.T) { + const key = "V2_PLUGIN_MARKETPLACE_URL" + old, wasSet := os.LookupEnv(key) + t.Cleanup(func() { + if wasSet { + os.Setenv(key, old) + } else { + os.Unsetenv(key) + } + }) + os.Unsetenv(key) + if got := envDefault(key, "development"); got != "development" { + t.Fatalf("unset=%q", got) + } + t.Setenv(key, "") + if got := envDefault(key, "development"); got != "" { + t.Fatalf("empty=%q", got) + } + t.Setenv(key, "https://internal.example/market") + if got := envDefault(key, "development"); got != "https://internal.example/market" { + t.Fatalf("custom=%q", got) + } +} + +func TestDeploymentPreflightPreservesExistingData(t *testing.T) { + root := t.TempDir() + file := filepath.Join(root, "existing-data") + if err := os.WriteFile(file, []byte("preserve existing data"), 0600); err != nil { + t.Fatal(err) + } + t.Setenv("V2_LOGIN", "idaas") + t.Setenv("V2_DATA_DIR", root) + t.Setenv("V2_USERS_FILE", "nonexistent-preset") + if err := run("127.0.0.1:0", "invalid database URL", false, false, false); err == nil { + t.Fatal("deployment unexpectedly started") + } + if data, err := os.ReadFile(file); err != nil || string(data) != "preserve existing data" { + t.Fatalf("existing data changed: %q %v", data, err) + } + if _, err := os.Stat(filepath.Join(root, "server.lock")); !os.IsNotExist(err) { + t.Fatal("preflight acquired data directory") + } +} diff --git a/v2-server/docs/deployment.en.md b/v2-server/docs/deployment.en.md new file mode 100644 index 000000000..520f015b8 --- /dev/null +++ b/v2-server/docs/deployment.en.md @@ -0,0 +1,90 @@ +# Single-machine offline deployment + +[中文](deployment.md) + +Basis: [Single-process Cloud (A1)](https://github.com/ora-space/specs/blob/main/decisions/cloud/lifecycle/0-single-process-cloud-on-enterprise-intranet.md) D2/D5/D6 and [Login and sessions (A6)](https://github.com/ora-space/specs/blob/main/decisions/cloud/login/0-idaas-or-email-login-with-shared-web-and-desktop-sessions.md). +This build does not provide IDaaS login. `V2_LOGIN=idaas` refuses startup before touching data; +it is not a deployable release and must not fall back to email. The current version does not +yet provide versioned migrations. Production deployment +requires a version supporting the required capabilities and a verified HTTPS entrypoint. + +## Build online + +Use Linux matching the target architecture. Install Go (go.mod), Node >=24, npm, Python 3, Git, +curl, Rust 1.95.0 and a trusted Deno 2.9.5 installation. The desktop repository must contain the +commit pinned in prepare-node.sh. + +```sh +DESKTOP_REPOSITORY=/build/desktop V2_NODE_ASSETS_DIR=/build/assets \ + V2_OFFLINE_OUTPUT=/build/cloud-linux.tar.gz task v2:offline:build +``` + +The builder runs prepare-node.sh first: it compiles Node/reaper at the pinned commit, +checks both Agent plugins against pinned SHA-256 digests, and checks Deno's version before recording +its local digest. Build concurrency is limited to two. Local executable and Deno digests prove +integrity, not publisher authenticity; trust the build machine and toolchain. The frontend uses +offline mode with `VITE_DEMO_MOCK=0`. Only the server, built web files, five runtime resources, +manifest, launcher and deployment guides are packaged. User configuration, databases, data volumes +and other files from the preparation directory are excluded. Manifest paths are relative; legacy +absolute development manifests remain supported. + +Transfer through a trusted channel, unpack into a new version directory and run +`sha256sum --check SHA256SUMS` there. Checksums detect corruption and do not replace trusted delivery +or release signing. Unpacking and startup download nothing. Runtime access to configured PostgreSQL, +IDaaS, model, internal Git and S3 services is still required. Install Git and system libraries on +the target host beforehand; operating system dependencies are not bundled. + +## Host and configuration + +Use a dedicated non-root account. Agents run as the Cloud account without isolation; the first +release is suitable only for mutually trusted members. Provision a dedicated PostgreSQL database +and identity without demo credentials. This version applies schema directly at startup and has +no versioned migrations; it cannot be used for production version upgrades that must preserve data. + +Keep configuration and secrets in protected process-manager configuration, outside the archive: + +- `V2_LOGIN=idaas`: the only deployment login. This build does not provide it and refuses startup. +- `V2_PUBLIC_URL`: public HTTPS address; configure `V2_IDAAS_BASE_URL`, `V2_IDAAS_CLIENT_ID` and + `V2_IDAAS_CLIENT_SECRET` as specified by A6. This build does not yet support IDaaS login. +- `V2_DATABASE_URL`: dedicated PostgreSQL connection with required TLS and least privilege. +- `V2_ADDR`: HTTP listener, reachable only through the HTTPS termination entrypoint. HTTPS is + mandatory; this build does not provide HTTPS termination configuration. +- `V2_DATA_DIR`: an absolute persistent directory such as `/srv/ora/data`. Neither it nor any parent + may be writable by group or others. Do not use `/tmp`. Prefer mode `0700` owned by the service account. +- `V2_MARKET_CREDENTIAL_KEY`: persist a stable 32-byte Base64-encoded key in the format required by pluginmarket. + Back it up securely; replacing or losing it makes existing marketplace AK/SK credentials unreadable. +- `V2_PLUGIN_MARKETPLACE_URL`: the launcher defaults to empty, disabling the official market. + Direct binary startup retains the development default when unset; explicit empty disables sync + and visibility of saved official catalog entries. Custom space markets support S3+AKSK and internal HTTPS Git authentication + (username plus token or password configured in space plugin settings, sealed with `V2_MARKET_CREDENTIAL_KEY`). +- `V2_PLUGIN_MARKETPLACE_BRANCH` and `V2_PLUGIN_MARKETPLACE_INTERVAL`: used only with the official + source enabled; defaults are main and 5m. +- `V2_MODEL_*` / `V2_ANTHROPIC_MODEL_*`: see the service README for model connections. + Changing model connections or credential bindings may prevent + existing conversations from continuing; notify users and start new conversations while retaining history. + +The launcher resolves `V2_FRONTEND_DIR` and `V2_NODE_ASSETS_DIR` relative to itself, checks archive +contents and executes the server. Deployment startup must not use cleanup or fixture flags. It +skips development presets, demo preparation and demo warming; this build blocks deployment startup +because it does not provide IDaaS login. + +Install enterprise CAs in the host system trust store using your distribution's enterprise process. +Git and Go HTTPS use system CAs. Never disable certificate verification. HTTPS termination belongs +before the Cloud HTTP listener. Verify secure cookies and callback URLs for deployment. Derive +public URLs only from configuration and do not trust forwarding headers. This guide does not +choose a proxy or certificate management solution. + +## Backup and upgrade + +Back up PostgreSQL, the complete `V2_DATA_DIR` volume and the stable encryption key. Stop the service +or use consistent snapshots, and test restoration. Agent changes exist only in local working trees +and are not pushed to Git; a database-only backup is insufficient. + +Stop this instance and confirm its Nodes exited. Back up, unpack a new version into a separate +program directory and verify checksums. This version has no versioned migrations; when migration +is required, use a target version that supports it and follow that version's migration instructions. Replace +programs and resources while retaining database, data directory, keys and host configuration. Do +not reset demos, seed again or overwrite new resources with the old package. Unfinished executions +become interrupted on restart and do not resume automatically. After migration, rollback requires +a verified backup recovery procedure, not merely an older binary. Static files use `no-cache` so +browsers revalidate after upgrades. diff --git a/v2-server/docs/deployment.md b/v2-server/docs/deployment.md new file mode 100644 index 000000000..8a7580507 --- /dev/null +++ b/v2-server/docs/deployment.md @@ -0,0 +1,72 @@ +# 单机离线部署 + +[English](deployment.en.md) + +依据:[Cloud 单进程(A1)](https://github.com/ora-space/specs/blob/main/decisions/cloud/lifecycle/0-single-process-cloud-on-enterprise-intranet.md) D2/D5/D6 和[登录与会话(A6)](https://github.com/ora-space/specs/blob/main/decisions/cloud/login/0-idaas-or-email-login-with-shared-web-and-desktop-sessions.md)。 +当前构建不提供 IDaaS 登录,`V2_LOGIN=idaas` 在访问数据前拒绝启动,不能作为可用部署上线, +不得回落到 email。当前版本尚未提供版本化迁移。正式部署须使用支持所需能力的版本, +并配置经过验证的 HTTPS 入口。 + +## 在外网构建 + +在与目标机同架构的 Linux 上,安装 Go(版本见 go.mod)、Node >=24、npm、Python 3、Git、curl、 +Rust 1.95.0 和已信任来源的 Deno 2.9.5。设置 `DESKTOP_REPOSITORY` 指向包含 prepare-node.sh +固定提交的 desktop 仓库。执行: + +```sh +DESKTOP_REPOSITORY=/build/desktop V2_NODE_ASSETS_DIR=/build/assets \ + V2_OFFLINE_OUTPUT=/build/cloud-linux.tar.gz task v2:offline:build +``` + +入口先调用 `prepare-node.sh`:按固定提交编译 Node/reaper,按固定 SHA-256 校验两个 Agent +插件,检查 Deno 版本并记录本机摘要。构建并发限制为 2。Deno 和本机编译摘要只证明完整性, +不是官方发布签名;构建机及其工具链必须可信。前端强制 `VITE_DEMO_MOCK=0`,使用 offline mode。 +包只包含服务端、web 构建、五项运行资源、清单、启动器和本文档,不复制用户配置、数据库或数据目录。 +准备目录中的其他内容(包括源码、用户文件)不进入包。`assets.json` 使用相对路径,运行时仍兼容旧的绝对路径开发清单。 + +将包通过受信任通道传入内网,解压到新的版本目录,在该目录执行 `sha256sum --check SHA256SUMS`。 +这份清单检测传输损坏,不代替可信传输或发布签名。解压及启动不下载资源;运行时仍需访问配置的 +PostgreSQL、IDaaS、模型和内部 Git/S3 服务。Git 和系统库须预先安装,离线包不包括操作系统依赖。 + +## 主机与配置 + +使用专用非 root 系统账号运行 Cloud。第一版 Agent 与 Cloud 同用户、不隔离,仅适用于互相信任的成员。 +准备 PostgreSQL 和专用数据库、数据库身份;不要使用演示数据库或演示凭据。当前版本在启动时 +应用 schema,没有版本化迁移,不能用于需要保留数据的正式版本升级。 + +在进程管理器的受保护配置中设置以下变量,不将密钥写入包或命令日志: + +- `V2_LOGIN=idaas`:唯一部署登录方式;当前构建不提供此能力,启动会明确拒绝。 +- `V2_PUBLIC_URL`:部署公开 HTTPS 地址;`V2_IDAAS_BASE_URL`、`V2_IDAAS_CLIENT_ID`、 + `V2_IDAAS_CLIENT_SECRET` 是 A6 规定的部署配置;当前构建尚不支持 IDaaS 登录。 +- `V2_DATABASE_URL`:专用 PostgreSQL 连接,按企业要求启用 TLS 和最小权限。 +- `V2_ADDR`:HTTP 监听地址。仅暴露给 HTTPS 终止入口;当前构建不提供 HTTPS 终止配置。 + 部署必须使用 HTTPS,不得将这里的 HTTP 监听直接当作正式用户入口。 +- `V2_DATA_DIR`:绝对、持久化目录,例如 `/srv/ora/data`;目录和所有父目录均不可被组或其他人写入, + 不能放 `/tmp`。由运行账号创建,建议 `0700`,不要通过宽化权限解决 Node 启动失败。 +- `V2_MARKET_CREDENTIAL_KEY`:按 pluginmarket 的密钥格式生成(32 字节 Base64);作为稳定密钥持久保存, + 与数据一起备份。重建、替换或丢失会使现有市场 AK/SK 无法解密。 +- `V2_PLUGIN_MARKETPLACE_URL`:启动器未配置时设为空,关闭官方市场。直接启动 binary 时未设置仍使用开发默认; + 显式空字符串关闭同步和旧官方目录可见性。自定义空间市场支持 S3+AKSK 及管理员在设置页配置的内部 HTTPS Git 认证(用户名与令牌/密码,经 `V2_MARKET_CREDENTIAL_KEY` 加密存库)。 +- `V2_PLUGIN_MARKETPLACE_BRANCH`、`V2_PLUGIN_MARKETPLACE_INTERVAL`:仅官方源启用时使用,默认 main、5m。 +- `V2_MODEL_*` / `V2_ANTHROPIC_MODEL_*`:模型连接,具体变量见服务 README。 + 改变连接、模型或凭据绑定可能让旧对话不能继续;在变更前通知用户,保留历史并新建对话。 + +`start.sh` 从自身位置确定 `V2_FRONTEND_DIR` 和 `V2_NODE_ASSETS_DIR`,校验包文件后执行服务。 +不能传入 `-fixture-check`、`-test-fixtures`、`-cleanup` 作为部署启动方式。程序不会加载开发用户 preset、 +准备 demo 项目或预热 demo Node;当前构建因不提供 IDaaS 登录而直接阻止部署启动。 + +企业 CA 必须安装到运行主机的系统信任库(按企业发行版流程更新信任库),Git 和 Go HTTPS 均使用 +系统 CA。不得关闭 TLS 校验。HTTPS 终止集成点是 Cloud HTTP 监听之前;部署需核对安全 Cookie 和回调地址, +公开地址只取配置,不信任转发头。本文不指定反向代理或证书管理方案。 + +## 备份和升级 + +备份 PostgreSQL、整个 `V2_DATA_DIR` 数据卷和稳定的加密密钥;采用停机或一致性快照确保数据库与数据卷一致, +验证能恢复。Agent 改动只在本机工作目录,不会自动推送到 Git,不能只备份数据库。 + +升级前停止本实例并确认 Node 已退出,备份后将新包解压到新的程序目录,校验摘要。当前版本没有版本化迁移;需要迁移时, +必须使用提供迁移支持的目标版本,并遵循该版本的迁移说明。 +替换程序和资源,保持数据目录、数据库、密钥及主机配置不变;不要删除数据、运行 demo reset、重新 seed 或复制旧包覆盖 +新版本文件。未完成的执行在重启后标记中断,不自动续跑。数据库迁移后的回退必须按已验证的备份恢复方案进行, +不能假设替换旧 binary 即可回退。静态 HTML 和资源使用 `no-cache`,让浏览器在升级后重新验证文件。 diff --git a/v2-server/internal/preparedassets/assets.go b/v2-server/internal/preparedassets/assets.go new file mode 100644 index 000000000..3df94361f --- /dev/null +++ b/v2-server/internal/preparedassets/assets.go @@ -0,0 +1,97 @@ +// Package preparedassets verifies the offline resource manifest without downloading anything. +package preparedassets + +import ( + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/wanglongan587/cloud/v2-server/internal/nodeservices" +) + +type asset struct{ Path, SHA256 string } +type manifest struct { + Version int `json:"version"` + SourceCommit string `json:"sourceCommit"` + Profile string `json:"profile"` + Node, Reaper, Deno, Plugin, Claude asset +} + +// Verify accepts relative manifest paths confined to root and legacy absolute development paths. +// Executables are locally built, so their digests attest bundle integrity, not publisher identity. +func Verify(directory string) error { + raw, err := os.ReadFile(filepath.Join(directory, "assets.json")) + if err != nil { + return err + } + var m manifest + if err = json.Unmarshal(raw, &m); err != nil { + return err + } + if m.Version != 1 || (m.Profile != "release" && m.Profile != "debug") { + return errors.New("unsupported prepared assets manifest") + } + opencode, err := nodeservices.HostOpenCodePackage() + if err != nil { + return err + } + claude, err := nodeservices.HostClaudePackage() + if err != nil { + return err + } + if m.Plugin.SHA256 != opencode.SHA256 || m.Claude.SHA256 != claude.SHA256 { + return errors.New("plugin digest does not match pinned release") + } + root, err := os.OpenRoot(directory) + if err != nil { + return err + } + defer root.Close() + for name, a := range map[string]asset{"bin/ora-node": m.Node, "bin/ora-reaper": m.Reaper, "bin/deno": m.Deno, "opencode-0.6.11.orax": m.Plugin, "claude-0.4.5.orax": m.Claude} { + if err := verifyAsset(root, directory, name, a); err != nil { + return err + } + } + return nil +} + +// Match the manifest to the fixed paths the runtime actually opens. Resolving a different file +// with the right digest must not validate an unchecked executable at the runtime path. +func verifyAsset(root *os.Root, directory, name string, a asset) error { + if filepath.IsAbs(a.Path) { + expected, err := filepath.Abs(filepath.Join(directory, name)) + if err != nil { + return err + } + if filepath.Clean(a.Path) != expected { + return errors.New("absolute asset path does not match runtime path") + } + } else if a.Path != name { + return errors.New("relative asset path does not match runtime path") + } + f, err := root.Open(name) + if err != nil { + return err + } + defer f.Close() + info, err := f.Stat() + if err != nil { + return err + } + if !info.Mode().IsRegular() { + return errors.New("asset must be regular") + } + hash := sha256.New() + if _, err := io.Copy(hash, f); err != nil { + return err + } + if hex.EncodeToString(hash.Sum(nil)) != a.SHA256 { + return fmt.Errorf("prepared asset checksum mismatch: %s", filepath.Base(name)) + } + return nil +} diff --git a/v2-server/internal/preparedassets/assets_test.go b/v2-server/internal/preparedassets/assets_test.go new file mode 100644 index 000000000..c8420700c --- /dev/null +++ b/v2-server/internal/preparedassets/assets_test.go @@ -0,0 +1,47 @@ +package preparedassets + +import ( + "crypto/sha256" + "encoding/hex" + "os" + "path/filepath" + "testing" +) + +func TestResourceRelocationAndLegacyAbsolutePath(t *testing.T) { + source := filepath.Join(t.TempDir(), "original") + if err := os.MkdirAll(filepath.Join(source, "bin"), 0700); err != nil { + t.Fatal(err) + } + data := []byte("unit fixture, not a release executable") + sum := sha256.Sum256(data) + a := asset{Path: "bin/ora-node", SHA256: hex.EncodeToString(sum[:])} + if err := os.WriteFile(filepath.Join(source, a.Path), data, 0700); err != nil { + t.Fatal(err) + } + moved := filepath.Join(t.TempDir(), "moved") + if err := os.Rename(source, moved); err != nil { + t.Fatal(err) + } + root, err := os.OpenRoot(moved) + if err != nil { + t.Fatal(err) + } + defer root.Close() + if err := verifyAsset(root, moved, "bin/ora-node", a); err != nil { + t.Fatalf("relative moved: %v", err) + } + a.Path = filepath.Join(moved, "bin/ora-node") + if err := verifyAsset(root, moved, "bin/ora-node", a); err != nil { + t.Fatalf("legacy absolute: %v", err) + } + a.Path = "../outside" + if err := verifyAsset(root, moved, "bin/ora-node", a); err == nil { + t.Fatal("escaping manifest path accepted") + } + a.Path = "bin/ora-node" + a.SHA256 = "bad" + if err := verifyAsset(root, moved, "bin/ora-node", a); err == nil { + t.Fatal("digest mismatch accepted") + } +} diff --git a/v2-server/internal/server/frontend.go b/v2-server/internal/server/frontend.go new file mode 100644 index 000000000..db34526f9 --- /dev/null +++ b/v2-server/internal/server/frontend.go @@ -0,0 +1,88 @@ +package server + +import ( + "errors" + "fmt" + "net/http" + "os" + "path" + "strings" +) + +// WithFrontend serves a build directory on the API origin. An empty directory preserves API-only +// operation. os.Root confines every open, including symlink resolution, to the configured tree. +func WithFrontend(api http.Handler, directory string) (http.Handler, error) { + if directory == "" { + return api, nil + } + root, err := os.OpenRoot(directory) + if err != nil { + return nil, fmt.Errorf("frontend directory: %w", err) + } + file, err := root.Open("index.html") + if err == nil { + var info os.FileInfo + info, err = file.Stat() + if err == nil && !info.Mode().IsRegular() { + err = errors.New("index.html must be regular") + } + file.Close() + } + root.Close() + if err != nil { + return nil, fmt.Errorf("frontend index: %w", err) + } + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + first := strings.Split(strings.TrimPrefix(r.URL.Path, "/"), "/")[0] + switch first { + case "api", "auth", "internal", "_internal", "healthz", "git", "node", "model", "packages", "runtime", "repo.git": + api.ServeHTTP(w, r) + return + } + if strings.HasPrefix(first, "_") { + api.ServeHTTP(w, r) + return + } + if r.Method != http.MethodGet && r.Method != http.MethodHead { + w.Header().Set("Allow", "GET, HEAD") + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + name := strings.TrimPrefix(r.URL.Path, "/") + if strings.Contains(name, "\\") || path.Clean("/"+name) != "/"+name && name != "" { + http.NotFound(w, r) + return + } + root, err := os.OpenRoot(directory) + if err != nil { + http.NotFound(w, r) + return + } + defer root.Close() + if name == "" { + name = "index.html" + } + file, err := root.Open(name) + // Only extensionless browser navigations use the SPA. Failed containment checks and missing + // assets never become a successful HTML response. + if errors.Is(err, os.ErrNotExist) && path.Ext(name) == "" && strings.Contains(r.Header.Get("Accept"), "text/html") { + name = "index.html" + file, err = root.Open(name) + } + if err != nil { + http.NotFound(w, r) + return + } + defer file.Close() + info, err := file.Stat() + if err != nil || !info.Mode().IsRegular() { + http.NotFound(w, r) + return + } + // Revalidate all files, including HTML, across upgrades; avoid stale entrypoints and cached + // responses accidentally surviving a package replacement. + w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("X-Content-Type-Options", "nosniff") + http.ServeContent(w, r, name, info.ModTime(), file) + }), nil +} diff --git a/v2-server/internal/server/frontend_test.go b/v2-server/internal/server/frontend_test.go new file mode 100644 index 000000000..67a5f8e5f --- /dev/null +++ b/v2-server/internal/server/frontend_test.go @@ -0,0 +1,103 @@ +package server + +import ( + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "strings" + "testing" +) + +func TestFrontendBoundary(t *testing.T) { + dir := t.TempDir() + for name, body := range map[string]string{"index.html": "app", "app.js": "javascript"} { + if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0600); err != nil { + t.Fatal(err) + } + } + outside := filepath.Join(t.TempDir(), "secret") + if err := os.WriteFile(outside, []byte("secret"), 0600); err != nil { + t.Fatal(err) + } + if err := os.Symlink(outside, filepath.Join(dir, "leak")); err != nil { + t.Fatal(err) + } + if err := os.Mkdir(filepath.Join(dir, "directory"), 0700); err != nil { + t.Fatal(err) + } + api := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(418) }) + h, err := WithFrontend(api, dir) + if err != nil { + t.Fatal(err) + } + for _, tc := range []struct { + method, path, accept string + status int + body string + }{ + {"GET", "/", "", 200, "app"}, {"GET", "/settings/plugins", "text/html", 200, "app"}, + {"HEAD", "/settings/plugins", "text/html", 200, ""}, {"GET", "/app.js", "", 200, "javascript"}, + {"GET", "/missing.js", "text/html", 404, ""}, {"GET", "/missing", "application/json", 404, ""}, + {"GET", "/directory", "text/html", 404, ""}, {"GET", "/leak", "text/html", 404, ""}, + {"GET", "/../secret", "text/html", 404, ""}, {"GET", "/api/missing", "text/html", 418, ""}, + {"GET", "/auth/missing", "text/html", 418, ""}, {"GET", "/internal/missing", "text/html", 418, ""}, + {"POST", "/settings", "text/html", 405, ""}, + } { + t.Run(tc.method+tc.path, func(t *testing.T) { + r := httptest.NewRequest(tc.method, tc.path, nil) + r.Header.Set("Accept", tc.accept) + w := httptest.NewRecorder() + h.ServeHTTP(w, r) + if w.Code != tc.status { + t.Fatalf("status=%d body=%s", w.Code, w.Body.String()) + } + if tc.status == 200 && w.Body.String() != tc.body { + t.Fatalf("body=%q", w.Body.String()) + } + if strings.Contains(w.Body.String(), "secret") { + t.Fatal("secret leaked") + } + if tc.status == 200 && w.Header().Get("Cache-Control") != "no-cache" { + t.Fatal("cache policy missing") + } + }) + } + if _, err := WithFrontend(api, filepath.Join(dir, "missing")); err == nil { + t.Fatal("missing directory accepted") + } + if err := os.Remove(filepath.Join(dir, "index.html")); err != nil { + t.Fatal(err) + } + if _, err := WithFrontend(api, dir); err == nil { + t.Fatal("missing index accepted") + } +} + +func TestFrontendPreservesRealAPIRouting(t *testing.T) { + dir := t.TempDir() + if err := os.WriteFile(filepath.Join(dir, "index.html"), []byte("SPA"), 0600); err != nil { + t.Fatal(err) + } + h, err := WithFrontend(New(nil, Options{}), dir) + if err != nil { + t.Fatal(err) + } + for _, tc := range []struct { + method, path string + status int + }{ + {"GET", "/api/not-real", 404}, {"GET", "/auth/not-real", 404}, {"GET", "/internal/not-real", 404}, + {"GET", "/_private/not-real", 404}, {"GET", "/git/not-real", 404}, {"GET", "/runtime/not-real", 404}, {"GET", "/repo.git/not-real", 404}, {"GET", "/auth/login", 405}, + } { + t.Run(tc.path, func(t *testing.T) { + r := httptest.NewRequest(tc.method, tc.path, nil) + r.Header.Set("Accept", "text/html") + w := httptest.NewRecorder() + h.ServeHTTP(w, r) + if w.Code != tc.status || w.Body.String() == "SPA" { + t.Fatalf("status=%d body=%s", w.Code, w.Body.String()) + } + }) + } +} diff --git a/v2-server/internal/server/market_sources.go b/v2-server/internal/server/market_sources.go index 65a158b53..1b735a683 100644 --- a/v2-server/internal/server/market_sources.go +++ b/v2-server/internal/server/market_sources.go @@ -19,7 +19,7 @@ func (h *handler) marketSources(w http.ResponseWriter, r *http.Request, a access pluginError(w, "list markets", e) return } - writeJSON(w, 200, map[string]any{"items": items}) + writeJSON(w, 200, map[string]any{"items": items, "officialEnabled": h.store.OfficialMarketEnabled()}) return } var in store.MarketSource diff --git a/v2-server/internal/server/market_sources_test.go b/v2-server/internal/server/market_sources_test.go new file mode 100644 index 000000000..49ab00ebb --- /dev/null +++ b/v2-server/internal/server/market_sources_test.go @@ -0,0 +1,67 @@ +package server + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "path/filepath" + "testing" + + "github.com/getkin/kin-openapi/openapi3" + "github.com/wanglongan587/cloud/v2-server/internal/store" +) + +// Only these methods are exercised by the sources read route; unimplemented calls fail visibly. +type marketCapabilityStore struct { + Store + enabled bool +} + +func (s marketCapabilityStore) OfficialMarketEnabled() bool { return s.enabled } +func (s marketCapabilityStore) SessionUser(context.Context, string) (store.User, error) { + return store.User{ID: "user", Status: "active"}, nil +} +func (s marketCapabilityStore) TenantAccess(_ context.Context, tenant, user string) (store.Access, error) { + return store.Access{TenantID: tenant, UserID: user, Role: store.RoleMember}, nil +} +func (s marketCapabilityStore) MarketSources(context.Context, string, string) ([]store.MarketSource, error) { + return []store.MarketSource{}, nil +} + +func TestMarketSourcesReportsOfficialCapabilityWithoutCatalog(t *testing.T) { + doc, err := openapi3.NewLoader().LoadFromFile(filepath.Join("..", "..", "market-sources.openapi.json")) + if err != nil { + t.Fatal(err) + } + if err := doc.Validate(context.Background()); err != nil { + t.Fatal(err) + } + schema := doc.Paths.Find("/api/v1/tenants/{tid}/spaces/{sid}/plugins/sources").Get.Responses.Status(200).Value.Content["application/json"].Schema.Value + for _, enabled := range []bool{true, false} { + name := "disabled" + if enabled { + name = "enabled" + } + t.Run(name, func(t *testing.T) { + h := New(marketCapabilityStore{enabled: enabled}, Options{}) + req := httptest.NewRequest(http.MethodGet, "/api/v1/tenants/00000000-0000-4000-8000-0000000000aa/spaces/00000000-0000-4000-8000-0000000000bb/plugins/sources", nil) + req.AddCookie(&http.Cookie{Name: SessionCookie, Value: "session"}) + response := httptest.NewRecorder() + h.ServeHTTP(response, req) + if response.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", response.Code, response.Body.String()) + } + var body map[string]any + if err := json.Unmarshal(response.Body.Bytes(), &body); err != nil { + t.Fatal(err) + } + if err := schema.VisitJSON(body); err != nil { + t.Fatalf("candidate contract: %v", err) + } + if body["officialEnabled"] != enabled || len(body["items"].([]any)) != 0 { + t.Fatalf("capability response=%v", body) + } + }) + } +} diff --git a/v2-server/internal/server/server.go b/v2-server/internal/server/server.go index 680ca46c8..c4f02c3aa 100644 --- a/v2-server/internal/server/server.go +++ b/v2-server/internal/server/server.go @@ -31,6 +31,7 @@ const SessionCookie = "ora_session" type Store interface { // TenantAccess is the single tenant authorization decision (see router). TenantAccess(ctx context.Context, tenant, user string) (store.Access, error) + OfficialMarketEnabled() bool SkillProgress(context.Context, string, string, string, string) ([]store.SkillProgress, error) MarketSources(context.Context, string, string) ([]store.MarketSource, error) ChangeMarket(context.Context, string, string, string, string, store.MarketSource) error diff --git a/v2-server/internal/store/market_sources.go b/v2-server/internal/store/market_sources.go index 166edd914..73a4bb6ba 100644 --- a/v2-server/internal/store/market_sources.go +++ b/v2-server/internal/store/market_sources.go @@ -44,7 +44,9 @@ func (s *Store) MarketSources(ctx context.Context, tenant, space string) ([]Mark if e := rows.Scan(&m.Namespace, &m.URL, &m.Branch, &m.Enabled, &m.SyncedAt, &m.Failure, &m.Retrieval, &m.GitConfigured); e != nil { return nil, e } - out = append(out, m) + if m.Namespace != "official" || !s.officialDisabled { + out = append(out, m) + } } return out, rows.Err() } @@ -53,6 +55,9 @@ func (s *Store) ChangeMarket(ctx context.Context, tenant, space, id, action stri return e } if id == "official" { + if s.officialDisabled { + return ErrNotFound + } if action == "sync" { return nil } diff --git a/v2-server/internal/store/market_sources_test.go b/v2-server/internal/store/market_sources_test.go index c8c49a226..b7193a908 100644 --- a/v2-server/internal/store/market_sources_test.go +++ b/v2-server/internal/store/market_sources_test.go @@ -14,6 +14,8 @@ import ( func TestCustomMarketKeepsSelectionsAndIsolatesSpaces(t *testing.T) { f := newSquadFixture(t) + // Disabling the official source must leave custom Git snapshots and S3 credentials usable. + f.store.DisableOfficialMarket(true) owner := f.login(t, "owner", "owner") spaces, e := f.store.TenantSpaces(f.ctx, storetest.Access(t, f.store, f.tenant, owner)) if e != nil { @@ -332,3 +334,18 @@ func TestMarketSourceURLChangeNeedsNewGitCredentials(t *testing.T) { t.Fatalf("moving with new credentials: %+v", got) } } + +func TestOfficialMarketCapabilityUsesConfiguration(t *testing.T) { + s := &store.Store{} + if !s.OfficialMarketEnabled() { + t.Fatal("development default must enable official source") + } + s.DisableOfficialMarket(true) + if s.OfficialMarketEnabled() { + t.Fatal("disabled official source reported enabled") + } + s.DisableOfficialMarket(false) + if !s.OfficialMarketEnabled() { + t.Fatal("re-enabled official source reported disabled") + } +} diff --git a/v2-server/internal/store/plugins.go b/v2-server/internal/store/plugins.go index dcbc88191..d593da600 100644 --- a/v2-server/internal/store/plugins.go +++ b/v2-server/internal/store/plugins.go @@ -148,13 +148,13 @@ func (s *Store) PluginCatalog(ctx context.Context, tenant, space string) ([]Plug rows, e := s.pool.Query(ctx, ` SELECT data, synced_at FROM v2_plugin_catalog - WHERE (data->>'marketplaceVisible')::boolean + WHERE (data->>'marketplaceVisible')::boolean AND (NOT $2 OR source_namespace <> 'official') UNION ALL SELECT item, synced_at FROM v2_market_sources CROSS JOIN LATERAL jsonb_array_elements(snapshot) item - WHERE space_id = $1 AND enabled + WHERE space_id = $1 AND enabled AND (NOT $2 OR namespace <> 'official') AND COALESCE((item->>'marketplaceVisible')::boolean, false) - ORDER BY 2 DESC`, space) + ORDER BY 2 DESC`, space, s.officialDisabled) if e != nil { return nil, time.Time{}, fmt.Errorf("list plugin catalog: %w", e) } @@ -210,7 +210,7 @@ func (s *Store) pluginPackageSource(ctx context.Context, tenant, space, id strin if !ok { return PluginPackageSource{}, ErrInvalidPluginID } - kind, _, raw, e := pluginCatalogRow(ctx, s.pool, space, namespace, identifier) + kind, _, raw, e := pluginCatalogRow(ctx, s.pool, space, namespace, identifier, s.officialDisabled) if e != nil { return PluginPackageSource{}, e } @@ -328,7 +328,7 @@ func (s *Store) installSpacePlugin( if _, e := tx.Exec(ctx, `select pg_advisory_xact_lock(hashtextextended($1,1))`, space+"/"+in.Identifier); e != nil { return e } - kind, version, raw, e := pluginCatalogRow(ctx, tx, space, namespace, identifier) + kind, version, raw, e := pluginCatalogRow(ctx, tx, space, namespace, identifier, s.officialDisabled) if e != nil { return e } @@ -439,7 +439,10 @@ func (s *Store) installSpacePlugin( return out, e } -func pluginCatalogRow(ctx context.Context, q dbTX, space, namespace, identifier string) (kind, version string, raw []byte, e error) { +func pluginCatalogRow(ctx context.Context, q dbTX, space, namespace, identifier string, officialDisabled bool) (kind, version string, raw []byte, e error) { + if officialDisabled && namespace == "official" { + return "", "", nil, ErrPluginNotFound + } e = q.QueryRow(ctx, ` SELECT kind, version, data FROM v2_plugin_catalog WHERE source_namespace = $1 AND identifier = $2 diff --git a/v2-server/internal/store/plugins_test.go b/v2-server/internal/store/plugins_test.go index 882a8856b..8ed3e9ed5 100644 --- a/v2-server/internal/store/plugins_test.go +++ b/v2-server/internal/store/plugins_test.go @@ -410,3 +410,34 @@ func TestHookInstallIsRejected(t *testing.T) { } } } + +func TestDisabledOfficialCatalogRetainsSnapshotWithoutOfferingInstall(t *testing.T) { + f := newSquadFixture(t) + owner := f.login(t, "owner", "owner") + spaces, e := f.store.TenantSpaces(f.ctx, storetest.Access(t, f.store, f.tenant, owner)) + if e != nil || len(spaces) != 1 { + t.Fatalf("spaces=%v %v", spaces, e) + } + space := spaces[0].ID + entry := pluginmarket.Entry{Namespace: "official", Identifier: "saved.skill", Kind: "skill", Version: "1.0.0", MarketplaceVisible: true} + if e := f.store.ReplacePluginCatalog(f.ctx, []pluginmarket.Entry{entry}, time.Now()); e != nil { + t.Fatal(e) + } + f.store.DisableOfficialMarket(true) + catalog, stamp, e := f.store.PluginCatalog(f.ctx, f.tenant, space) + if e != nil || len(catalog) != 0 || !stamp.IsZero() { + t.Fatalf("disabled catalog=%v %v %v", catalog, stamp, e) + } + if e := f.store.ChangeMarket(f.ctx, f.tenant, space, "official", "sync", store.MarketSource{}); !errors.Is(e, store.ErrNotFound) { + t.Fatalf("sync=%v", e) + } + _, e = f.store.PluginPackageSource(f.ctx, f.tenant, space, "official/saved.skill") + if !errors.Is(e, store.ErrPluginNotFound) { + t.Fatalf("package=%v", e) + } + f.store.DisableOfficialMarket(false) + catalog, _, e = f.store.PluginCatalog(f.ctx, f.tenant, space) + if e != nil || len(catalog) != 1 { + t.Fatalf("retained snapshot=%v %v", catalog, e) + } +} diff --git a/v2-server/internal/store/store.go b/v2-server/internal/store/store.go index 0c986d221..61184662d 100644 --- a/v2-server/internal/store/store.go +++ b/v2-server/internal/store/store.go @@ -20,7 +20,17 @@ var schema string var ErrNotFound = errors.New("not found") // Store is the v2-server database. -type Store struct{ pool *pgxpool.Pool } +type Store struct { + pool *pgxpool.Pool + officialDisabled bool +} + +// DisableOfficialMarket configures catalog visibility before the store is shared with workers. +// It retains durable snapshots for a later re-enable, while preventing new installs from them. +func (s *Store) DisableOfficialMarket(disabled bool) { s.officialDisabled = disabled } + +// OfficialMarketEnabled reports deployment configuration independently of saved catalog entries. +func (s *Store) OfficialMarketEnabled() bool { return !s.officialDisabled } // Open connects to url, creating its database when missing, and applies the schema. func Open(ctx context.Context, url string) (*Store, error) { diff --git a/v2-server/main.go b/v2-server/main.go index 7e089852a..645af0cfa 100644 --- a/v2-server/main.go +++ b/v2-server/main.go @@ -26,6 +26,7 @@ import ( "github.com/wanglongan587/cloud/v2-server/internal/executionruntime" "github.com/wanglongan587/cloud/v2-server/internal/nodeservices" "github.com/wanglongan587/cloud/v2-server/internal/pluginmarket" + "github.com/wanglongan587/cloud/v2-server/internal/preparedassets" "github.com/wanglongan587/cloud/v2-server/internal/projectrepos" "github.com/wanglongan587/cloud/v2-server/internal/requestmetrics" "github.com/wanglongan587/cloud/v2-server/internal/scheduler" @@ -56,6 +57,10 @@ func main() { } func run(addr, dbURL string, cleanup, fixture, testFixtures bool) (resultErr error) { + login := os.Getenv("V2_LOGIN") + if e := validateLogin(login, fixture || testFixtures || cleanup); e != nil { + return e + } ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer stop() base, e := dataDirectory() @@ -75,33 +80,40 @@ func run(addr, dbURL string, cleanup, fixture, testFixtures bool) (resultErr err if e != nil { return e } - preset, e := store.LoadPreset(envOr("V2_USERS_FILE", "users.json")) - if e != nil { - db.Close() - return e - } - if e := db.SeedUsers(ctx, preset); e != nil { - db.Close() - return e - } - if e := db.MigrateStarterSkillNames(ctx); e != nil { - db.Close() - return e - } - if e := db.RetireLegacyDemoUser(ctx); e != nil { - db.Close() - return e - } - if e := db.RetireUsers(ctx, preset.Retired); e != nil { - db.Close() - return e + db.DisableOfficialMarket(envDefault("V2_PLUGIN_MARKETPLACE_URL", "https://github.com/ora-space/marketplace") == "") + var preset store.Preset + if login == "email" { + preset, e = store.LoadPreset(envOr("V2_USERS_FILE", "users.json")) + if e != nil { + db.Close() + return e + } + if e := db.SeedUsers(ctx, preset); e != nil { + db.Close() + return e + } + if e := db.MigrateStarterSkillNames(ctx); e != nil { + db.Close() + return e + } + if e := db.RetireLegacyDemoUser(ctx); e != nil { + db.Close() + return e + } + if e := db.RetireUsers(ctx, preset.Retired); e != nil { + db.Close() + return e + } } if e := db.EndDeletedSquadMembers(ctx); e != nil { db.Close() return e } // The demo project is owned by the first preset owner; it seeds shared content, not a login. - bootstrap := preset.Users[0].Email + bootstrap := "" + if len(preset.Users) > 0 { + bootstrap = preset.Users[0].Email + } for _, u := range preset.Users { if u.Role == store.RoleOwner { bootstrap = u.Email @@ -130,6 +142,9 @@ func run(addr, dbURL string, cleanup, fixture, testFixtures bool) (resultErr err } var driver *agentruntime.Driver if assets := os.Getenv("V2_NODE_ASSETS_DIR"); assets != "" && len(models) > 0 { + if e := preparedassets.Verify(assets); e != nil { + return e + } if e := checkReleaseNodeDataDirectory(assets, base); e != nil { return e } @@ -193,54 +208,60 @@ func run(addr, dbURL string, cleanup, fixture, testFixtures bool) (resultErr err if e := db.InterruptEndedChatSessions(ctx); e != nil { return e } - scope, demo, e := prepareDemo(ctx, db, projects, bootstrap) - if e != nil { - return e - } - if fixture { - if driver == nil { - return errors.New("fixture-check requires V2_NODE_ASSETS_DIR; run task v2:node:prepare first") + var scope execution.Scope + var demo store.Project + if login == "email" { + scope, demo, e = prepareDemo(ctx, db, projects, bootstrap) + if e != nil { + return e + } + if fixture { + if driver == nil { + return errors.New("fixture-check requires V2_NODE_ASSETS_DIR; run task v2:node:prepare first") + } + return checkFixture(ctx, runtime, scope, demo.ID, filepath.Join(base, "nodes")) + } + if driver != nil { + go driver.WarmDemo(ctx, demo.ID, agentruntime.Project{MirrorPath: demo.MirrorPath, Commit: demo.Commit, SnapshotRef: demo.SnapshotRef}) } - return checkFixture(ctx, runtime, scope, demo.ID, filepath.Join(base, "nodes")) - } - if driver != nil { - go driver.WarmDemo(ctx, demo.ID, agentruntime.Project{MirrorPath: demo.MirrorPath, Commit: demo.Commit, SnapshotRef: demo.SnapshotRef}) - } - marketURL, e := pluginmarket.NormalizeSourceURL(envOr( - "V2_PLUGIN_MARKETPLACE_URL", - "https://github.com/ora-space/marketplace", - )) - if e != nil { - return e - } - marketBranch := envOr("V2_PLUGIN_MARKETPLACE_BRANCH", "main") - if !pluginmarket.ValidBranch(marketBranch) { - return fmt.Errorf("V2_PLUGIN_MARKETPLACE_BRANCH is not a supported Git branch") - } - marketInterval, e := time.ParseDuration(envOr("V2_PLUGIN_MARKETPLACE_INTERVAL", "5m")) - if e != nil || marketInterval <= 0 { - return fmt.Errorf("V2_PLUGIN_MARKETPLACE_INTERVAL must be a positive duration") - } - market := &pluginmarket.Syncer{ - Source: pluginmarket.Source{ - Namespace: "official", URL: marketURL, Branch: marketBranch, - }, - WorkDir: filepath.Join(base, "marketplace"), } - marketCtx, cancelMarket := context.WithCancel(ctx) - marketDone := make(chan struct{}) - go func() { - defer close(marketDone) - if e := market.Sync(marketCtx, db, time.Now()); e != nil { - slog.Warn("initial plugin marketplace sync failed; retaining previous snapshot", "error", e) + marketValue := envDefault("V2_PLUGIN_MARKETPLACE_URL", "https://github.com/ora-space/marketplace") + var refreshOfficial func(context.Context) error + if marketValue != "" { + marketURL, e := pluginmarket.NormalizeSourceURL(marketValue) + if e != nil { + return e } - market.Loop(marketCtx, marketInterval, db) - }() - defer func() { - cancelMarket() - <-marketDone - }() + marketBranch := envOr("V2_PLUGIN_MARKETPLACE_BRANCH", "main") + if !pluginmarket.ValidBranch(marketBranch) { + return fmt.Errorf("V2_PLUGIN_MARKETPLACE_BRANCH is not a supported Git branch") + } + marketInterval, e := time.ParseDuration(envOr("V2_PLUGIN_MARKETPLACE_INTERVAL", "5m")) + if e != nil || marketInterval <= 0 { + return fmt.Errorf("V2_PLUGIN_MARKETPLACE_INTERVAL must be a positive duration") + } + market := &pluginmarket.Syncer{ + Source: pluginmarket.Source{ + Namespace: "official", URL: marketURL, Branch: marketBranch, + }, + WorkDir: filepath.Join(base, "marketplace"), + } + marketCtx, cancelMarket := context.WithCancel(ctx) + marketDone := make(chan struct{}) + go func() { + defer close(marketDone) + if e := market.Sync(marketCtx, db, time.Now()); e != nil { + slog.Warn("initial plugin marketplace sync failed; retaining previous snapshot", "error", e) + } + market.Loop(marketCtx, marketInterval, db) + }() + defer func() { + cancelMarket() + <-marketDone + }() + refreshOfficial = func(ctx context.Context) error { return market.Refresh(ctx, db, time.Now()) } + } skillCtx, cancelSkills := context.WithCancel(ctx) skillDone := make(chan struct{}) go func() { defer close(skillDone); runSkillReconciler(skillCtx, db, driver) }() @@ -270,7 +291,7 @@ func run(addr, dbURL string, cleanup, fixture, testFixtures bool) (resultErr err return e } options := withWorkflowDomain(server.Options{ - RefreshOfficial: func(ctx context.Context) error { return market.Refresh(ctx, db, time.Now()) }, + RefreshOfficial: refreshOfficial, SessionTTL: 7 * 24 * time.Hour, Projects: projects, Execution: runtime, @@ -300,7 +321,11 @@ func run(addr, dbURL string, cleanup, fixture, testFixtures bool) (resultErr err }() <-schedules.Ready() options.Schedules = schedules - srv := newHTTPServer(ctx, addr, server.New(db, options)) + handler, e := server.WithFrontend(server.New(db, options), os.Getenv("V2_FRONTEND_DIR")) + if e != nil { + return e + } + srv := newHTTPServer(ctx, addr, handler) errs := make(chan error, 1) go func() { errs <- srv.ListenAndServe() }() slog.Info("v2-server listening", "addr", addr) diff --git a/v2-server/market-sources.openapi.json b/v2-server/market-sources.openapi.json index e0fd7eb99..fb68342ab 100644 --- a/v2-server/market-sources.openapi.json +++ b/v2-server/market-sources.openapi.json @@ -39,10 +39,15 @@ "items": { "$ref": "#/components/schemas/MarketSource" } + }, + "officialEnabled": { + "type": "boolean", + "description": "Whether the deployment enables the shared official source, independent of catalog contents. Official sources are not included in items." } }, "required": [ - "items" + "items", + "officialEnabled" ] } } diff --git a/v2-server/scripts/build-offline.sh b/v2-server/scripts/build-offline.sh new file mode 100644 index 000000000..0d4c7fc57 --- /dev/null +++ b/v2-server/scripts/build-offline.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail +# Build on the target Linux architecture, with network access. No installation step downloads. +root=$(cd "$(dirname "$0")/../.." && pwd -P) +: "${V2_OFFLINE_OUTPUT:?Set V2_OFFLINE_OUTPUT to a new archive path}" +[[ ! -e $V2_OFFLINE_OUTPUT ]] || { echo 'Output already exists.' >&2; exit 1; } +[[ $(node -p 'Number(process.versions.node.split(".")[0])') -ge 24 ]] || { echo 'Node >=24 required.' >&2; exit 1; } +export GOMAXPROCS=2 CARGO_BUILD_JOBS=2 V2_NODE_PROFILE=release +bash "$root/v2-server/scripts/prepare-node.sh" +assets=${V2_NODE_ASSETS_DIR:-$HOME/.cache/ora-v2-node} +stage=$(mktemp -d) +trap 'rm -rf -- "$stage"' EXIT +mkdir -p "$stage/cloud/bin" "$stage/cloud/assets" "$stage/cloud/web" "$stage/cloud/docs" +(cd "$root/v2-server" && go build -p 2 -trimpath -o "$stage/cloud/bin/cloud" .) +# Use a separate mode and explicitly override the mock flag from every Vite env file. +# Shared .env files may still be read by Vite; none are copied into the package. +(cd "$root/frontend-v2" && npm ci && VITE_DEMO_MOCK=0 npm run build -- --mode offline) +cp -R "$root/frontend-v2/dist/." "$stage/cloud/web/" +python3 "$root/v2-server/scripts/package-offline.py" "$assets" "$stage/cloud/assets" +cp "$root/v2-server/scripts/start-offline.sh" "$stage/cloud/start.sh" +chmod 755 "$stage/cloud/start.sh" +cp "$root/v2-server/docs/deployment.md" "$root/v2-server/docs/deployment.en.md" "$stage/cloud/docs/" +(cd "$stage/cloud" && find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS) +tar -czf "$V2_OFFLINE_OUTPUT" -C "$stage" cloud +echo 'Offline package built. This build does not provide IDaaS login or versioned migrations; HTTPS is required for deployment; see docs/deployment.md.' diff --git a/v2-server/scripts/deepseek.sh b/v2-server/scripts/deepseek.sh index deca5d268..8f352b8cd 100755 --- a/v2-server/scripts/deepseek.sh +++ b/v2-server/scripts/deepseek.sh @@ -3,6 +3,7 @@ # repository so every checkout and worktree shares it and worktree cleanup never deletes it. # `--check` only validates the configuration, so `task v2:deepseek` can stop before starting anything. set -euo pipefail +export V2_LOGIN=email cd "$(dirname "$0")/.." env_file=$HOME/ora-demo/.env diff --git a/v2-server/scripts/demo.sh b/v2-server/scripts/demo.sh index 17d6f993f..a2504af0f 100755 --- a/v2-server/scripts/demo.sh +++ b/v2-server/scripts/demo.sh @@ -4,6 +4,7 @@ # environments run side by side and a rerun always starts over. Run it through `task v2:demo[:...]`, # which checks the model key and starts PostgreSQL first. set -euo pipefail +export V2_LOGIN=email cd "$(dirname "$0")/.." name=${1:?usage: scripts/demo.sh newcomer|lead|ops|all} diff --git a/v2-server/scripts/package-offline.py b/v2-server/scripts/package-offline.py new file mode 100755 index 000000000..f42f85b3d --- /dev/null +++ b/v2-server/scripts/package-offline.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +"""Copy only the five verified prepared resources; never recurse over a user's asset directory.""" +import hashlib +import json +import pathlib +import re +import shutil +import sys + +FILES = {'node': 'bin/ora-node', 'reaper': 'bin/ora-reaper', 'deno': 'bin/deno', + 'plugin': 'opencode-0.6.11.orax', 'claude': 'claude-0.4.5.orax'} + + +def pinned_source_commit(): + script = pathlib.Path(__file__).with_name('prepare-node.sh').read_text(encoding='utf-8') + match = re.search(r'^source_commit=([0-9a-f]{40})$', script, re.MULTILINE) + if not match: + raise ValueError('pinned source_commit missing in prepare-node.sh') + return match.group(1) + + +def copy_assets(source, destination): + manifest = json.loads((source / 'assets.json').read_text(encoding='utf-8')) + if manifest['version'] != 1 or manifest['sourceCommit'] != pinned_source_commit() or manifest['profile'] != 'release': + raise ValueError('offline packages require pinned release assets') + # Trust anchors remain in prepare-node.sh; the builder runs it before this copy. + for key, relative in FILES.items(): + entry = manifest[key] + original = pathlib.Path(entry['Path']) + if not original.is_absolute(): + original = source / original + if (not original.resolve().is_relative_to(source.resolve()) + or original.is_symlink() + or original.resolve() != (source / relative).resolve()): + raise ValueError('unexpected asset path: ' + key) + with original.open('rb') as stream: + digest = hashlib.file_digest(stream, 'sha256').hexdigest() + if digest != entry['SHA256']: + raise ValueError('asset digest mismatch: ' + key) + target = destination / relative + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(original, target) + target.chmod(0o755 if relative.startswith('bin/') else 0o644) + entry['Path'] = relative + (destination / 'assets.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8') + + +if __name__ == '__main__': + copy_assets(pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2])) diff --git a/v2-server/scripts/package_offline_test.py b/v2-server/scripts/package_offline_test.py new file mode 100644 index 000000000..eb45e5048 --- /dev/null +++ b/v2-server/scripts/package_offline_test.py @@ -0,0 +1,51 @@ +"""Content-boundary tests use explicit fake resources, never a purported release package.""" +import hashlib +import importlib.util +import json +import pathlib +import tempfile +import unittest + +spec = importlib.util.spec_from_file_location('pack', pathlib.Path(__file__).with_name('package-offline.py')) +pack = importlib.util.module_from_spec(spec) +spec.loader.exec_module(pack) + + +class PackageBoundary(unittest.TestCase): + def test_allowlist_relocation_and_corruption(self): + pinned = pack.pinned_source_commit() + self.assertRegex(pinned, r'^[0-9a-f]{40}$') + with tempfile.TemporaryDirectory() as temp: + root = pathlib.Path(temp) + source, target = root / 'prepared', root / 'package' + source.mkdir() + manifest = {'version': 1, 'sourceCommit': pinned, 'profile': 'release'} + for key, relative in pack.FILES.items(): + asset = source / relative + asset.parent.mkdir(exist_ok=True) + asset.write_bytes(b'explicit unit fixture') + manifest[key] = {'Path': str(asset), 'SHA256': hashlib.sha256(asset.read_bytes()).hexdigest()} + (source / 'assets.json').write_text(json.dumps(manifest)) + (source / 'users.json').write_text('must not ship') + (source / 'private-data').mkdir() + target.mkdir() + pack.copy_assets(source, target) + moved = root / 'moved' + target.rename(moved) + copied = json.loads((moved / 'assets.json').read_text()) + self.assertEqual({p.relative_to(moved).as_posix() for p in moved.rglob('*') if p.is_file()}, set(pack.FILES.values()) | {'assets.json'}) + for key, relative in pack.FILES.items(): + self.assertEqual(copied[key]['Path'], relative) + self.assertEqual(hashlib.sha256((moved / relative).read_bytes()).hexdigest(), copied[key]['SHA256']) + for bad_field, bad_value in [('sourceCommit', '0' * 40), ('profile', 'debug')]: + (source / 'assets.json').write_text(json.dumps({**manifest, bad_field: bad_value})) + with self.assertRaisesRegex(ValueError, 'pinned release assets'): + pack.copy_assets(source, root / f'reject-{bad_field}') + (source / 'assets.json').write_text(json.dumps(manifest)) + (source / 'bin/ora-node').write_text('corrupted') + with self.assertRaisesRegex(ValueError, 'digest mismatch'): + pack.copy_assets(source, root / 'reject-digest') + + +if __name__ == '__main__': + unittest.main() diff --git a/v2-server/scripts/prepare-node.sh b/v2-server/scripts/prepare-node.sh index d93595c58..465758eef 100644 --- a/v2-server/scripts/prepare-node.sh +++ b/v2-server/scripts/prepare-node.sh @@ -37,7 +37,7 @@ case $profile in debug) profile_flag= ;; *) echo 'V2_NODE_PROFILE must be release or debug.' >&2; exit 1 ;; esac -(cd "$source_dir" && cargo +1.95.0 build --locked $profile_flag -p ora-node -p ora-reaper) +(cd "$source_dir" && cargo +1.95.0 build -j 2 --locked $profile_flag -p ora-node -p ora-reaper) # Fixed modes, so the result does not depend on the caller's umask. install -d -m 0755 "$assets_dir" "$assets_dir/bin" for binary in ora-node ora-reaper; do @@ -68,7 +68,7 @@ if declaration != sys.argv[3]: def asset(path): with path.open('rb') as source: digest = hashlib.file_digest(source, 'sha256').hexdigest() - return {'Path': str(path), 'SHA256': digest} + return {'Path': str(path.relative_to(root)), 'SHA256': digest} manifest = {'version': 1, 'sourceCommit': sys.argv[2], 'profile': sys.argv[4], 'node': asset(root/'bin'/'ora-node'), 'reaper': asset(root/'bin'/'ora-reaper'), diff --git a/v2-server/scripts/start-offline.sh b/v2-server/scripts/start-offline.sh new file mode 100644 index 000000000..fad7eb2fc --- /dev/null +++ b/v2-server/scripts/start-offline.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail +root=$(cd "$(dirname "$0")" && pwd -P) +: "${V2_LOGIN:?Set V2_LOGIN=idaas; IDaaS integration is required}" +[[ $V2_LOGIN == idaas ]] || { echo 'The offline deployment launcher requires V2_LOGIN=idaas.' >&2; exit 1; } +: "${V2_DATABASE_URL:?Set V2_DATABASE_URL}" +: "${V2_DATA_DIR:?Set a persistent, private V2_DATA_DIR}" +: "${V2_MARKET_CREDENTIAL_KEY:?Set the stable V2_MARKET_CREDENTIAL_KEY}" +export V2_NODE_ASSETS_DIR="$root/assets" V2_FRONTEND_DIR="$root/web" +# Unset defaults to offline-safe disabled; an explicit internal source may be configured. +export V2_PLUGIN_MARKETPLACE_URL=${V2_PLUGIN_MARKETPLACE_URL-} +(cd "$root" && sha256sum --check --status SHA256SUMS) +exec "$root/bin/cloud" "$@" From 24d2a46c9006e87acc1828cff8388b5d17e4e247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=BE=99=E5=AE=89?= <297888591+wanglongan587@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:59:47 +0800 Subject: [PATCH 2/4] fix(frontend-v2): honor deployment official marketplace availability --- frontend-v2/playwright.config.ts | 1 + frontend-v2/src/features/settings/README.md | 2 + .../features/settings/market-api/generated.ts | 2 + .../settings/plugins/market-sources.tsx | 2 +- .../features/settings/plugins/page.test.tsx | 61 ++++++++++++++++++- .../src/features/settings/plugins/page.tsx | 8 +-- .../src/features/settings/test-utils.tsx | 5 +- 7 files changed, 74 insertions(+), 7 deletions(-) diff --git a/frontend-v2/playwright.config.ts b/frontend-v2/playwright.config.ts index a1f359dfc..a263f0fdc 100644 --- a/frontend-v2/playwright.config.ts +++ b/frontend-v2/playwright.config.ts @@ -30,6 +30,7 @@ export default defineConfig({ cwd: '../v2-server', url: `${server}/healthz`, env: { + V2_LOGIN: 'email', V2_ADDR: `127.0.0.1:${serverPort}`, V2_DATABASE_URL: database, // Public fixture key for this isolated test server; external servers keep their own setup. diff --git a/frontend-v2/src/features/settings/README.md b/frontend-v2/src/features/settings/README.md index 4fe842abf..53b801c53 100644 --- a/frontend-v2/src/features/settings/README.md +++ b/frontend-v2/src/features/settings/README.md @@ -73,3 +73,5 @@ member 被服务端拒绝。只有模型连接的资源操作保存在当前浏 插件市场区分空间选择与项目实际结果。来源管理使用临时市场契约生成的客户端;空间选择供插件和技能页面共享。Skill 会进入项目运行时;MCP 的非空执行须待 Node 与服务端完整生命周期接入,当前不会静默忽略选择后继续执行;可执行 Agent 仍只有系统预装的 OpenCode 和 Claude Code;市场 Agent、Hook 与合集只浏览,服务端拒绝新建或更新这些选择。默认构建里没有任何预装或演示安装:`VITE_DEMO_MOCK=1` 时 `lib/demo/plugin-installs.ts` 才为市场 Agent、Hook 和预装 Agent 提供浏览器本地演示安装(3–5 秒等待,只写 localStorage,不发请求)。插件详情列出各项目等待、成功或失败的状态。移除市场仅隐藏可安装目录,不移除空间中已有选择。 MCP 客户端由 orval.mcp.config.ts 从 v2-server/mcp.openapi.json 生成,安装与配置成功后刷新设置页和工作流 MCP 目录。秘密输入保存在表单内存,保存成功后清空。修改设置携带 revision,冲突由服务端拒绝。 + +官方市场由服务端配置控制:`V2_PLUGIN_MARKETPLACE_URL` 显式为空时,后端隐藏旧官方快照,设置页不显示官方来源;自定义来源仍可管理。来源列表响应的 `officialEnabled` 独立于目录内容,手动同步据此决定是否请求官方来源,并同步已启用的自定义来源;空目录不影响官方来源手动重试。 diff --git a/frontend-v2/src/features/settings/market-api/generated.ts b/frontend-v2/src/features/settings/market-api/generated.ts index 0bd2facf1..bf90e33e4 100644 --- a/frontend-v2/src/features/settings/market-api/generated.ts +++ b/frontend-v2/src/features/settings/market-api/generated.ts @@ -83,6 +83,8 @@ export interface SkillProgress { export type ListMarketSources200 = { items: MarketSource[]; + /** Whether the deployment enables the shared official source, independent of catalog contents. Official sources are not included in items. */ + officialEnabled: boolean; }; export type GetSkillProgress200 = { diff --git a/frontend-v2/src/features/settings/plugins/market-sources.tsx b/frontend-v2/src/features/settings/plugins/market-sources.tsx index 4a26dc7a0..f9270a380 100644 --- a/frontend-v2/src/features/settings/plugins/market-sources.tsx +++ b/frontend-v2/src/features/settings/plugins/market-sources.tsx @@ -94,7 +94,7 @@ export function MarketSources({

)} - {officialUrl && ( + {list.data?.officialEnabled && officialUrl && (
{ renderSettingsPage() await user.click(screen.getByRole('button', { name: '管理市场' })) const dialog = await screen.findByRole('dialog') - const officialRow = within(dialog).getByRole('article', { + const officialRow = await within(dialog).findByRole('article', { name: '官方市场', }) expect(officialRow).toHaveTextContent('https://github.com/ora-space/marketplace') @@ -573,3 +575,60 @@ it('keeps the demo runtime-preinstalled Agent install browser-only', async () => ) expect(backend.bodies).toHaveLength(0) }) + +it('hides the official source when the server disables it', async () => { + const url = 'https://market.example.org/plugins.git' + installMarketplaceBackend({ + officialEnabled: false, + catalog: [official], + marketSources: [{ + namespace: 'custom-market', url, branch: 'main', enabled: true, + syncedAt: null, failure: '', + retrieval: { mode: 'direct_https', useProxy: false }, + }], + }) + const user = userEvent.setup() + renderSettingsPage() + await user.click(screen.getByRole('button', { name: '管理市场' })) + const dialog = await screen.findByRole('dialog') + expect(await within(dialog).findByText(url, { selector: 'strong' })).toBeVisible() + expect(within(dialog).queryByRole('article', { name: '官方市场' })).not.toBeInTheDocument() +}) + +it.each([ + { name: 'enabled official with empty catalog', officialEnabled: true, catalog: [] }, + { name: 'disabled official with empty catalog', officialEnabled: false, catalog: [] }, + { name: 'disabled official with cached catalog', officialEnabled: false, catalog: [official] }, +])('synchronizes authoritative enabled sources: $name', async ({ officialEnabled, catalog }) => { + const success = vi.spyOn(toast, 'success').mockImplementation(() => 'success') + const error = vi.spyOn(toast, 'error').mockImplementation(() => 'error') + try { + const source = { + url: 'https://market.example.org/plugins.git', branch: 'main', + syncedAt: null, failure: '', + retrieval: { mode: 'direct_https' as const, useProxy: false }, + } + const backend = installMarketplaceBackend({ + officialEnabled, catalog, + marketSources: [ + { ...source, namespace: 'custom-market', enabled: true }, + { ...source, namespace: 'disabled-market', enabled: false }, + ], + }) + const user = userEvent.setup() + renderSettingsPage() + const sync = await screen.findByRole('button', { name: /^同步$/ }) + await waitFor(() => expect(sync).toBeEnabled()) + await user.click(sync) + await waitFor(() => expect(success).toHaveBeenCalledWith('市场目录已同步')) + const base = `POST /api/v1/tenants/${MARKET_TENANT}/spaces/${MARKET_SPACE}/plugins/sources` + expect(backend.seen.filter((request) => request.endsWith('/sync'))).toEqual([ + ...(officialEnabled ? [`${base}/official/sync`] : []), + `${base}/custom-market/sync`, + ]) + expect(error).not.toHaveBeenCalled() + } finally { + success.mockRestore() + error.mockRestore() + } +}) diff --git a/frontend-v2/src/features/settings/plugins/page.tsx b/frontend-v2/src/features/settings/plugins/page.tsx index b27ffff22..6c120a152 100644 --- a/frontend-v2/src/features/settings/plugins/page.tsx +++ b/frontend-v2/src/features/settings/plugins/page.tsx @@ -117,12 +117,12 @@ export default function PluginsPage() { const synchronize = async () => { setSyncing(true) try { - const { items } = await listMarketSources(market.tenantId, market.spaceId) + const { items, officialEnabled } = await listMarketSources(market.tenantId, market.spaceId) const failures: string[] = [] - for (const source of [ - 'official', + for (const source of new Set([ + ...(officialEnabled ? ['official'] : []), ...items.filter((s) => s.enabled).map((s) => s.namespace), - ]) { + ])) { try { await syncMarketSource(market.tenantId, market.spaceId, source) } catch { diff --git a/frontend-v2/src/features/settings/test-utils.tsx b/frontend-v2/src/features/settings/test-utils.tsx index 8601f968f..d8b3c0c26 100644 --- a/frontend-v2/src/features/settings/test-utils.tsx +++ b/frontend-v2/src/features/settings/test-utils.tsx @@ -85,6 +85,7 @@ export function marketplaceSelection( */ export function installMarketplaceBackend({ role = 'owner', + officialEnabled = true, catalog = [], selections = [], marketSources = [], @@ -95,6 +96,7 @@ export function installMarketplaceBackend({ tenantFailures = 0, }: { role?: 'owner' | 'member' + officialEnabled?: boolean catalog?: PluginCatalogEntry[] selections?: SpacePlugin[] marketSources?: MarketSource[] @@ -437,7 +439,7 @@ export function installMarketplaceBackend({ } } if (url === sourceBase && method === 'GET') - return { status: 200, data: { items: state.marketSources } } + return { status: 200, data: { items: state.marketSources, officialEnabled } } if (url === sourceBase && method === 'POST') { if (role !== 'owner') return { status: 403, data: { code: 'forbidden', params: {} } } @@ -466,6 +468,7 @@ export function installMarketplaceBackend({ const index = state.marketSources.findIndex( (source) => source.namespace === namespace, ) + if (namespace === 'official' && action === 'sync' && officialEnabled) return { status: 204 } if (index < 0) return { status: 404, data: { code: 'not_found', params: {} } } if (action === 'sync') return { status: 204 } From fede0f1215a356c08d2a603b565d27ab1c113d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=BE=99=E5=AE=89?= <297888591+wanglongan587@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:54:05 +0800 Subject: [PATCH 3/4] docs: add first intranet deployment acceptance procedure --- v2-server/docs/deployment.en.md | 63 +++++++++++++++++++++++++++++++-- v2-server/docs/deployment.md | 43 ++++++++++++++++++++-- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/v2-server/docs/deployment.en.md b/v2-server/docs/deployment.en.md index 520f015b8..25b2ba096 100644 --- a/v2-server/docs/deployment.en.md +++ b/v2-server/docs/deployment.en.md @@ -44,6 +44,8 @@ no versioned migrations; it cannot be used for production version upgrades that Keep configuration and secrets in protected process-manager configuration, outside the archive: - `V2_LOGIN=idaas`: the only deployment login. This build does not provide it and refuses startup. + Once IDaaS is enabled, the frontend reads `/auth/providers` to detect deployment mode and hides + the browser-only model-connections and roles pages as well as workflow role fields. - `V2_PUBLIC_URL`: public HTTPS address; configure `V2_IDAAS_BASE_URL`, `V2_IDAAS_CLIENT_ID` and `V2_IDAAS_CLIENT_SECRET` as specified by A6. This build does not yet support IDaaS login. - `V2_DATABASE_URL`: dedicated PostgreSQL connection with required TLS and least privilege. @@ -51,12 +53,15 @@ Keep configuration and secrets in protected process-manager configuration, outsi mandatory; this build does not provide HTTPS termination configuration. - `V2_DATA_DIR`: an absolute persistent directory such as `/srv/ora/data`. Neither it nor any parent may be writable by group or others. Do not use `/tmp`. Prefer mode `0700` owned by the service account. -- `V2_MARKET_CREDENTIAL_KEY`: persist a stable 32-byte Base64-encoded key in the format required by pluginmarket. - Back it up securely; replacing or losing it makes existing marketplace AK/SK credentials unreadable. +- `V2_MARKET_CREDENTIAL_KEY`: persist a stable 32-byte Base64-encoded key in the format required by + pluginmarket and projectrepos. Back it up securely; replacing or losing it makes existing marketplace + S3 AK/SK credentials, custom marketplace Git credentials, and private project repository tokens unreadable. - `V2_PLUGIN_MARKETPLACE_URL`: the launcher defaults to empty, disabling the official market. Direct binary startup retains the development default when unset; explicit empty disables sync and visibility of saved official catalog entries. Custom space markets support S3+AKSK and internal HTTPS Git authentication - (username plus token or password configured in space plugin settings, sealed with `V2_MARKET_CREDENTIAL_KEY`). + (username plus token or password configured in space plugin settings, sealed with `V2_MARKET_CREDENTIAL_KEY`); + Git sync disables redirects (`http.followRedirects=false`), so enter the exact current repository URL, + and changing the URL requires supplying new credentials or explicitly clearing saved ones. - `V2_PLUGIN_MARKETPLACE_BRANCH` and `V2_PLUGIN_MARKETPLACE_INTERVAL`: used only with the official source enabled; defaults are main and 5m. - `V2_MODEL_*` / `V2_ANTHROPIC_MODEL_*`: see the service README for model connections. @@ -74,6 +79,58 @@ before the Cloud HTTP listener. Verify secure cookies and callback URLs for depl public URLs only from configuration and do not trust forwarding headers. This guide does not choose a proxy or certificate management solution. +## First intranet acceptance + +Run the complete procedure only with a target version that provides IDaaS login and versioned migrations, +following that version's administrator bootstrap and migration instructions. This build is for deployment +preflight only and cannot go live. Email login or model fixtures cannot substitute for onsite acceptance. + +1. Prepare dedicated PostgreSQL and a persistent volume, a registered IDaaS application, an administrator + and a second employee account, a real project, a working model connection, and an internal Git repository + containing an installable workflow plugin with its package in S3. Match the package to the target Linux + architecture and require every entry in `sha256sum --check SHA256SUMS` to pass. Use an isolated acceptance + instance; do not restart or modify other instances. +2. Install the enterprise CA in the system trust store using the host distribution's enterprise procedure. + As the actual Cloud runtime identity, use the site's existing DNS/TLS diagnostic tools to check each Git, + S3 and model host: DNS results must be expected, and HTTPS hostname, certificate chain and validity checks + must pass. Then exercise actual requests through Cloud below. Never disable certificate validation or + public-address checks. If internal DNS resolves to an address rejected by the current address policy, + record a blocker; do not bypass TLS or relax address checks to proceed. Enter credentials only through + protected configuration or settings, never in command lines, URLs, screenshots or logs. +3. On the acceptance instance, migrate and bootstrap the IDaaS administrator according to the target + version's instructions, then invite the second employee to sign in and join the team. In the browser, + verify that web and `/api` share an origin, the IDaaS callback uses the registered public HTTPS address, + and the session cookie has `Secure`, `HttpOnly` and `SameSite=Lax`. Confirm there are no preset demo + accounts, projects or content. HTTPS termination connects before Cloud's HTTP listener; the deployment + must confirm its termination design. This procedure selects neither direct Cloud TLS nor a reverse proxy. +4. As administrator, add a custom internal HTTPS Git source under Settings → Plugins → Manage markets. + Enter its exact current repository URL (no redirects), branch, Git username and read-only token. + Select S3 signed downloads and separately enter the S3 endpoint, bucket, region and AK/SK. + Keep Git and S3 credentials separate, and persist and back up `V2_MARKET_CREDENTIAL_KEY`. + Synchronize and confirm no source failure and the expected catalog version. + Install a workflow plugin and confirm its imported workflow opens on the workflows page. +5. Create a separate acceptance source using a different repository address, not another URL spelling of + the same repository. Synchronize successfully first, then replace only this source's Git token with an + incorrect value and synchronize. Require the internal Git server's authentication failure response to + be recognized as a readable repository authentication failure (not a generic network or clone error) + and confirm the previous catalog is retained. Clear the saved Git credentials and synchronize again: a + repository requiring authentication must still fail explicitly and retain its catalog. Restore correct + credentials and verify synchronization succeeds again. Leave the normal source untouched; do not change + S3 keys to mask a Git failure. +6. Run the installed workflow and complete a conversation on the real project. Verify the actual model, + package download and Node execution succeed and that results and history are readable. Record members, + installed plugins, history and an acceptance file on the data volume, then restart only the acceptance + instance. After login, verify those states and files remain, the key still decrypts source credentials, + and synchronization succeeds again. Unfinished executions from before restart should be interrupted; + automatic resumption is not a success criterion. + +Keep redacted evidence for every step: program version, platform architecture, SHA verification, time, +action and result. Never record secrets, tokens or full authentication responses. On failure, distinguish +DNS resolution, TLS trust/hostname, Git or S3/model authentication, package download/digest verification, +and the Node/workflow execution chain in that order. Record safe error codes and redacted messages and +stop the affected step. A retained catalog or fixture output does not prove successful synchronization, +installation or real execution. + ## Backup and upgrade Back up PostgreSQL, the complete `V2_DATA_DIR` volume and the stable encryption key. Stop the service diff --git a/v2-server/docs/deployment.md b/v2-server/docs/deployment.md index 8a7580507..48bc9c994 100644 --- a/v2-server/docs/deployment.md +++ b/v2-server/docs/deployment.md @@ -37,6 +37,7 @@ PostgreSQL、IDaaS、模型和内部 Git/S3 服务。Git 和系统库须预先 在进程管理器的受保护配置中设置以下变量,不将密钥写入包或命令日志: - `V2_LOGIN=idaas`:唯一部署登录方式;当前构建不提供此能力,启动会明确拒绝。 + 启用 IDaaS 后,前端从 `/auth/providers` 识别部署模式,自动隐藏只写浏览器的「模型连接」「角色」两页和工作流角色字段。 - `V2_PUBLIC_URL`:部署公开 HTTPS 地址;`V2_IDAAS_BASE_URL`、`V2_IDAAS_CLIENT_ID`、 `V2_IDAAS_CLIENT_SECRET` 是 A6 规定的部署配置;当前构建尚不支持 IDaaS 登录。 - `V2_DATABASE_URL`:专用 PostgreSQL 连接,按企业要求启用 TLS 和最小权限。 @@ -44,10 +45,12 @@ PostgreSQL、IDaaS、模型和内部 Git/S3 服务。Git 和系统库须预先 部署必须使用 HTTPS,不得将这里的 HTTP 监听直接当作正式用户入口。 - `V2_DATA_DIR`:绝对、持久化目录,例如 `/srv/ora/data`;目录和所有父目录均不可被组或其他人写入, 不能放 `/tmp`。由运行账号创建,建议 `0700`,不要通过宽化权限解决 Node 启动失败。 -- `V2_MARKET_CREDENTIAL_KEY`:按 pluginmarket 的密钥格式生成(32 字节 Base64);作为稳定密钥持久保存, - 与数据一起备份。重建、替换或丢失会使现有市场 AK/SK 无法解密。 +- `V2_MARKET_CREDENTIAL_KEY`:按 pluginmarket 与 projectrepos 要求的密钥格式生成(32 字节 Base64); + 作为稳定密钥持久保存,与数据一起备份。重建、替换或丢失会使现有市场 S3 AK/SK、自定义市场 Git 凭据以及私有项目仓库令牌无法解密。 - `V2_PLUGIN_MARKETPLACE_URL`:启动器未配置时设为空,关闭官方市场。直接启动 binary 时未设置仍使用开发默认; - 显式空字符串关闭同步和旧官方目录可见性。自定义空间市场支持 S3+AKSK 及管理员在设置页配置的内部 HTTPS Git 认证(用户名与令牌/密码,经 `V2_MARKET_CREDENTIAL_KEY` 加密存库)。 + 显式空字符串关闭同步和旧官方目录可见性。自定义空间市场支持 S3+AKSK 及管理员在设置页配置的内部 HTTPS Git 认证 + (用户名与令牌/密码,经 `V2_MARKET_CREDENTIAL_KEY` 加密存库);Git 同步禁用重定向(`http.followRedirects=false`), + 须填写仓库当前准确地址,更改仓库地址时需同时填写新凭据或显式清除旧凭据。 - `V2_PLUGIN_MARKETPLACE_BRANCH`、`V2_PLUGIN_MARKETPLACE_INTERVAL`:仅官方源启用时使用,默认 main、5m。 - `V2_MODEL_*` / `V2_ANTHROPIC_MODEL_*`:模型连接,具体变量见服务 README。 改变连接、模型或凭据绑定可能让旧对话不能继续;在变更前通知用户,保留历史并新建对话。 @@ -60,6 +63,40 @@ PostgreSQL、IDaaS、模型和内部 Git/S3 服务。Git 和系统库须预先 系统 CA。不得关闭 TLS 校验。HTTPS 终止集成点是 Cloud HTTP 监听之前;部署需核对安全 Cookie 和回调地址, 公开地址只取配置,不信任转发头。本文不指定反向代理或证书管理方案。 +## 首次内网验收 + +仅对已提供 IDaaS 登录和版本化迁移的目标版本执行以下完整验收,并遵循该版本的管理员初始化和迁移说明; +本构建仅供部署预检,不能上线,也不能以邮箱登录或模型 fixture 替代现场验收。 + +1. 准备专用 PostgreSQL、持久数据卷、已登记的 IDaaS 应用、管理员和第二名员工账号,以及一个真实项目、 + 可用模型连接、含可安装工作流插件的内部 Git 仓库和对应 S3 包。确认包与目标 Linux 架构匹配,执行 + `sha256sum --check SHA256SUMS` 全部通过。为验收使用独立实例,不重启或修改其他实例。 +2. 按主机发行版的企业流程将企业 CA 安装到系统信任库。以实际 Cloud 运行身份,使用现场已有的 DNS/TLS + 诊断工具,逐一核对 Git、S3 和模型主机:解析结果符合预期,HTTPS 主机名、证书链和有效期校验通过, + 再经 Cloud 执行下述实际请求。不得关闭证书校验或公网地址检查;若内网解析地址被现有地址策略拒绝, + 记录为阻断条件,不以 TLS 绕过或放宽地址检查继续。凭据只通过受保护的配置或设置页输入, + 不放入命令行、URL、截图或日志。 +3. 在验收实例按目标版本说明完成迁移和 IDaaS 管理员初始化,再邀请第二名员工登录并加入团队。 + 从浏览器确认 web 与 `/api` 同源,IDaaS 回调使用登记的公开 HTTPS 地址,会话 Cookie 带 `Secure`、 + `HttpOnly` 和 `SameSite=Lax`;核对不存在预置演示账号、项目或内容。HTTPS 终止接入点仍在 Cloud HTTP + 监听之前;具体方案须由部署方确认,本步骤不指定 Cloud 直配或反向代理。 +4. 管理员在“设置 → 插件 → 管理市场”添加自定义内部 HTTPS Git 来源,填写当前准确仓库 URL(无重定向)、 + 分支、Git 用户名和只读令牌,包下载选择 S3 签名下载,分别填写 S3 端点、桶、区域及 AK/SK。Git 凭据与 S3 凭据分开, + 持久保存并备份 `V2_MARKET_CREDENTIAL_KEY`。点击同步,确认来源无失败提示、目录出现预期版本; + 安装一个工作流插件,确认工作流已导入并可在工作流页打开。 +5. 另建独立验收来源(使用不同仓库地址,不能只改同一仓库 URL 写法),先正确同步得到目录, + 再仅替换该来源的 Git 令牌为错误值并同步,确认内部 Git 服务器的认证失败输出被准确识别为可读的仓库认证失败提示 + (而不是笼统的网络/克隆失败)且上一版目录保留。 + 再清除已保存的 Git 认证并同步:需要认证的仓库仍应明确失败,旧目录仍保留。恢复正确凭据后应可再次同步。 + 全程不修改正常来源;Git 失败时不要更换 S3 密钥来掩盖问题。 +6. 在真实项目上运行已安装的工作流并完成一轮对话,确认实际模型、包下载和 Node 执行均成功,结果与历史可读。 + 记录成员、插件、历史和数据卷中的验收文件,然后只重启验收实例;确认登录后这些状态与文件仍在、 + 密钥仍可解密来源凭据且可再次同步。重启前未结束的执行应标记中断,不以自动续跑作为成功标准。 + +每步保存脱敏证据:程序版本、平台架构、SHA 校验结果、时间、操作和结果;不记录密钥、令牌或完整认证响应。 +失败时按顺序区分 DNS 解析、TLS 信任/主机名、Git 或 S3/模型认证、包下载/摘要校验、Node/工作流执行链, +记录安全错误码与脱敏提示后停止对应步骤;不得把目录保留或 fixture 输出当作同步、安装或真实执行成功。 + ## 备份和升级 备份 PostgreSQL、整个 `V2_DATA_DIR` 数据卷和稳定的加密密钥;采用停机或一致性快照确保数据库与数据卷一致, From 85bc9a5fac3e2e29913751cb451d79a6f5a531ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=BE=99=E5=AE=89?= <297888591+wanglongan587@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:28:54 +0800 Subject: [PATCH 4/4] docs(v2): keep workspace roles visible in deployment guides --- v2-server/docs/deployment.en.md | 4 ++-- v2-server/docs/deployment.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/v2-server/docs/deployment.en.md b/v2-server/docs/deployment.en.md index 25b2ba096..6ada88847 100644 --- a/v2-server/docs/deployment.en.md +++ b/v2-server/docs/deployment.en.md @@ -45,7 +45,7 @@ Keep configuration and secrets in protected process-manager configuration, outsi - `V2_LOGIN=idaas`: the only deployment login. This build does not provide it and refuses startup. Once IDaaS is enabled, the frontend reads `/auth/providers` to detect deployment mode and hides - the browser-only model-connections and roles pages as well as workflow role fields. + only the browser-only model-connections page; the workspace roles page and workflow role fields remain available. - `V2_PUBLIC_URL`: public HTTPS address; configure `V2_IDAAS_BASE_URL`, `V2_IDAAS_CLIENT_ID` and `V2_IDAAS_CLIENT_SECRET` as specified by A6. This build does not yet support IDaaS login. - `V2_DATABASE_URL`: dedicated PostgreSQL connection with required TLS and least privilege. @@ -55,7 +55,7 @@ Keep configuration and secrets in protected process-manager configuration, outsi may be writable by group or others. Do not use `/tmp`. Prefer mode `0700` owned by the service account. - `V2_MARKET_CREDENTIAL_KEY`: persist a stable 32-byte Base64-encoded key in the format required by pluginmarket and projectrepos. Back it up securely; replacing or losing it makes existing marketplace - S3 AK/SK credentials, custom marketplace Git credentials, and private project repository tokens unreadable. + S3 AK/SK credentials, custom marketplace Git credentials, tenant MCP settings, and private project repository tokens unreadable. - `V2_PLUGIN_MARKETPLACE_URL`: the launcher defaults to empty, disabling the official market. Direct binary startup retains the development default when unset; explicit empty disables sync and visibility of saved official catalog entries. Custom space markets support S3+AKSK and internal HTTPS Git authentication diff --git a/v2-server/docs/deployment.md b/v2-server/docs/deployment.md index 48bc9c994..384a6d551 100644 --- a/v2-server/docs/deployment.md +++ b/v2-server/docs/deployment.md @@ -37,7 +37,7 @@ PostgreSQL、IDaaS、模型和内部 Git/S3 服务。Git 和系统库须预先 在进程管理器的受保护配置中设置以下变量,不将密钥写入包或命令日志: - `V2_LOGIN=idaas`:唯一部署登录方式;当前构建不提供此能力,启动会明确拒绝。 - 启用 IDaaS 后,前端从 `/auth/providers` 识别部署模式,自动隐藏只写浏览器的「模型连接」「角色」两页和工作流角色字段。 + 启用 IDaaS 后,前端从 `/auth/providers` 识别部署模式,只隐藏只写浏览器的「模型连接」页;角色目录由服务端提供,设置页「角色」与工作流角色字段照常显示。 - `V2_PUBLIC_URL`:部署公开 HTTPS 地址;`V2_IDAAS_BASE_URL`、`V2_IDAAS_CLIENT_ID`、 `V2_IDAAS_CLIENT_SECRET` 是 A6 规定的部署配置;当前构建尚不支持 IDaaS 登录。 - `V2_DATABASE_URL`:专用 PostgreSQL 连接,按企业要求启用 TLS 和最小权限。 @@ -46,7 +46,7 @@ PostgreSQL、IDaaS、模型和内部 Git/S3 服务。Git 和系统库须预先 - `V2_DATA_DIR`:绝对、持久化目录,例如 `/srv/ora/data`;目录和所有父目录均不可被组或其他人写入, 不能放 `/tmp`。由运行账号创建,建议 `0700`,不要通过宽化权限解决 Node 启动失败。 - `V2_MARKET_CREDENTIAL_KEY`:按 pluginmarket 与 projectrepos 要求的密钥格式生成(32 字节 Base64); - 作为稳定密钥持久保存,与数据一起备份。重建、替换或丢失会使现有市场 S3 AK/SK、自定义市场 Git 凭据以及私有项目仓库令牌无法解密。 + 作为稳定密钥持久保存,与数据一起备份。重建、替换或丢失会使现有市场 S3 AK/SK、自定义市场 Git 凭据、租户 MCP 设置以及私有项目仓库令牌无法解密。 - `V2_PLUGIN_MARKETPLACE_URL`:启动器未配置时设为空,关闭官方市场。直接启动 binary 时未设置仍使用开发默认; 显式空字符串关闭同步和旧官方目录可见性。自定义空间市场支持 S3+AKSK 及管理员在设置页配置的内部 HTTPS Git 认证 (用户名与令牌/密码,经 `V2_MARKET_CREDENTIAL_KEY` 加密存库);Git 同步禁用重定向(`http.followRedirects=false`),