新增 GET /api/heicode/preflight?template_id=&binding_ids=1,2,3 —— agent 启动前的统一 确认层(#29 EPIC 的 #39 缺失项检测 + #40 可读执行摘要): - #39 缺失项检测:必需资源类别(git/sk/project_document/cloud_account)未绑定、budget (余额≤0)、agent_slot(在跑数达 tier 上限)。ready = missing 为空。 - #40 可读执行摘要:agent 角色、脱敏资源视图、高危操作、预算(剩余额度/quota_per_unit/ tier 上限/当前在跑数)、审批策略。 - 红线:resources 只暴露 type/provider/name/status/has_secret(布尔),绝不含 secret_ref/channelId/base_url/price。 - 高危操作固定 enum:production_deploy/db_write/cloud_resource_delete/ production_secret/large_budget,由已绑资源类型推导,均 requires_approval。 判定逻辑抽为纯函数 computePreflight,单测覆盖:全缺失、就绪、槽位满、高危 enum、 敏感字段不泄露(序列化断言)。复用既有 ResourceBinding/模板/GetUserMaxAgents/部署门禁 口径,不改部署/计费逻辑。文档补 §4.1。 #41(confirm + 审计 + 防篡改版本校验)作为后续 POST /preflight/confirm 实现。 Affects: Manager only(新增只读端点)。无 Client/Swarm 代码改动,无计费/审计 schema 改动。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -146,6 +146,47 @@ signature = base64( ed25519_sign( device_priv, sha256(canonical) ) )
|
||||
|
||||
---
|
||||
|
||||
## 4.1 启动前预检 / 执行摘要 🟢(preflight)
|
||||
|
||||
部署 agent 前,给用户看一份「执行摘要」:用哪些资源、还缺什么、有哪些高危操作、预算上限。用户**只确认摘要**,不必面对完整参数。
|
||||
|
||||
| 方法 | 路径 | 鉴权 | 说明 |
|
||||
|---|---|---|---|
|
||||
| GET | `/api/heicode/preflight?template_id=&binding_ids=1,2,3` | `UserOrV2DeviceAuth` | 返回缺失项 + 可读执行摘要 |
|
||||
|
||||
- `binding_ids` 同部署入参(逗号分隔或重复 key,可空)。
|
||||
|
||||
```json
|
||||
{ "success": true, "data": {
|
||||
"template_id": "architect",
|
||||
"agent_role": { "template_id":"architect", "name":"架构顾问", "model":"opus" },
|
||||
"resources": [
|
||||
{ "binding_id":17, "type":"git", "provider":"github", "name":"my-repo", "status":"active", "has_secret":true }
|
||||
],
|
||||
"invalid_bindings": [],
|
||||
"missing": [
|
||||
{ "kind":"sk", "reason":"未绑定SK 资源包" },
|
||||
{ "kind":"budget", "reason":"账户可用额度不足,请充值或开通订阅" }
|
||||
],
|
||||
"high_risk_ops": [
|
||||
{ "op":"production_deploy", "label":"生产部署 / 代码改动", "requires_approval":true },
|
||||
{ "op":"large_budget", "label":"大额预算消耗", "requires_approval":true }
|
||||
],
|
||||
"budget": { "remaining_quota":1234567, "quota_per_unit":500000, "tier_max_agents":5, "current_agents":1 },
|
||||
"approval_policy": { "mode":"per_high_risk_op" },
|
||||
"ready": false
|
||||
}}
|
||||
```
|
||||
|
||||
- **`missing`**:必需类别(`git`/`sk`/`project_document`/`cloud_account`)未绑定、`budget`(余额≤0)、`agent_slot`(在跑数已达 tier 上限)。`ready=true` 当且仅当 `missing` 为空。
|
||||
- **`high_risk_ops`**:固定 enum —— `production_deploy` / `db_write` / `cloud_resource_delete` / `production_secret` / `large_budget`;由已绑资源类型推导,均 `requires_approval`。
|
||||
- **红线**:`resources` 只暴露 `type/provider/name/status/has_secret`(布尔),**绝不返回 `secret_ref`/`channelId`/`base_url`/价格**。
|
||||
- **`invalid_bindings`**:请求里无效 / 非本人 / 非 active 的绑定 id(不阻断,供前端提示)。
|
||||
|
||||
> confirm + 审计 + 防篡改版本校验(#41)将作为 `POST /api/heicode/preflight/confirm` 后续补充;当前 preflight 为只读。
|
||||
|
||||
---
|
||||
|
||||
## 5. 我的 Agent 🟢(已对接 AM,生产验证)
|
||||
|
||||
> **2026-06-04 生产实测**:部署 / 列表 / 详情 / 状态 / 删除均真实可用。
|
||||
|
||||
Reference in New Issue
Block a user