Files
Genarrative/server-rs/crates/shared-contracts
kdletters 4a46f89c9b
Project CI / Repository checks (push) Successful in 2m45s
Project CI / Frontend tests (push) Successful in 3m27s
Project CI / Backend tests (push) Successful in 6m18s
Project CI / Native shell tests (push) Failing after 13m52s
接入 AGC 内置插件宿主并补齐 Cocos 编辑器能力 (#338)
客户端新增随包提供的插件宿主和 Cocos Creator 集成:识别并导入 Cocos 项目,通过内置桥接操作已打开的编辑器,无需安装项目 MCP 扩展。DirectProject 现在公开 36 个独立 cocos_* 工具,保留通用 JavaScript 执行入口。

- 通用插件 SDK、命令/能力/面板注册、编辑器适配器和跨进程内置插件开关。
- Cocos 场景、节点、组件、Prefab、UI、Layout/Widget、资源、保存、撤销、日志与预览调试;目录和实现由 JS/native 共用。
- 编辑事务回读、失败回滚、后续手动修改保护及不确定结果禁止重放;预览截图通过 MCP image 返回。
- DirectProject 跳过无关专业 Agent 历史,将项目打开和历史读取中的同步 I/O 移出窗口线程,消除 Cocos 执行与项目文件锁的错误耦合。

验证:
- 合并 master 后:类型/配置检查、编码检查、Rust 格式检查和提交钩子通过。
- 合并 master 后:Cocos 项目打开、插件面板和开发启动定向测试 10 通过、2 跳过;DirectProject MCP 测试 17 通过、1 项真实 Creator opt-in 忽略;插件宿主测试 9/9。
- 插件行为测试 17/17;native 测试 20/20,4 项 opt-in 测试默认忽略。
- 真实 Creator 3.8.8 的 36/36 操作 smoke,以及客户端 MCP tools/list、tools/call、UI/撤销和预览截图,在功能实现阶段已验证通过;本次 master 合并后未重复真实 GUI smoke。

验证边界:发行安装包和远端 CI 尚未验收。

Reviewed-on: #338
Co-authored-by: kdletters <kdletters@qq.com>
Co-committed-by: kdletters <kdletters@qq.com>
2026-09-13 14:48:55 +08:00
..

shared-contracts 共享 crate 说明

日期:2026-04-21

1. crate 职责

shared-contracts 是前后端兼容 contract 共享 crate,后续负责:

  1. HTTP 请求与响应 DTO
  2. SSE 事件结构与事件名约定
  3. response envelope、错误结构、兼容头部契约
  4. 各模块对外暴露的共享协议类型

2. 当前阶段说明

当前阶段已完成 Stage1 最小真实落地:

  1. 统一 response envelope / 头部常量
  2. auth/login-options
  3. auth/me
  4. auth/sessions
  5. runtime/settings

当前阶段继续补齐的 Stage2 鉴权 DTO:

  1. auth/entry
  2. auth/refresh
  3. auth/logout
  4. auth/logout-all
  5. auth/phone/send-code
  6. auth/phone/login
  7. auth/wechat/start
  8. auth/wechat/callback
  9. auth/wechat/bind-phone
  10. auth/wechat/miniprogram-login

当前阶段继续补齐的 Stage3 公开请求 DTO:

  1. assets/direct-upload-tickets
  2. assets/read-url
  3. assets/objects/confirm
  4. assets/objects/bind
  5. story-sessions/begin
  6. story-sessions/continue

当前阶段继续补齐的 Stage4 显式成功响应 DTO:

  1. assets/direct-upload-tickets
  2. assets/read-url
  3. assets/objects/confirm
  4. assets/objects/bind
  5. story-sessions/begin
  6. story-sessions/continue

当前阶段新增 Stage6 character visual 兼容 DTO

  1. assets/character-visual/generate
  2. assets/character-visual/jobs/:taskId
  3. assets/character-visual/publish

当前阶段新增 Stage7 character animation 模板与导入兼容 DTO

  1. assets/character-animation/templates
  2. assets/character-animation/import-video

当前阶段新增 Stage8 character workflow cache 第一批兼容 DTO

  1. assets/character-workflow-cache
  2. assets/character-workflow-cache/:characterId

当前阶段新增 Stage9 character animation 主链兼容 DTO

  1. assets/character-animation/generate
  2. assets/character-animation/jobs/:taskId
  3. assets/character-animation/publish

当前阶段新增 Stage5 story session scoped runtime story 写读 DTO

  1. BeginStoryRuntimeSessionRequest
  2. ResolveStoryRuntimeActionRequest
  3. StoryRuntimeProjectionResponse
  4. StoryRuntimeMutationResponse
  5. StoryRuntimeSnapshotPayload 仅用于 story session scoped 写侧持久化边界,不复用旧 /api/runtime/story/* 总入口 contract。

WP-DEL 已删除旧 runtime story HTTP DTORuntimeStoryStateResolveRequestRuntimeStoryBootstrapRequest/ResponseRuntimeStoryActionResponse 和旧 RuntimeStorySnapshotPayloadruntime_story 模块中仍保留的 RuntimeStoryViewModelRuntimeStoryPresentationRuntimeStoryPatch 与 battle presentation 是当前投影/表现构件,不作为旧 HTTP 写入口。

当前仍刻意未做:

  1. SSE 事件结构
  2. 自动代码生成或跨语言 contract 同步
  3. 其他尚未收口模块的 handler 响应体显式 DTO 化

3. 边界约束

  1. shared-contracts 只放协议类型与兼容结构,不承接业务规则、供应商适配或状态写入逻辑。
  2. 各模块 crate 对外暴露的协议优先复用这里的共享定义,避免重复散落。
  3. 前端兼容契约一旦进入本 crate,就必须与任务清单和基线文档同步维护。
  4. assets 模块依赖 platform-oss 的稳定返回类型,默认通过 oss-contracts feature 给 api-server 使用;SpacetimeDB WASM 构建链路必须通过 workspace 依赖关闭默认 feature,避免把 platform-oss / reqwest / wasm-bindgen 带进 spacetime-module