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
1 change: 1 addition & 0 deletions frontend-v2/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions frontend-v2/src/features/settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 独立于目录内容,手动同步据此决定是否请求官方来源,并同步已启用的自定义来源;空目录不影响官方来源手动重试。
2 changes: 2 additions & 0 deletions frontend-v2/src/features/settings/market-api/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function MarketSources({
</Button>
</p>
)}
{officialUrl && (
{list.data?.officialEnabled && officialUrl && (
<article
aria-label="官方市场"
className="space-y-2 rounded-lg border p-3"
Expand Down
61 changes: 60 additions & 1 deletion frontend-v2/src/features/settings/plugins/page.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { beforeEach, expect, it, vi } from 'vitest'
import { screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { toast } from 'sonner'
import type { PluginCatalogEntry } from '@/api/generated.schemas'
import { getListMcpQueryKey, type McpInstallation } from '@/lib/mcp-api/generated'
import {
MARKET_SPACE,
MARKET_TENANT,
installMarketplaceBackend,
marketplaceEntry,
Expand Down Expand Up @@ -336,7 +338,7 @@ it('shows the shared official market and manages space sources', async () => {
renderSettingsPage(<PluginsPage />)
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')
Expand Down Expand Up @@ -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(<PluginsPage />)
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(<PluginsPage />)
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()
}
})
8 changes: 4 additions & 4 deletions frontend-v2/src/features/settings/plugins/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion frontend-v2/src/features/settings/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export function marketplaceSelection(
*/
export function installMarketplaceBackend({
role = 'owner',
officialEnabled = true,
catalog = [],
selections = [],
marketSources = [],
Expand All @@ -95,6 +96,7 @@ export function installMarketplaceBackend({
tenantFailures = 0,
}: {
role?: 'owner' | 'member'
officialEnabled?: boolean
catalog?: PluginCatalogEntry[]
selections?: SpacePlugin[]
marketSources?: MarketSource[]
Expand Down Expand Up @@ -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: {} } }
Expand Down Expand Up @@ -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 }
Expand Down
24 changes: 19 additions & 5 deletions v2-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down Expand Up @@ -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
```
Expand All @@ -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 验收通过。

Expand Down Expand Up @@ -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` 仍只列空间自定义来源,不将官方来源作为可编辑条目。
4 changes: 4 additions & 0 deletions v2-server/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions v2-server/deployment.go
Original file line number Diff line number Diff line change
@@ -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)")
}
}
Loading
Loading