feat: 支持智能体自主编写 Tool/MCP / Guide self-authored Tools and MCP (#272)

用户要求自建可复用工具或设备协议接入时,现有指南缺少从代码到工具登记与调用的完整路径。新增双语 tool-mcp-authoring
Skill,提供 AgentFS Tool 和 MCP 作者合同、依赖/权限及生命周期验证;同步内置清单和目录元数据。修正
app-developer 的正文、参考和示例,作者动作统一使用 AppAuthoring,安装生命周期保留 AppManage。

When users request reusable tools or device integrations, the existing
guidance does not explain the complete
code-to-registration-to-invocation path. Add bilingual Tool/MCP
authoring guidance and references, and update builtin/catalog metadata.
Migrate app-developer authoring instructions and examples to
AppAuthoring while keeping installation lifecycle on AppManage.

验证 / Validation: market i18n and complete catalog validation pass (0
errors; existing governance warnings retained); all translation
freshness checks pass. Both localized script examples pass the real Tool
frontmatter Schema, execute valid input and reject invalid input.
Full-tree credential-pattern and customer-neutrality checks pass. No
hardware operation, model decision or full application release is
claimed.
This commit is contained in:
yige authored and GitHub committed 2026-11-09 17:11:25 +08:00
1 parent 2a6a814a0f
commit da94f5361b
18 files changed
+474 -51

No files matched your search

@@ -2,9 +2,9 @@
本文是未发行候选协议的知识材料。中文权威接口正文位于主仓 `docs/功能/市场系统/API/应用开发发布接口.md`;该路径与外仓 PR 不声明在线文档、客户端或官方 seed 已更新。每次先读取实际 capability 结果和当前 Schema。
Agent 使用原 `AppManage` 的有限作者动作,直接进入已有 release、preview、runtime 或 Docker owner。原 ToolExecutor 调用源、真实 Run/用户/Agent/宿主、材料读取根、当前策略与审批在效果边界重新核验。参数不自报 owner,也不获得平台管理凭据。以下动作可按目标组合,表格不是固定开发步骤。
Agent 使用原 `AppAuthoring` 的有限作者动作,直接进入已有 release、preview、runtime 或 Docker owner。原 ToolExecutor 调用源、真实 Run/用户/Agent/宿主、材料读取根、当前策略与审批在效果边界重新核验。参数不自报 owner,也不获得平台管理凭据。以下动作可按目标组合,表格不是固定开发步骤。
| AppManage action | 参数包络 | 返回事实 |
| AppAuthoring action | 参数包络 | 返回事实 |
|---|---|---|
| `authoring_capabilities` | 无额外参数 | `capabilities` 的实际 features/policy/hostInstanceId 和当前 Agent 可读的 `fileRoots` 与已登记的 `registryTargetIds`;本次会话可用作草稿来源时给 `draftSource:{agentId,sessionId}`,否则给 `draftSourceUnavailable`(旧客户端两者都没有);不授上传或文件写权限 |
| `read_draft` | `file_ref: FileResourceRef` | 从真实授权文件读取并核验的 `draft: AppDraftRef` |
@@ -26,7 +26,7 @@ Agent 使用原 `AppManage` 的有限作者动作,直接进入已有 release
| `export_release` | `owner_request: AppReleaseExportRequest`;可另给顶层 `export_file_ref` 与 `expected_absent:true` 或 `expected_etag` | exportRef、archiveDigest、releaseDigest、实际 files/size;显式导出时 archiveFile 包含真实 ZIP fileRef/sha256/size/etag/replayed,不上传 |
| `distribution_prepare` | `owner_request: AppDistributionPrepareRequest`(exportRef、registryRepoId、source、metadata) | 从真实 export 与 capability 中的目录目标生成三文件草稿,未上传/未提交 |
例如能力调用为 `AppManage({action:'authoring_capabilities'})`。读草稿使用 `action:'read_draft'` 与返回的授权根对应的 `file_ref`;发布准备/提交分别使用 `release_request`,预览/运行纳管/导出使用 `owner_request`。这些包络不是互换字段,原工具及内部 owner 仍逐个严格核验完整 DTO。
例如能力调用为 `AppAuthoring({action:'authoring_capabilities'})`。读草稿使用 `action:'read_draft'` 与返回的授权根对应的 `file_ref`;发布准备/提交分别使用 `release_request`,预览/运行纳管/导出使用 `owner_request`。这些包络不是互换字段,原工具及内部 owner 仍逐个严格核验完整 DTO。
`prepare_release` 的 AppReleasePrepareRequest 包含 `mutationId`、已授权 `materialRoot: FileResourceRef`、`manifestPath`、可选 expectedReleaseDigest、`target:{appId,installationId,deviceId,sourceId}`。FileResourceRef 的 schemaVersion/instanceId/agentId/rootId/path 来自真实 fileRoots 与本次材料;path 是授权根内相对路径,不能复制别的宿主/Agent/root。首次个人 sourceId 为服务约定的 `user-managed`,不能用名字冒充目录身份。
@@ -42,7 +42,7 @@ web-bundle.delivery.entrypoints 固定 `{entrypointId,path,spaFallback?}`;nati
数据合同声明 formatVersion、readableVersions、writableVersions、有限 files key/path/maxBytes/contentType 和 uninstallRetention: retain。备份/迁移/恢复说明引用必须在 payload 白名单中;说明不授权自动执行,安装历史不代表真实数据备份。
动态 Node 示例的 `/.desirecore-app-identity` 返回当前 TaskHost 注入的 proof/releaseDigest/scopeId/runtimeGeneration;proof 仅用于本次运行身份握手,不当应用 API token,不写日志。`AppManage.runtime_enroll` 使用已 prepare 的材料、installationId、真实 terminalId、endpoint.port/identityPath 与 startupPolicy。服务固定原执行合同后,原 Bash 显式停原命令,正式 commit 后由原 owner 启动新代际再核验。具体环境、执行审批和数据根均由实际 owner 决定。
动态 Node 示例的 `/.desirecore-app-identity` 返回当前 TaskHost 注入的 proof/releaseDigest/scopeId/runtimeGeneration;proof 仅用于本次运行身份握手,不当应用 API token,不写日志。`AppAuthoring.runtime_enroll` 使用已 prepare 的材料、installationId、真实 terminalId、endpoint.port/identityPath 与 startupPolicy。服务固定原执行合同后,原 Bash 显式停原命令,正式 commit 后由原 owner 启动新代际再核验。具体环境、执行审批和数据根均由实际 owner 决定。
原执行命令的初始默认端口写成 `PORT="${PORT:-32000}" node runtime/server.mjs`,其中默认端口需实际可用。重启仍执行原真实 argv,Harness 注入的 preview PORT 不能被写死赋值盖掉。若应用后端需要数据,APP_DATA_DIR 也用已授权 seed 根作为初次默认,后续严格使用 owner 注入的独立根;不可将 seed/candidate 数据自动迁入正式实例。
@@ -50,7 +50,7 @@ Docker prepare 的 owner_request 为 `{prepareRef,installationId,endpoint:{port,
## 平台 HTTP 管理消费者
HTTP 接口保留给平台 UI 或具有合法管理凭据的消费者,普通 HttpRequest 不自动注入实例凭据。Agent 缺少对应原工具能力时说明不可用,不读取实例 token、不改 Origin 绕过 401,也不把凭据交网页。HTTP 返回包络与原 AppManage 结果各按实际合同读取。
HTTP 接口保留给平台 UI 或具有合法管理凭据的消费者,普通 HttpRequest 不自动注入实例凭据。Agent 缺少对应原工具能力时说明不可用,不读取实例 token、不改 Origin 绕过 401,也不把凭据交网页。HTTP 返回包络与原 AppAuthoring 结果各按实际合同读取。
| 平台接口 | 用途 |
|---|---|
@@ -65,7 +65,7 @@ HTTP 接口保留给平台 UI 或具有合法管理凭据的消费者,普通 H
downloadPath 仍是平台管理下载路径,不授予网页或普通 HTTP 工具访问。Agent 需要实际 ZIP 时,在 export_release 顶层另给 export_file_ref:使用当前 Agent 原写权限内的 FileResourceRef 目标,path 为该根内相对路径;不能把服务 exports 私有目录挂成工作根。首次给 expected_absent:true,覆盖已有文件给原 expected_etag,两者不能同时提供。返回 archiveFile={fileRef,sha256,size,etag,replayed},sha256/size 必须等于 export 的 archiveDigest/size;这才是可交原授权上传工具的实际文件。只读 fileRoots 不授写权限。响应丢失保持相同目标/条件/完整正文,已有同一固定字节可重放,其他内容必须按实际 ETag 决定,不能盲覆盖。
目录草稿用原 AppManage.distribution_prepare,完整 AppDistributionPrepareRequest 放在 owner_request;registryRepoId 从 authoring_capabilities.registryTargetIds 选本次真实目标,不自报 sourceId 或构造连接。source 指向用户已实际上传并核验的不可变来源,sha256 等于 archiveDigest。返回 draft 三文件及 mapping/facts;upload 仍为 unverified,catalog 仍为 not-submitted,sourceAcl 仍为 source-admin-managed。写入目录仓库、提交 PR、目录准入和第二用户获取各由原工具取得实际回执;没有目标或来源连接时说明不可用。
目录草稿用原 AppAuthoring.distribution_prepare,完整 AppDistributionPrepareRequest 放在 owner_request;registryRepoId 从 authoring_capabilities.registryTargetIds 选本次真实目标,不自报 sourceId 或构造连接。source 指向用户已实际上传并核验的不可变来源,sha256 等于 archiveDigest。返回 draft 三文件及 mapping/facts;upload 仍为 unverified,catalog 仍为 not-submitted,sourceAcl 仍为 source-admin-managed。写入目录仓库、提交 PR、目录准入和第二用户获取各由原工具取得实际回执;没有目标或来源连接时说明不可用。
## 网页协作合同
@@ -1,14 +1,14 @@
# 固定应用版本分发
1. 确认用户要分发的精确版本、真实目标仓库/Registry、公共或私有范围、实际登录连接和材料许可。生成文件、个人发布或已有预览都不是上传授权;既有会话中的明确分发授权直接沿用。
2. 用原 AppManage 的 export_release 动作,从 prepareRef,或 installationId + expectedRevision 导出;完整 AppReleaseExportRequest 放在 owner_request。`paths` 必须显式覆盖全部 payload + app-release.json;不包含服务物化 descriptor、owner 标记、个人数据和秘密。需要实际 ZIP 时,另在顶层给 export_file_ref(当前 Agent 原写权限目录的目标 FileResourceRef)与 expected_absent:true 或原 expected_etag;不能同时给两个条件或覆盖未知文件。核验响应的 files/size 和 archiveFile 的实际 fileRef/sha256/size/etag/replayed,sha256/size 必须等于 export 的 archiveDigest/size。读能力返回的 fileRoots 不授写权限;响应丢失保持同一目标、条件与完整正文恢复。downloadPath 是平台管理消费者路径,普通 HttpRequest 不自动注入凭据。
2. 用原 AppAuthoring 的 export_release 动作,从 prepareRef,或 installationId + expectedRevision 导出;完整 AppReleaseExportRequest 放在 owner_request。`paths` 必须显式覆盖全部 payload + app-release.json;不包含服务物化 descriptor、owner 标记、个人数据和秘密。需要实际 ZIP 时,另在顶层给 export_file_ref(当前 Agent 原写权限目录的目标 FileResourceRef)与 expected_absent:true 或原 expected_etag;不能同时给两个条件或覆盖未知文件。核验响应的 files/size 和 archiveFile 的实际 fileRef/sha256/size/etag/replayed,sha256/size 必须等于 export 的 archiveDigest/size。读能力返回的 fileRoots 不授写权限;响应丢失保持同一目标、条件与完整正文恢复。downloadPath 是平台管理消费者路径,普通 HttpRequest 不自动注入凭据。
3. 将真实 archiveFile.fileRef 交原实际授权上传工具;GitHub Release 上传此 ZIP 后,核读真实下载地址、固定 commit 和原始字节摘要;Gitea 私有仓库可提交 `releases/<version>.zip`,取得完整 commit 与该路径。可变 tag/latest 只作展示,必须解析到固定引用。没有真实来源回执就报告“制品已生成,尚未上传”。
4. 使用原 AppManage 的 distribution_prepare 动作,owner_request 为 AppDistributionPrepareRequest:`exportRef`、从 authoring_capabilities.registryTargetIds 选择的真实 registryRepoId、`source:{kind:'release'|'git',url,ref,sha256,path?}` 和实际 metadata。目录目标列表是配置事实,不授予源端上传权限;普通模型不读取实例 token 或改 Origin 绕过认证。git 必须给固定包路径,sha256 必须等于导出 archiveDigest。产品 ID/名称/版本/入口不由 metadata 另填。
4. 使用原 AppAuthoring 的 distribution_prepare 动作,owner_request 为 AppDistributionPrepareRequest:`exportRef`、从 authoring_capabilities.registryTargetIds 选择的真实 registryRepoId、`source:{kind:'release'|'git',url,ref,sha256,path?}` 和实际 metadata。目录目标列表是配置事实,不授予源端上传权限;普通模型不读取实例 token 或改 Origin 绕过认证。git 必须给固定包路径,sha256 必须等于导出 archiveDigest。产品 ID/名称/版本/入口不由 metadata 另填。
5. metadata 包含 author/description/tags/category/license/redistribution/availability/requiredClientVersion,以及实际维护者、品牌和复核材料。证据不足保留 listing-only;不要填不存在的审核者、认证、发布时间或平台验收。已复核的许可证路径应来自同一 release 的 license role 文件。
6. 返回的是 `entries/<id>/manifest.json`、`catalog-metadata.v1.json`、`install.md` 内容和摘要。mapping 关联目标 sourceId、逻辑 ID、releaseDigest 与 archiveDigest,descriptor 安装时按真实来源物化。将三文件写入实际授权的目录仓库后审阅 diff,通过其原治理提交 PR;不能自动合并或说目录已开放。
7. 查询真实目录可获取状态与目标客户端握手,再由第二用户/设备沿原 acquisition/app-install-manager 路径安装并核验。两来源同名不共享实例或数据;目录更新仅给更新候选,不改原安装快照。
候选 Registry 4.3 Schema 与客户端 reader 必须先分别 review;正式 Registry seed 只指已合入的受审提交。候选 reader 仅在明确受信的非官方测试来源开放,正式条目等待客户端能力发行,不能借 10.0.180 字符串跳过 app-authoring-v1。
候选 Registry 4.3 Schema 与客户端 reader 必须先分别 review;正式 Registry seed 只指已合入的受审提交。候选 reader 仅在明确受信的非官方测试来源开放,正式条目等待客户端能力发行,不能借 10.0.203 字符串跳过 app-authoring-v1。
私有源使用 `access: private` 的真实 Registry 连接,只读登记端点、不转公开镜像;认证失败拒绝新获取。字段不是 ACL,GitHub/Gitea 管理员仍负责实际成员权限。平台团队成员移除不自动改变源端 ACL,不能宣称已撤销。已下载字节不能收回,本机数据不自动删除。