开发者文档

RKT 协议 v1.0 — 完整参考手册

Manifest 结构

每个 Bundle 的核心是一个 manifest.json 文件,遵循 RKT 协议 v1.0 规范。当前阶段 Bundle 是最小交易单元(最小 = 1 Role + 0~N Kit)。

字段类型必须说明
rktVersionstring必填协议版本(当前 "1.0")
idstring必填唯一标识符(kebab-case)
versionstring必填Bundle 版本(语义化版本)
namestring必填显示名称
summarystring必填一句话描述
targetUserstring必填目标用户
rolesRole[]必填角色定义数组(≥1)
kitsKit[]可选能力包数组
teamsTeam[]可选协作团队定义
modeenum可选single | team
activationScopeenum可选session | agent | workspace | global
rollbackProfileobject必填回滚策略配置
assertionsAssertion[]可选契约测试声明
authorstring新增发布者/作者
tagsstring[]新增市场标签
categorystring新增市场分类
licensestring新增许可证(默认 MIT)

四大对象

Role 角色

{
  "id": "analyst",
  "label": "数据分析师",
  "purpose": "负责数据清洗和趋势分析",
  "description": "专注于金融数据的深度分析",
  "thinkingLevel": "deep",
  "isEntry": true,
  "responsibilities": ["数据清洗", "趋势分析"],
  "boundaries": ["不执行写操作"],
  "kits": ["data-kit", "chart-kit"],
  "input": { "type": "json", "schema": null },
  "output": { "type": "structured", "schema": null }
}
字段类型说明
id / labelstring必填 唯一标识 / 显示名称
purposestring角色目的
descriptionstring新增 详细描述
thinkingLevelenum新增 none | normal | deep
kitsstring[]新增 可使用的 Kit ID 列表
input / outputobject输入输出规范 { type: text|json|file|structured }
responsibilitiesstring[]职责列表
boundariesstring[]边界声明(不做什么)
isEntryboolean入口角色(Team 中使用)
tradablebooleanPhase 2 是否可独立交易

Kit 能力包

{
  "id": "web-search",
  "label": "网页搜索",
  "description": "实时网页搜索能力",
  "capabilities": ["关键词搜索", "实时新闻"],
  "riskLevel": "low",
  "runtime": "node",
  "entryPoint": "search.js",
  "toolBinding": { "type": "mcp", "config": { "server": "search-api" } },
  "permissions": [
    { "type": "network", "target": "https://api.search.com", "mode": "read" }
  ],
  "mirror": {
    "source": "roleos-mirror://official",
    "digest": "sha256:f1e2d3c4b5a6",
    "lockedAt": "2026-03-25T00:00:00Z",
    "autoUpdate": false,
    "clawHubRef": "web-search@1.0.0"
  }
}
字段类型说明
id / labelstring必填
descriptionstring新增 能力描述
capabilitiesstring[]必填 能力标识符列表
riskLevelenumlow | medium | high | critical
runtimeenum新增 node | python | binary | docker | mcp-server
entryPointstring新增 入口文件
toolBindingobject{ type: mcp|function|http|cli, config }
permissionsarray新增 [{ type, target, mode }]
mirrorobject新增 受控镜像策略(见下文)
tradablebooleanPhase 2

Team 协作

{
  "id": "research-team",
  "label": "研究团队",
  "topology": "pipeline",
  "entryRoleId": "analyst",
  "concurrencyMode": "sequential",
  "members": [
    { "id": "analyst", "isEntry": true },
    { "id": "writer" }
  ],
  "handoffGraph": [
    { "source": "analyst", "target": "writer", "type": "sequential", "label": "分析完成" }
  ],
  "terminationRules": ["报告已生成"],
  "degradationStrategy": {
    "toolMissing": "skip",
    "permDenied": "escalate",
    "modelWeak": "fallback",
    "timeout": "retry"
  },
  "humanEscalation": { "enabled": true, "maxRetries": 3 }
}
字段类型说明
id / labelstring必填
topologyenum新增 single | hierarchical | pipeline | parallel | mesh
entryRoleIdstring新增 入口 Role ID
concurrencyModeenum新增 sequential | parallel | mixed
membersarray成员列表
handoffGraphHandoffEdge[]交接路线(见下文)
terminationRulesstring[]必填 终止规则
degradationStrategyobject增强 细粒度降级 { toolMissing, permDenied, modelWeak, timeout }
humanEscalationobject{ enabled, condition?, maxRetries? }
tradablebooleanPhase 2

🔒 Kit 受控镜像策略

Kit 挂载的 Skills 从 ClawHub 获取但版本哈希锁定,禁止热更新,确保 Bundle 功能稳定:

字段类型说明
sourcestring镜像来源(如 roleos-mirror://official
digeststring内容哈希(sha256:xxx)— 版本锁定
lockedAtstring锁定时间 ISO 8601
autoUpdateboolean默认 false — 禁止热更新
clawHubRefstringClawHub 对照源引用(如 weather@1.2.0
updateCheckIntervalnumber更新检查间隔(天)
⚠️ 为什么禁止热更新? 第三方 Skills 的版本变化可能导致 Bundle 行为不可预测。RKT 通过 digest 哈希锁定确保安装时的 Skill 版本与开发时完全一致。Validator L4 会对 autoUpdate: true 发出警告。

Handoff 边定义

Team 的 handoffGraph 中每条边描述 Role 之间的交接方式:

字段类型必须说明
sourcestring必填来源 Role/Kit ID
targetstring必填目标 Role/Kit ID
typeenum建议dispatch | sequential | parallel | conditional | fallback | kit-attach
conditionstring可选条件表达式(conditional 类型)
prioritynumber可选优先级(fallback 排序)
labelstring可选显示标签

6 层 Validator

层级名称检查内容
L1包体结构必填字段存在、rktVersion 有效
L2语义对象Role id 唯一、Kit capabilities 非空、runtime 枚举、thinkingLevel 枚举、handoff 边类型
L3依赖兼容协议版本兼容、Kit 依赖解析、mirror.digest 哈希校验
L4权限隔离Kit 风险等级审核、permissions 权限清单autoUpdate 热更新警告
L5运行时确定rollbackProfile、activationScope、projectionPlan
L6体验可转译summary、description、author、Role 可读描述

版本演化

RKT 协议使用 Major.Minor 二段式版本号。

🔮 Phase 2 升级路线

当前阶段 Bundle 是最小交易单元,所有对象已预留独立交易字段:

预留字段类型说明
tradableboolean是否可独立交易(当前默认 false)
versionstring独立版本号
authorstring作者/发布者
tagsstring[]市场标签
Phase 2 升级时,Role/Kit/Team 均可独立上架市场、独立更新版本、自由组合成新 Bundle。Bundle 从"最小交易单元"升级为"组合包"。

API — 激活 Bundle

POST /api/activate
Content-Type: application/json

{ "manifest": { ... } }

→ 200: { bundleName, workspace, filesCreated, ... }
→ 422: { error, validation: { ... } }

API — 验证 Bundle

POST /api/validate
{ "manifest": { ... } }
→ { valid, passedLevels, totalLevels, results, errors, warnings }

API — Shadow Runtime

POST /api/shadow-preview
{ "manifest": { ... } }
→ { preview: { headline, members, capabilities, risk, ... }, markdown }

CLI 命令参考

命令说明
roleos init初始化 ROLEOS + 检测 Runtime
roleos start启动控制层
roleos stop停止控制层
roleos status查看 Bundle 和路由状态
roleos install <id>安装 Bundle
roleos uninstall <id>卸载 Bundle
roleos login登录 roleos.ai