Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ curl -H "Authorization: Bearer $AGENTFLOW_TOKEN" "$AGENTFLOW_URL/api/health"
| `GET`, `PUT`, `DELETE` | `/api/skills` |
| `GET`, `PUT` | `/api/mcp-servers` |
| `POST` | `/api/mcp-servers/import` |
| `POST` | `/api/projects/{id}/asset-bundles/export` |
| `POST` | `/api/projects/{id}/asset-bundles/preview` |
| `POST` | `/api/projects/{id}/asset-bundles/import` |
| `GET` | `/api/executors` |
| `GET`, `PUT`, `DELETE` | `/api/sandboxes` |

Expand Down
169 changes: 169 additions & 0 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,117 @@ paths:
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
/api/projects/{projectId}/asset-bundles/export:
parameters:
- name: projectId
in: path
required: true
schema: {type: string}
post:
tags: [Assets]
operationId: exportProjectAssetBundle
description: Export the selected assets and their project-owned dependencies. Global rules that other projects bind to a shared LOOP are not included. Requires a project owner, maintainer, or platform administrator.
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [assets]
properties:
assets:
type: array
minItems: 1
maxItems: 200
items:
type: object
required: [kind, id]
properties:
kind: {type: string, enum: [skill, mcp, agent, sop]}
id: {type: string}
responses:
"200":
description: Versioned JSON bundle including asset definitions and attachments
content:
application/json:
schema:
$ref: "#/components/schemas/ProjectAssetBundle"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
"413":
description: Bundle exceeds the size limit
/api/projects/{projectId}/asset-bundles/preview:
parameters:
- name: projectId
in: path
required: true
schema: {type: string}
post:
tags: [Assets]
operationId: previewProjectAssetBundle
description: Validate a bundle and preview assets and connection setup. The import runs in a transaction that is rolled back, so nothing is written to the project. Requires a project owner, maintainer, or platform administrator.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ProjectAssetBundle"
responses:
"200":
description: Asset list and connections to configure
content:
application/json:
schema:
$ref: "#/components/schemas/ProjectAssetBundleResult"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
"413":
description: Bundle exceeds the size limit
/api/projects/{projectId}/asset-bundles/import:
parameters:
- name: projectId
in: path
required: true
schema: {type: string}
post:
tags: [Assets]
operationId: importProjectAssetBundle
description: Create the project-owned copies in one transaction and rebind their references. LOOPs start as drafts. Each asset reports its new targetId and each binding assetId names the imported copy. Requires a project owner, maintainer, or platform administrator.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ProjectAssetBundle"
responses:
"201":
description: Asset list and connections to configure
content:
application/json:
schema:
$ref: "#/components/schemas/ProjectAssetBundleResult"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
"413":
description: Bundle exceeds the size limit
/api/projects/{projectId}/restore:
parameters:
- name: projectId
Expand Down Expand Up @@ -5174,6 +5285,64 @@ components:
model: {type: string, description: Concrete model ID on the executor.}
effort: {type: string, description: The selected model's reasoning effort.}
approval: {type: string, enum: [confirm, assisted, auto], description: Initial confirmation mode for new conversations.}
ProjectAssetBundle:
type: object
required: [format]
properties:
format:
const: loopforge.project-assets/v1
skills:
type: array
items:
$ref: "#/components/schemas/OpenObject"
mcpServers:
type: array
items:
$ref: "#/components/schemas/OpenObject"
agents:
type: array
items:
$ref: "#/components/schemas/OpenObject"
workflows:
type: array
items:
$ref: "#/components/schemas/OpenObject"
rules:
type: array
items:
$ref: "#/components/schemas/OpenObject"
sandboxes:
type: array
items:
$ref: "#/components/schemas/OpenObject"
bindings:
type: array
items:
$ref: "#/components/schemas/ProjectAssetBundleBinding"
ProjectAssetBundleBinding:
type: object
required: [kind, assetId]
properties:
kind: {type: string}
assetId: {type: string}
ProjectAssetBundleResult:
type: object
required: [assets]
properties:
assets:
type: array
items:
type: object
required: [kind, id, name]
properties:
kind: {type: string}
id: {type: string}
name: {type: string}
targetId: {type: string}
bindings:
type: [array, "null"]
items:
$ref: "#/components/schemas/ProjectAssetBundleBinding"
OpenObject:
type: object
additionalProperties: true
Expand Down
24 changes: 24 additions & 0 deletions docs/api/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,30 @@ curl -u "$AGENTFLOW_USER:$AGENTFLOW_PASS" -X POST \
"$AGENTFLOW_URL/api/mcp-servers/import"
```

## 项目资产包

LOOP 库右上角的「资产包」可单选或批量选择本项目的 Skill、MCP、角色和 LOOP。项目所有者、项目管理员和平台管理员可以导入导出。

### `POST /api/projects/{id}/asset-bundles/export`

请求体的 `assets` 为所选资产数组。`kind` 支持 `skill`、`mcp`、`agent`、`sop`。

```json
{"assets":[{"kind":"sop","id":"review-sop"},{"kind":"skill","id":"check-rules"}]}
```

返回 `loopforge.project-assets/v1` JSON 文件,包含当前定义、附件和同项目依赖,包括角色引用的规则、LOOP 引用的子 LOOP,以及自定义沙箱及其 Dockerfile 构建上下文。平台内置沙箱使用目标环境中的对应配置。其他项目资产和平台通用模板需要先复制到当前项目,否则返回 `400` 并指出是哪一项。LOOP 只带上本项目绑定到它的全局规则,其他项目绑定到共享 LOOP 的全局规则不会进入资产包,也不影响导出。

### `POST /api/projects/{id}/asset-bundles/preview`

请求体为整个资产包。成功时返回 `assets` 清单和 `bindings` 重配项(包含 `kind` 和 `assetId`)。预览会在事务中完整执行一次导入再回滚,导入时会失败的定义(如角色 Hook 语言、产物路径)在预览时同样返回 `400`,此请求不写入项目。附件校验 SHA‑256 和路径。包最多包含 200 项资产及依赖、64 MiB 附件和 96 MiB JSON。

### `POST /api/projects/{id}/asset-bundles/import`

请求体与预览相同。成功返回 `201`,`assets` 中包含各项的 `targetId`,`bindings` 的 `assetId` 改为导入后副本的新 ID。资产包整体导入为项目私有副本并自动重绑包内引用。LOOP 保存为草稿,有子 LOOP 时按依赖顺序重配连接和发布。每次导入创建一套新副本。

项目 MCP 的 Headers、环境变量值、URL 中的认证信息和查询参数,以及项目凭据、知识库和通知绑定需要在目标项目重配。Skill 与 MCP 附件按原始字节导出。只在受信任项目间交付经过审查的资产包,正文和可执行文件中的自带内容会随包迁移。

## 执行器

### `GET /api/executors`
Expand Down
47 changes: 47 additions & 0 deletions internal/domain/asset_bundle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package domain

const ProjectAssetBundleFormat = "loopforge.project-assets/v1"

type BundleAssetRef struct {
Kind string `json:"kind"`
ID string `json:"id"`
}

type BundleAssetFile struct {
Path string `json:"path"`
Content []byte `json:"content"`
Mode uint32 `json:"mode"`
SHA256 string `json:"sha256"`
}

type BundleSkill struct {
SkillDefinition
Attachments []BundleAssetFile `json:"attachments,omitempty"`
}

type BundleMCPServer struct {
MCPServerDefinition
Attachments []BundleAssetFile `json:"attachments,omitempty"`
}

type ProjectAssetBundle struct {
Format string `json:"format"`
Skills []BundleSkill `json:"skills,omitempty"`
MCPServers []BundleMCPServer `json:"mcpServers,omitempty"`
Agents []AgentDefinition `json:"agents,omitempty"`
Workflows []WorkflowDefinition `json:"workflows,omitempty"`
Rules []RuleDefinition `json:"rules,omitempty"`
Sandboxes []SandboxProfile `json:"sandboxes,omitempty"`
Bindings []BundleBinding `json:"bindings,omitempty"`
}

type BundleBinding struct {
Kind string `json:"kind"`
AssetID string `json:"assetId"`
}

type BundleAssetSummary struct {
BundleAssetRef
Name string `json:"name"`
TargetID string `json:"targetId,omitempty"`
}
5 changes: 5 additions & 0 deletions internal/engine/workflow_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func hasFailed(wf domain.WorkflowDefinition, r domain.Run) bool {
return ok
}

// ValidateWorkflowGraph applies the runtime graph checks to a portable definition.
func ValidateWorkflowGraph(wf domain.WorkflowDefinition) error {
return validate(wf)
}

func validate(wf domain.WorkflowDefinition) error {
if err := domain.ValidateWorkflowKnowledge(wf); err != nil {
return err
Expand Down
Loading
Loading