Compare commits

..

259 Commits

Author SHA1 Message Date
k88936 15c633986d 补齐自动切分概览字体属性
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / Backend tests (pull_request) Failing after 12s
Project CI / Frontend tests (pull_request) Successful in 2m58s
Project CI / Native shell tests (pull_request) Successful in 23m2s
向 SeparationOverview 传入 fonts 数据

修复 UI 编辑器 TS2741 类型错误
2026-09-14 14:16:24 +08:00
k88936 5cb3801ba4 修复 UI 编辑器待办循环高亮动画
修复受控树选中回调清除 Inspector 高亮的问题

循环游标同时使用界面树与节点 ID

补充多节点循环和动画重启回归测试
2026-09-14 14:15:43 +08:00
k88936 6dbc4a39cb 注释掉 InspectorSidebar 中的 LayoutEditor 组件以暂时禁用布局编辑功能
Project CI / Repository checks (pull_request) Failing after 23s
Project CI / Backend tests (pull_request) Failing after 11s
Project CI / Frontend tests (pull_request) Successful in 3m52s
Project CI / Native shell tests (pull_request) Failing after 4m49s
2026-09-14 12:04:49 +08:00
k88936 e5df8f11b8 补充 UI 编辑器交互回归测试
从实际节点事件目标验证删除快捷键

验证 portal 右键菜单启用后会执行操作并关闭
2026-09-14 12:04:49 +08:00
k88936 2eff7d74c6 压缩 UI 编辑器概览布局
将识别概览指标改为四列横向排列

将素材切分概览改为四列网格以减少纵向高度
2026-09-14 12:04:49 +08:00
k88936 bd4dcfeacf 修复 UI 预览画布交互
为无限视口添加跟随平移和缩放的点阵背景

恢复画布快捷缩放与初始适配比例控制

保留节点平移选择并屏蔽浏览器原生拖拽选择
2026-09-14 12:04:47 +08:00
k88936 5e1e5a2e5f 重构 UI 编辑器全屏外壳
通过 portal 将资源编辑器挂载到 body 并覆盖标题栏以下区域

移除外层 FocusTrap,保留内部确认对话框的模态行为

统一左右浮动面板的顶部与底部留白
2026-09-14 12:02:46 +08:00
k88936 35f3a9cf8a 布局重构:
- 预览改为全区域背景层。
  - 左右面板、顶部流程条改为覆盖层,可遮挡预览。
  - 左右面板开合状态仅保存在当前 React 会话。
  - 增加左右面板“收起/展开”入口。
  - 编辑器关闭入口改为单独的 ×,继续通过 onBack 注入关闭逻辑。
  - 保留全局顶部栏与现有快捷键、业务状态、保存流程。
  - 底层页面仍由现有父级路由控制,不新增 URL 状态。
2026-09-14 12:02:10 +08:00
k88936 a0325d653e 补充图片编辑代理与素材切分工作流技术文档链接
Project CI / Repository checks (pull_request) Successful in 3m13s
Project CI / Frontend tests (pull_request) Successful in 3m24s
Project CI / Backend tests (pull_request) Successful in 6m18s
Project CI / Native shell tests (pull_request) Successful in 19m37s
2026-09-14 11:58:53 +08:00
k88936 b617873f46 调整模块引用顺序及精简测试断言格式 2026-09-14 11:58:42 +08:00
k88936 513c25898c Merge remote-tracking branch 'origin/master' into feat/ui-editor-auto-seperation
Project CI / Repository checks (pull_request) Failing after 2m16s
Project CI / Frontend tests (pull_request) Successful in 4m44s
Project CI / Backend tests (pull_request) Successful in 7m39s
Project CI / Native shell tests (pull_request) Successful in 18m52s
# Conflicts:
#	apps/ai-game-creator-shell/src/view/project-development/index.tsx
2026-09-14 11:32:17 +08:00
k88936 9856bb7057 补充 UI 工作流安全边界说明
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 2m58s
Project CI / Native shell tests (pull_request) Successful in 18m31s
记录提示清洗、图片解码限制、上传超时和 sidecar 产物恢复约束。
2026-09-12 21:44:12 +08:00
k88936 16db7ae8aa 为识别根节点补充名称兜底
LLM 返回空根名称时使用页面根节点默认名称,避免空标题进入 UI 树。
2026-09-12 21:40:20 +08:00
k88936 0ea7c7745c 保留分离结果的必要类型断言
TypeScript 对闭包赋值结果无法完成控制流收窄,恢复断言以通过类型检查。
2026-09-12 21:37:04 +08:00
k88936 6baf358bc7 完善素材分离恢复与步骤映射
回填部分失败时重新读取恢复状态;移除冗余类型断言并改用显式步骤映射。
2026-09-12 21:34:45 +08:00
k88936 462fc856aa 为原始图片上传解析增加超时
从请求入口开始计算准备截止时间,并限制 multipart 上传解析阶段的最长等待。
2026-09-12 21:33:48 +08:00
k88936 274bb1a3d2 兼容带参数的 PNG 内容类型
解析 multipart Content-Type 的媒体类型部分,接受合法的 image/png 参数。
2026-09-12 21:33:06 +08:00
k88936 8a96190db8 限制素材分离图片的 Base64 解码大小
对源图和服务端处理图在解码前后统一执行 64 MiB 上限检查,避免无界内存分配。
2026-09-12 21:32:20 +08:00
k88936 584da5b76b 限制视觉绑定处理图的解码规模
在解码前限制 base64 字节数并校验图像宽高,避免异常响应造成过量内存分配。
2026-09-12 21:31:13 +08:00
k88936 d1a03aec0e 统一预览画布适配与缩放滑杆计算
自动适配复用 fitToCanvas,避免重复计算;滑杆直接从原始缩放比例计算步进值。
2026-09-12 21:29:04 +08:00
k88936 b90d12c5fb 补充 Windows 原子替换安全说明
记录 MoveFileExW 路径缓冲区的所有权、终止符和调用生命周期不变量。
2026-09-12 21:27:57 +08:00
k88936 8135b4c374 避免 LLM 重试循环生产环境崩溃
将理论不可达分支改为显式错误返回,防止重试边界变化触发 panic。
2026-09-12 21:27:34 +08:00
k88936 124d94de93 保证素材批次补丁失败时状态原子
在修改状态前预检所有成功绑定节点的裁剪路径,避免中途错误留下部分更新。
2026-09-12 21:27:05 +08:00
k88936 103fe6fcd6 移除无效的裁剪路径伪校验
裁剪路径由 UUID 文件名和 sidecar 目录构造,直接依靠项目相对路径校验。
2026-09-12 21:26:33 +08:00
k88936 1370094c52 为素材处理产物生成唯一文件名
处理图 sidecar 文件名改用 UUID,避免全批次返工时覆盖前一批产物。
2026-09-12 21:25:58 +08:00
k88936 be8155c4a8 保留素材切分原始失败原因
检查点写入失败时仅记录日志,继续返回图像处理、绑定或裁剪的原始错误。
2026-09-12 21:25:21 +08:00
k88936 9052ff14f8 区分素材提取的完成与问题节点
仅将已绑定节点标记为 DONE,达到返工上限的节点继续作为上下文提供给提取模型。
2026-09-12 21:24:25 +08:00
k88936 9d9f1b8164 清理素材提取提示中的备注内容
对 YAML 提示中的描述和返工备注做有界清洗,避免代码围栏破坏提示结构。
2026-09-12 21:23:44 +08:00
k88936 8629a228a1 限制并清理视觉绑定提示备注
为节点描述和返工备注增加长度上限并移除控制字符、代码围栏字符。
2026-09-12 21:23:35 +08:00
k88936 a92121e09d 校准素材切分概览的资源绑定统计
图片与字体槽位仅在引用的项目资源存在时计为已绑定。

概览组件接入字体资源表并保留无资源参数时的旧调用语义。
2026-09-12 21:22:21 +08:00
k88936 e49d6741ca 修正组件移除失败弹窗处理
移除操作失败时关闭确认弹窗以展示错误;未执行时保留弹窗。
2026-09-12 21:19:36 +08:00
k88936 f7666339fe 修正组件替换失败弹窗处理
替换操作失败时关闭确认弹窗以展示错误;未执行时保留弹窗。
2026-09-12 21:19:14 +08:00
k88936 891cf50c0e 按节点重置组件检查面板
为 ComponentPanel 绑定节点 key,切换节点时清理折叠与确认状态。
2026-09-12 21:18:30 +08:00
k88936 b15a95e774 扩大 UI 节点随机标识空间
将节点 ID 从 8 位十六进制扩展到 16 位,降低批量识别中的碰撞概率。
2026-09-12 21:18:00 +08:00
k88936 e0f743b608 修复组件计数的布尔值转换
将布尔值显式转换为 usize,恢复 Rust 工作流模块编译。
2026-09-12 21:17:41 +08:00
k88936 a19684a5f5 Merge remote-tracking branch 'origin/master' into feat/ui-editor-auto-seperation
Project CI / Repository checks (pull_request) Failing after 1m7s
Project CI / Frontend tests (pull_request) Successful in 3m10s
Project CI / Backend tests (pull_request) Successful in 6m0s
Project CI / Native shell tests (pull_request) Successful in 18m41s
2026-09-12 19:46:41 +08:00
k88936 46b0871e6d 补充背景节点规则说明
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 2m48s
Project CI / Native shell tests (pull_request) Successful in 19m57s
2026-09-12 18:56:31 +08:00
k88936 5c40abce47 识别树根节点改为模型根节点
识别协议改用 trees[].root 并保留根节点非几何字段
同步根节点解析校验、提示词与 UI 树转换
2026-09-12 18:10:45 +08:00
k88936 47d09d51ef 简化并集中化随机 NodeId 生成逻辑 2026-09-12 17:57:48 +08:00
k88936 f05f6e49ab 复用原始图片编辑 HTTP 客户端
Project CI / Repository checks (pull_request) Failing after 12s
Project CI / Backend tests (pull_request) Failing after 13s
Project CI / Frontend tests (pull_request) Successful in 3m12s
Project CI / Native shell tests (pull_request) Failing after 4m20s
让 raw edit 接收 api-server 构造的 VectorEngine reqwest 客户端。

通过 request builder 保留有效请求超时,不修改现有连接池策略。

移除不再使用的客户端构造错误分支并同步技术方案。
2026-09-12 16:33:33 +08:00
k88936 c7fe531b16 恢复预览百分比按钮适配画布
将缩放百分比显示改为可点击的适配画布按钮
复用工具栏按钮的鼠标焦点处理并按当前容器重新计算视口
补充预览缩放组件回归测试并同步交互设计文档
2026-09-12 16:31:55 +08:00
k88936 d44c6ab62c 补充背景节点规则示例说明 2026-09-12 16:28:31 +08:00
k88936 6764950aec 限制原始图片上传字节
将 image 和 mask multipart 字段改为分块读取并限制单字段大小。

新增图片总字节上限、413 错误和字段/总量边界测试。

同步 Raw GPT Image 2 代理技术方案的资源防护合同。
2026-09-12 16:27:23 +08:00
k88936 0944667c37 限制原始图片解码并发
为 raw image PNG 预处理增加 AppState 专用 semaphore。

按请求截止时间限制槽位等待和 blocking 解码等待,并让 permit 持有到任务结束。
2026-09-12 16:22:06 +08:00
k88936 bb2f080d3b 分离产物使用 UUID 文件名
切分图片文件名改用 UUID,避免把 NodeId 当作物理路径。

继续通过 cut_paths 写入 BoundNode.cut_image_path,保留逻辑节点 ID 与产物路径的独立性。
2026-09-12 16:18:13 +08:00
k88936 413707da33 提前拒绝高位深 PNG 解码
通过 image crate 的 ImageReader decoder 元数据在像素缓冲分配前拒绝 16-bit PNG。

继续使用同一外部 decoder 执行受限像素读取校验,不手写 PNG 解析器。
2026-09-12 15:40:26 +08:00
k88936 6235fa3298 修复分离状态跨平台原子替换
使用唯一临时文件并同步写入,避免 checkpoint 临时文件互相覆盖。

Unix 使用 rename,Windows 使用 MoveFileExW 原子覆盖已有 state.json。

拒绝符号链接和非普通文件目标,并增加覆盖已有目标回归测试。
2026-09-12 15:40:12 +08:00
k88936 8a9d37d5ad 移除分离提示词的破坏性清洗
保留描述、返工意见和 NodeId 原文,删除重复截断与字符改写。

返工意见仍由 validate_binding_response 统一执行 MAX_REWORK_NOTE_CHARS 校验。
2026-09-12 15:19:24 +08:00
k88936 9bbfc56cd7 修正分离期间保存选项的闭包判断
由调用方明确传入的 allowDuringSeparation 直接生效,避免依赖点击时捕获的过期状态。
2026-09-12 15:02:56 +08:00
k88936 e9d0180054 集中管理 GPT Image 2 尺寸限制
将请求尺寸压缩与原始编辑校验共用同一组像素、边长和对齐常量。
2026-09-12 15:00:55 +08:00
k88936 664bdd6877 避免伪造原始图片供应商请求编号
原始图片响应未提供供应商 request id 时不再写入操作名作为关联编号。
2026-09-12 14:58:21 +08:00
k88936 39a64a864a 声明图片平台使用 reqwest 流式特性
为 Part::stream 补齐 platform-image 的直接依赖特性,支持独立构建。
2026-09-12 14:56:54 +08:00
k88936 f055961714 修正分离源图 MIME 识别回退
缺失或未知 MIME 时强制走 PNG 规范化,避免非 PNG 数据被误标为 image/png。
2026-09-12 14:55:35 +08:00
k88936 3bcabe36fa 清理字体校验中的冗余空值判断
按 FontSource 的实际联合类型保留运行时字体资源校验。
2026-09-12 14:54:49 +08:00
k88936 2bfc870854 复用分离流程已选批次节点
让批次校验和应用使用同一份已选节点,避免重复选择造成目标漂移。
2026-09-12 14:54:05 +08:00
k88936 b0e9741e81 在预览区尺寸变化时重新适配画布
将画布尺寸纳入适配视口 effect 依赖,恢复面板调整后的自动 fit。
2026-09-12 14:49:30 +08:00
k88936 b52a33cc28 明确提示词清洗的字符映射意图
使用 map 替代始终返回 Some 的 filter_map,保持清洗行为不变。
2026-09-12 14:48:42 +08:00
k88936 398edd6e86 将分离状态序列化移入阻塞任务
避免在异步执行器线程同步格式化大型 separation state。
2026-09-12 14:48:00 +08:00
k88936 9788087271 修复组件操作失败时确认弹窗卡住
当组件更新返回 undefined 时关闭替换或移除确认弹窗,避免操作无反馈地停留。
2026-09-12 14:47:01 +08:00
k88936 329de5fce9 修复组件面板展开状态重置
仅在组件存在性发生变化时同步展开状态,避免深拷贝更新意外重新展开。
2026-09-12 14:46:08 +08:00
k88936 e4d70fbe1b 移除 Raw 编辑无效恢复审计字段
Project CI / Repository checks (pull_request) Successful in 2m59s
Project CI / Frontend tests (pull_request) Successful in 3m18s
Project CI / Backend tests (pull_request) Successful in 7m7s
Project CI / Native shell tests (pull_request) Successful in 19m53s
RawImageEditResult 仅保留实际透传的 b64_images

删除 raw-edit 不会产生的恢复审计转发与文档描述

补充 PreparedRawImageEdit 的 Debug 派生以通过现有测试
2026-09-12 13:50:25 +08:00
k88936 aaa9d3fb6f 补齐 Raw 编辑恢复审计语义
保留 recovered_failure_audits 公共字段并注明当前同步无回退不变量

让 raw handler 记录未来恢复审计并写入成功摘要计数

同步 Raw GPT Image 2 技术方案文档
2026-09-12 13:44:17 +08:00
k88936 bd127846f7 允许分离流程在忙碌态保存结果
保留 isSeparating 属于 isAiRunning 的全局语义

为内部分离保存增加受控 allowDuringSeparation 选项
2026-09-12 13:36:30 +08:00
k88936 b1751784ba 修正切分状态写入日志格式
移除状态写入完成日志中多余的格式参数
2026-09-12 13:26:36 +08:00
k88936 379611d552 避免渲染阶段写入画布尺寸引用
在 ResizeObserver 尺寸更新回调中同步 canvasSizeRef
2026-09-12 13:20:30 +08:00
k88936 ef04a19d5a 抽取组件确认弹窗公共结构
统一替换与移除操作的确认弹窗布局

保留各操作独立文案与按钮样式
2026-09-12 13:19:59 +08:00
k88936 206b4830a1 复用原图编辑错误摘要
解析失败分支只计算一次截断响应并同时用于审计与错误返回
2026-09-12 13:19:10 +08:00
k88936 4b8e268816 统一重启切分失败通知
restartSeparation 失败时复用工作流完成上报并清理完成提示
2026-09-12 13:18:30 +08:00
k88936 7e7d6f1563 避免忙碌时继续切分隐藏恢复提示
在清理恢复对话框前检查分离与工作流忙碌状态
2026-09-12 13:18:13 +08:00
k88936 a4b1d81123 避免忙碌时重启切分丢失恢复状态
restartSeparation 在清理 sidecar 前复用并发工作流守卫
2026-09-12 13:17:52 +08:00
k88936 983b15c3a7 允许恢复流程识别已完成的素材回填
同一 Sprite 已绑定的节点直接跳过

仅对缺失 Image 或绑定其他素材报告错误
2026-09-12 13:17:38 +08:00
k88936 cdb6fcfe97 切换组件时重置检查面板展开状态
按组件身份变化同步展开状态,避免沿用上一个节点的折叠状态
2026-09-12 13:17:01 +08:00
k88936 d8a4e35232 减少切分状态写入的重复克隆
让状态写入接口借用状态并在阻塞任务中写入序列化字节

保留 schema 与大小校验,避免每批次复制完整状态树
2026-09-12 13:16:25 +08:00
k88936 0726106818 为图片分离请求设置超时
将原图编辑 HTTP 请求限制为 120 秒,避免工作流永久阻塞
2026-09-12 13:14:22 +08:00
k88936 8beade5b4d 为业务校验重试增加退避
校验失败重试复用请求错误的递增等待并记录日志
2026-09-12 13:13:56 +08:00
k88936 46984a4945 净化切分提示中的节点标识
复用提示文本清洗逻辑,阻断控制字符与反引号注入
2026-09-12 13:13:25 +08:00
k88936 a8a30ecbc8 修正切分恢复命令映射
finalize_separation 调用 finalize helper

discard_separation_recovery 调用 discard helper
2026-09-12 13:13:06 +08:00
k88936 48e669d167 合并主线并解决界面编辑器冲突
Project CI / Repository checks (pull_request) Successful in 2m44s
Project CI / Frontend tests (pull_request) Successful in 3m25s
Project CI / Backend tests (pull_request) Failing after 4m23s
Project CI / Native shell tests (pull_request) Successful in 17m48s
合并主线的 AGC Runtime、UI 工作流与开发脚本变更

保留现行 Prompt Runtime 结构并整合设计基础提示词契约断言

适配 CanvasWorld 逆缩放渲染并修正预览缩放回归测试

同步项目文档、共享契约与已退役策划资源清理
2026-09-12 11:38:50 +08:00
k88936 23fdc005fe 整理 Raw 编辑方案文档格式
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 3m10s
Project CI / Native shell tests (pull_request) Failing after 14m49s
分隔字节边界说明与代码拆分列表
2026-09-12 11:22:50 +08:00
k88936 b8a4523a4f 补充 Raw 编辑字节边界说明
记录 raw_edit 使用 Bytes streaming multipart 的零拷贝约束

明确既有图片链路继续保持 Vec 字节契约
2026-09-12 11:20:53 +08:00
k88936 9c04561419 明确 Raw 编辑零拷贝上传约束
补充 Bytes 所有权与 streaming multipart 注释

增加共享字节缓冲不转换的回归测试
2026-09-12 11:18:14 +08:00
k88936 551fb6609a 为 Raw 编辑建立独立字节类型
恢复旧图片链路的 Vec 字节契约

让新增 raw_edit 输入和结果类型独立于既有 ReferenceImage
2026-09-12 11:15:15 +08:00
k88936 d05440dcca 为 Raw 编辑建立独立字节类型
恢复旧图片链路的 Vec 字节契约

让新增 raw_edit 输入和结果类型独立于既有 ReferenceImage
2026-09-12 11:13:27 +08:00
k88936 7edf4a8f8b 恢复旧图片链路字节类型
Project CI / Repository checks (pull_request) Failing after 13s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 2m43s
Project CI / Native shell tests (pull_request) Failing after 14m6s
撤回非 raw_edit 的全局 Bytes 迁移

保留既有 VectorEngine 与编辑器路径的 Vec 字节契约
2026-09-12 11:06:05 +08:00
k88936 afc9ecbd51 补充 WebP 源图转码测试
验证 WebP 输入可转换为 PNG 上传格式
2026-09-12 10:42:15 +08:00
k88936 fc2f4b71ce 支持分离流程转换非 PNG 源图
在上传图片编辑请求前将 JPEG 和 WebP 转码为 PNG

新增 JPEG 转 PNG 单元测试并将转码放入阻塞任务
2026-09-12 10:38:00 +08:00
k88936 545f64cf9e 补齐原图编辑失败追踪事件
provider 失败时记录 external_generation_run 失败状态

保留现有外部 API 失败审计与错误映射
2026-09-12 10:37:04 +08:00
k88936 2a50614c11 将分离恢复阻塞 I/O 移出异步线程
新增 spawn_blocking 状态读取封装

sidecar 目录创建改用阻塞任务执行
2026-09-12 10:23:32 +08:00
k88936 915006c98f 适配绑定区域类型错误调用方
在区域归一化边界转换 typed error 为展示文案
2026-09-12 10:23:21 +08:00
k88936 69ce232a74 为绑定区域校验引入类型错误
用 ZeroDimension 和 OutOfBounds 区分边界校验失败

补充 typed error 单元测试并保留展示层中文文案
2026-09-12 10:20:17 +08:00
k88936 319aa69d6e 统一分离树根节点坐标空间
子节点收集复用根节点实际解析矩形
2026-09-12 02:24:01 +08:00
k88936 bec468bdc9 统一分离终止节点判定
批次选择与提取提示复用同一终止节点集合
2026-09-12 02:23:02 +08:00
k88936 eada20c199 恢复自动切分前重新校验状态
继续分离前确认 sidecar 存在并检查前置条件

恢复入口异常统一写入工作流失败通知
2026-09-12 02:20:52 +08:00
k88936 e8cf773aac 统一自动切分失败完成提示
分离入口异常时写入工作流完成失败通知
2026-09-12 02:19:48 +08:00
k88936 12fbb61fad 限制分离恢复状态写入大小
写盘前校验与读取一致的八兆字节上限

超限时记录原因并拒绝不可恢复检查点
2026-09-12 02:17:55 +08:00
k88936 478e08fb92 将 PNG 依赖限定为测试环境
从生产依赖移除仅测试使用的 png crate

在 dev-dependencies 中声明 PNG 测试依赖
2026-09-12 02:13:52 +08:00
k88936 0e67fbf80a 停止对最终工作流步骤重复预检
资产分离作为最后步骤不再校验不存在的下一步
2026-09-12 02:12:15 +08:00
k88936 ed2cfbad36 避免预览容器变化重置缩放
自动适配仅在图片或逻辑尺寸变化时执行

通过尺寸引用保留初始视口兜底值
2026-09-12 02:11:22 +08:00
k88936 560422286b 稳定组件面板展开与移除交互
仅在组件存在性变化时自动展开面板

为移除组件增加确认并保留失败弹窗
2026-09-12 02:08:56 +08:00
k88936 e04075fd95 为分离模型请求增加重试退避
瞬时请求失败时按递增毫秒延迟后重试

将重试循环末尾改为不可达断言
2026-09-12 02:07:02 +08:00
k88936 d7776f2a17 修正文生绑定提示语法
改进分离要求和返工建议英文表述
2026-09-12 02:05:18 +08:00
k88936 4d9e69841e 加固分离提示词生成
绑定提示改用切片参数避免多余复制

清理提取提示中的描述与返工备注文本
2026-09-12 02:04:32 +08:00
k88936 49e88bbd9f 统一分离提示备注长度限制
复用模型层的重做备注字符上限

导出提示文本清理函数供投影复用
2026-09-11 21:55:15 +08:00
k88936 86c268eca3 分离恢复使用独立丢弃操作
新增独立的恢复状态丢弃入口

完成与 finalize 的共享状态删除逻辑
2026-09-11 21:54:17 +08:00
k88936 c86221e3da 添加 TODO 注释以提示恢复字符限制错误信息
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 3m3s
Project CI / Native shell tests (pull_request) Failing after 14m57s
2026-09-11 20:12:16 +08:00
k88936 e7af7cf4e4 校验处理图区域并明确 multipart 字节上传
将处理图真实尺寸传入视觉绑定校验,提前拒绝零尺寸和越界区域。

保持非法区域直接失败,不转换为 NeedRework。

将 image 和 mask multipart 部分改为 Part::bytes。
2026-09-11 20:11:11 +08:00
k88936 e7cd008d7c 调整文本组件的识别规则
简化多行文本节点逻辑,明确文字与图片组件的绑定要求。
2026-09-11 20:06:09 +08:00
k88936 c743ca146e 复用图像下载的共享字节缓冲
将 DownloadedImage.bytes 改为 bytes::Bytes。

让远程下载和图标切片下游避免不必要的完整复制。

同步更新图像处理实现与测试 fixture。
2026-09-11 19:53:14 +08:00
k88936 8c8b6cc75a 将自动切分状态写盘移出 Tokio worker
用 spawn_blocking 承载 JSON 序列化和文件写入,并在工作流中等待结果。
2026-09-11 19:44:01 +08:00
k88936 4cf3642b53 说明视觉绑定解析错误的有限重试策略
记录严格工具 schema 和响应损坏重试边界。
2026-09-11 19:41:48 +08:00
k88936 f933db169e 说明结构化重试的有限上下文边界
记录现役调用方的小重试次数和保留完整反馈的设计依据。
2026-09-11 19:41:21 +08:00
k88936 a5e936dd27 清理已退役的前端绑定模块
删除无现役导入的 binding.ts 及其 BindingDTO、BindingChange 类型。
2026-09-11 19:39:59 +08:00
k88936 53008959c5 修正自动切分结果的类型收窄
在异步闭包赋值后明确已完成结果的非空类型。
2026-09-11 19:09:22 +08:00
k88936 57dbb3de52 替换已有组件前增加确认
使用独立确认弹窗避免一次点击覆盖已配置组件。
2026-09-11 19:07:12 +08:00
k88936 e189aff485 更新设计基础提示词契约测试
将测试断言同步到当前按需图片生成与动态产物合同。
2026-09-11 19:05:57 +08:00
k88936 248c094da9 清理合并命令测试中的无用导入
移除组件类型未再使用的测试模块导入。
2026-09-11 19:05:03 +08:00
k88936 e66eb2fb55 切换预览图片时自动适配画布
在活动图片变化后重新按完整画布边界计算视口。
2026-09-11 19:04:33 +08:00
k88936 d455dc18a9 按实际保存快照更新脏状态签名
保存成功后直接记录持久化快照签名,避免闭包中的旧编辑器状态阻止清脏。
2026-09-11 19:03:51 +08:00
k88936 04a0d21351 避免原始 PNG 的重复解析
使用解码后的颜色类型校验位深,将读取限制统一留在 image 解码器。
2026-09-11 19:03:03 +08:00
k88936 a9358bf3ce 防止字体前置校验访问空值
对外部状态中的空字体引用返回正常校验结果而不是抛出异常。
2026-09-11 19:00:49 +08:00
k88936 c3de2ce958 为自动切分命令增加项目写权限校验
在启动分离工作流前复用 asset.register 权限门禁。
2026-09-11 19:00:19 +08:00
k88936 287d2f94da 限制自动切分恢复状态读取大小
在解析 sidecar state 前检查文件大小,避免异常分配。
2026-09-11 18:59:51 +08:00
k88936 1343f487d0 为自动切分工作流增加忙碌保护
统一直接调用入口的并发防护,避免状态锁冲突。
2026-09-11 18:59:10 +08:00
k88936 73fb89a8f4 阻止本地素材登记结果错位回填
资源导入返回数量与请求路径不一致时立即中止位置映射。
2026-09-11 18:58:35 +08:00
k88936 bf2ffd2bf9 拒绝保存无可见像素的切分区域
透明裁切区域直接返回可恢复错误,避免登记空素材。
2026-09-11 18:58:13 +08:00
k88936 3f55f043a1 拒绝切分产物路径中的非法节点标识
在写入 cut 图片前限制节点 ID 字符并确认路径仍位于 sidecar 内。
2026-09-11 18:57:19 +08:00
k88936 26677b193c 复用界面树组件计数值
在同一行中复用组件数量,避免重复计算。
2026-09-11 18:56:13 +08:00
k88936 b8691add3a 移除区域归一化日志路径中的恐慌
直接记录归一化结果,避免诊断日志调用 expect。
2026-09-11 18:55:28 +08:00
k88936 bfe010a192 让视觉绑定调试预览写入失败可降级
调试 PNG 写入失败时记录警告并继续绑定流程。
2026-09-11 18:55:06 +08:00
k88936 6db6de5b99 同步检查器组件面板展开状态
切换节点或组件时重置展开状态,避免复用旧节点的折叠状态。
2026-09-11 18:54:39 +08:00
k88936 87a7294a04 细化组件绑定载荷形状校验
在反序列化前拒绝空值和无效的节点组件外部枚举。
2026-09-11 18:54:21 +08:00
k88936 3774d7c1e1 移除修复重试流程中的隐式恐慌
在循环意外结束时返回可恢复错误而不是触发 unreachable。
2026-09-11 18:53:34 +08:00
k88936 8d15125f12 限制切分提示词中的节点备注
对用户备注清理控制字符和围栏符号并限制长度。
2026-09-11 18:52:59 +08:00
k88936 cf68b8212d 让提取提示词序列化错误可恢复
将提取提示词生成改为返回带上下文的错误。
2026-09-11 18:52:10 +08:00
k88936 8d7ccc0d75 简化工作流操作卡状态映射
使用步骤映射替代嵌套三元表达式。
2026-09-11 18:51:30 +08:00
k88936 2af3d9a965 修正结构识别步骤的前置校验
将结构识别活动步骤改为校验素材切分前置条件。
2026-09-11 18:50:59 +08:00
k88936 4749339bad 补齐图片字节类型导出与转换
Project CI / Repository checks (pull_request) Failing after 31s
Project CI / Backend tests (pull_request) Failing after 13s
Project CI / Frontend tests (pull_request) Successful in 3m56s
Project CI / Native shell tests (pull_request) Failing after 3m33s
导出共享 GPT 图片尺寸阈值常量。

修复编辑器参考图 Bytes 与 Vec 边界转换。
2026-09-11 18:02:04 +08:00
k88936 3e85c71060 整理图片代理代码格式
按 Rust 格式化规范整理 multipart 与响应解析代码。
2026-09-11 17:55:50 +08:00
k88936 da19bde99a 同步八位 PNG 与 b64 契约
记录八位 PNG 校验规则与稳定错误文案。

说明 GPT-Image-2 原生 b64_json,不发送 response_format。
2026-09-11 17:52:26 +08:00
k88936 4a32ee37c4 修复 Bytes 迁移后的图片类型边界
统一使用 Bytes 的只读引用并在旧 Vec 接口处显式转换。

修复编辑器参考图对齐与 Raw PNG 解码编译错误。
2026-09-11 17:52:00 +08:00
k88936 31fd1da495 修正 GPT 图片响应契约说明
仅保留 GPT-Image-2 原生 b64_json 行为的行内注释。

不发送 response_format 参数,也不引入 URL 兼容下载。
2026-09-11 17:48:55 +08:00
k88936 4c88e5e924 限制 Raw 图片仅接收八位 PNG
使用 png 解码器读取位深并在 image 解码前拒绝非八位输入。

统一返回稳定的 8-bit PNG 客户端错误并补充十六位 PNG 测试。
2026-09-11 17:48:01 +08:00
k88936 99f4961c5f 统一 GPT 图片尺寸计费阈值
提取共享的 1536 长边 tier 常量并复用到 raw 与编辑器计费。

同步 Raw 图片代理技术合同中的阈值来源。
2026-09-11 17:47:31 +08:00
k88936 0cebc39b6a 同步 Raw 图片代理契约
记录文本字段 16KiB 流式限制。

记录 GPT-Image-2 固定 b64_json 响应格式。
2026-09-11 17:37:58 +08:00
k88936 842d080a75 锁定图片缓冲依赖
将 platform-image 使用的 bytes 依赖写入 Cargo.lock。
2026-09-11 17:37:32 +08:00
k88936 8cd6e34af0 调整图片切分批次请求尺寸计算逻辑
基于批次源矩形总面积动态计算 image-edit 请求尺寸,新增面积对齐和最小/最大值限制,扩展相关模块和测试以支持调整后的工作流。
2026-09-11 17:33:26 +08:00
k88936 b357d36262 明确 GPT 图片编辑响应格式
原始图片编辑请求固定声明 response_format=b64_json。

补充 GPT-Image-2 仅返回 b64_json 的契约行内注释。
2026-09-11 17:29:11 +08:00
k88936 48c5638893 扩大原始图片文本字段上限
multipart 文本字段改为 chunk 流式读取并限制 16KB。

统一 UTF-8 校验和超限错误,避免先完整分配超长 prompt。
2026-09-11 17:28:13 +08:00
k88936 46df12c086 收敛原始图片 multipart 错误
服务端记录解析原始错误,客户端仅返回稳定分类文案。
2026-09-11 17:26:33 +08:00
k88936 4bdbab29c0 优化原始图片请求缓冲
将 ReferenceImage 与 multipart 输入改用 bytes::Bytes。

通过流式 multipart part 避免 reqwest 路径的额外整图复制。
2026-09-11 17:25:25 +08:00
k88936 9acc23b848 抽离 DFS 批次逻辑至独立模块,并优化节点面积计算与终端过滤流程
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 8m16s
Project CI / Native shell tests (pull_request) Failing after 11m7s
2026-09-11 15:34:30 +08:00
k88936 b9b4ebd38e 重命名图片编辑为提取模块并更新相关调用绘制流程
Project CI / Repository checks (pull_request) Failing after 16s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Native shell tests (pull_request) Failing after 4m22s
Project CI / Frontend tests (pull_request) Successful in 11m36s
2026-09-11 15:18:05 +08:00
k88936 8f680ef376 视觉绑定增加透明标记预处理
新增视觉绑定 RGBA 预处理与阈值复用

在请求前生成不透明洋红标记图并记录耗时

更新英文提示词说明标记色语义
2026-09-11 15:09:44 +08:00
k88936 7c7d55dcab 重构提取提示词生成逻辑,移除文本拼接方式,新增 YAML 序列化结构与测试 2026-09-11 14:54:00 +08:00
k88936 1303592a86 重构UI编辑器素材切分工作流模块
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 5m17s
Project CI / Native shell tests (pull_request) Failing after 6m41s
拆分提取与绑定提示词模块

拆分图片编辑、视觉绑定、裁切和批次 patch 实现

同步技术方案实现组织说明并更新提示词测试
2026-09-11 13:54:33 +08:00
k88936 1db7597141 重构UI素材切分树与批次选择
移除文本遮罩和标记图生成流程,图片编辑直接读取原始界面图

引入节点类型并保留文字移除上下文,按前序DFS与面积预算选择图片批次

补充根节点、重叠节点、文字过滤和超面积推进测试并同步TypeScript类型
2026-09-11 12:55:53 +08:00
k88936 13701d0144 澄清UI自动切分的原图输入与调试产物
明确图片编辑直接使用原始界面图,不再生成辅助输入图

明确处理图与裁切图使用随机文件名并保留用于调试
2026-09-11 11:56:33 +08:00
k88936 5c83142fec 更新UI编辑器自动切分素材工作流方案
将多轮整图分层与DFS面积批次写入权威专题

明确TextRemovalOnly、视觉绑定和atlas输出合同

删除平行专题文档并保留后续TODO

补充UI编辑器自动分离多轮分层方案

新增整图语义分层与多轮 image-edit 方案

明确 DFS 批次、TextRemovalOnly 和视觉绑定合同

记录面积预算、恢复边界与后续 TODO
2026-09-11 11:10:51 +08:00
k88936 95ed49f264 调整素材切分边界像素上限
将视觉绑定区域每条边的调整上限改为固定 32px。

同步 UI 编辑器自动切分技术方案与项目决策记录。

更新边界测试以覆盖绝对像素限制。
2026-09-11 10:28:32 +08:00
k88936 b8d8072267 完善识别命令说明,新增禁止冗余背景节点的指引
Project CI / Repository checks (pull_request) Failing after 9s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 2m44s
Project CI / Native shell tests (pull_request) Failing after 3m5s
2026-09-10 19:54:46 +08:00
k88936 462caa33c5 修复工作流完成弹窗的多行错误展示
让完成通知中的换行字符按实际换行渲染,避免多项回填错误挤成一行。

保持通知内容和弹窗交互不变。
2026-09-10 19:06:20 +08:00
k88936 4e1064266f 移除自动切分结果的冗余类型断言
依赖空值检查后的 TypeScript 类型收窄直接使用 SeparationDTO。

不改变自动切分流程或运行时行为。
2026-09-10 19:05:48 +08:00
k88936 a50cbfb6c8 过滤图片编辑响应中的空图像数据
忽略上游返回的空 b64_json 条目,避免把空字符串转发为图像结果。

新增空条目与有效条目混合响应的回归测试。
2026-09-10 19:04:40 +08:00
k88936 1eb4bd5ec0 明确拒绝无效的处理图数据地址
处理图缺少 data URL 分隔符时直接返回格式错误。

避免先写入空文件再在后续裁切阶段暴露误导性错误。
2026-09-10 19:03:29 +08:00
k88936 5b441d389c 忽略完全位于图片外的切分标记矩形
矩形起点超出图片边界时直接返回 None,避免在边缘绘制伪影。

新增越界矩形回归测试。
2026-09-10 19:02:40 +08:00
k88936 f200cb4d3c 避免标记图编码重复复制像素缓冲
复用同一个 DynamicImage 完成文件保存和返回数据编码。

保持标记图内容和错误处理不变。
2026-09-10 19:02:09 +08:00
k88936 ae2f5fc80b 记录 UI 编辑器重试中的请求错误
在结构化 LLM 请求的中间重试失败时写入尝试次数和错误日志。

保留原有重试次数、历史消息和最终错误语义。
2026-09-10 19:01:32 +08:00
k88936 b69bd88e5e 修正 UI 编辑器校验器命名
将 run_with_repair_history 的 Validater/validater 更正为 Validator/validator。

不改变重试流程和运行时行为。
2026-09-10 19:01:18 +08:00
k88936 c5c7339c4a 重命名分离模块 problem_descriptionadvice 并同步更新相关校验逻辑与测试
Project CI / Repository checks (pull_request) Failing after 13s
Project CI / Backend tests (pull_request) Failing after 9s
Project CI / Frontend tests (pull_request) Successful in 2m28s
Project CI / Native shell tests (pull_request) Failing after 14m32s
2026-09-10 18:54:10 +08:00
k88936 4bbc77fc32 增加UI自动切分耗时日志
补充 marker、area、LLM、图片编辑及 batch 阶段耗时观测
记录成功与失败路径的性能字段
同步自动切分工作流技术方案中的日志约定
2026-09-10 18:51:53 +08:00
k88936 8c521ca891 移除 UI 预览适配与缩放输入
删除预览工具栏适配按钮、适配回调与对应快捷键
将缩放百分比改为只读显示并移除输入组件及测试
2026-09-10 18:48:56 +08:00
k88936 69a0804c03 调整切分区域边界扩展上限
将像素边界每边调整上限常量设为百分之百

同步更新受影响的区域归一化测试

技术方案仅引用上限常量,不重复写死数值
2026-09-10 18:46:39 +08:00
k88936 74f726e65d 修正自动切分素材检查条件
移除自动切分对预先导入独立素材的错误要求。
统一自动切分前置与结果检查,并补齐图片和字体引用校验。
在新建和重新开始自动切分时执行前置检查,恢复流程继续尽力完成。
2026-09-10 18:43:31 +08:00
k88936 1509235c1b 统一自动切分素材工作流命名
将 UI 编辑器第三步和内部流程 ID 统一为自动切分素材。
重命名前端切分概览模块并更新完成、恢复和导航文案。
同步 Runtime 最终编辑器路由、测试与相关技术文档。
2026-09-10 15:11:29 +08:00
k88936 1c992c69fe 完善分离与识别命令说明,调整嵌套格式与结构化指引 2026-09-10 14:05:37 +08:00
k88936 d9b153ed78 完善分离命令说明,新增禁止未请求文本的指引 2026-09-10 13:15:42 +08:00
k88936 30c469e9a1 规范分离模块格式化写法 2026-09-10 13:15:34 +08:00
k88936 51f629b2f9 UI编辑器节点改为单组件模型
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Frontend tests (pull_request) Successful in 2m43s
Project CI / Native shell tests (pull_request) Failing after 14m29s
修改 Node、Binding DTO、识别与分离链路为 component 单字段

为识别和绑定 LLM 工具引入 PureNode/WithComponent 显式载荷

移除前端组件索引、排序和组件栈操作

同步生成 ts-rs TypeScript 类型、状态校验、测试与专题文档
2026-09-10 13:08:29 +08:00
k88936 d6c720ecdd 纠正分离模块导出提交边界
撤销误入的组件字段重命名测试改动

仅保留裁切工作流对面积归一化模块的直接依赖
2026-09-10 12:26:39 +08:00
k88936 086aa91d70 收窄分离区域模块导出
让裁切工作流直接依赖面积归一化模块

移除未使用的公共重导出,保持分离模块边界清晰
2026-09-10 12:24:18 +08:00
k88936 3733e86272 补充分离区域像素归一化约定
记录透明像素边界扫描、方向锁定与四边同步推进规则

明确 50% 与图像边界约束、透明图处理、日志字段和性能 TODO
2026-09-10 12:13:21 +08:00
k88936 5d0f3e6be6 UI编辑器分离区域像素边界归一化
新增独立 BindingArea 像素边界归一化模块与回归测试

在 cut 裁切前按透明像素收缩或扩展四条边并记录约束结果

接入分离工作流并保留原始与归一化区域日志
2026-09-10 12:13:04 +08:00
k88936 989440173f 完善绑定区域值类型约束
为 BindingArea 增加 Eq 以支持分离区域比较
2026-09-10 11:52:46 +08:00
k88936 22d9958d18 在分离标记图中遮罩普通文字
绘制文字紫色区域并保持绿色元素框在最上层

增加文字遮罩图层顺序测试
2026-09-10 10:57:50 +08:00
k88936 56f8c9a6a1 构造自动分离文字遮罩
按最近未绑定图片祖先收集 Text 布局像素矩形

补充嵌套图片与根图片遮罩构造测试
2026-09-10 10:49:45 +08:00
k88936 c84df3d88f 补充文字遮罩状态字段契约
明确 text_mask_areas 为当前 separation state 必选字段

保持开发阶段 v1 且不提供旧 sidecar 迁移回退
2026-09-10 10:49:07 +08:00
k88936 761d32cebf 拆分自动分离模型并增加文字遮罩区域
将 separation model 拆为 note、node、binding、result 模块

为 SeparationNode 增加 text_mask_areas 字段并同步 TypeScript 类型
2026-09-10 10:43:00 +08:00
k88936 b3d6543d73 补充自动分离文字遮罩方案
记录普通文字归属、遮罩字段与标记图绘制规则

明确不进入分离树、绑定结果和视觉模型契约
2026-09-10 10:32:34 +08:00
k88936 8cd7c43b9e 更新自动分离接入文档状态
将前端接入 TODO 更新为联调与失败注入测试待办。
2026-09-09 21:02:09 +08:00
k88936 7fb7d246c0 将视觉步骤切换为自动分离
前端仅调用一次 separate_ui,并完成 cut 图片登记、SpriteAsset 回填和 State 保存。

增加 sidecar 恢复选择面板,旧 bind_components 标记为未调用遗留命令。
2026-09-09 21:00:53 +08:00
k88936 5844afa14d 抽取自动分离素材状态变换
复用 SpriteAsset 校验并支持锁内构造下一份 State。

保留公开 addSpriteAssets 的锁保护与历史提交行为。
2026-09-09 20:17:11 +08:00
k88936 615d1a28cd 补齐自动分离恢复状态胶水
新增 separation 恢复探测、完成清理命令与 DTO。

持久化项目相对 cut 图片路径并保留 state sidecar 到最终提交。
2026-09-09 20:16:09 +08:00
k88936 3e1e172f9c 补充自动分离前端接入合同
明确 UI 编辑器单次调用 separation 与 sidecar 恢复弹窗

补充资源登记、State 回填、保存和 finalize 顺序

划定旧 binding 与 Runtime workflow 的本次不改范围
2026-09-09 20:03:27 +08:00
k88936 53a919e39b 优化 UI 分离工作流程的提示生成与历史处理
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Frontend tests (pull_request) Successful in 2m50s
Project CI / Native shell tests (pull_request) Failing after 3m4s
- 调整 initial_history 构建逻辑,增强系统与用户消息的一致性。
- 简化 SeparationNode 提示生成逻辑,仅保留节点 ID 与注释。
- 明确 extracted_area 的权威性为 processed 图像,并更新生成提示的规则。
2026-09-09 19:04:56 +08:00
k88936 d4b5f9fc14 重构 UI Editor LLM repair history
将 request_with_feedback 改为 run_with_repair_history 并统一 max_retries 与 validater 命名。

让 requester 接收 append-only LlmMessage history,业务校验失败追加序列化响应和错误反馈。

迁移 visual_binding 调用方并补充 retry-only 与业务反馈 history 测试。

同步 UI Editor 结构化请求 repair history 决策文档。
2026-09-09 16:46:29 +08:00
k88936 6e4f9a6f1f 完善 UI 自动分离返工意见链路
记录视觉模型 NeedRework 意见并注入后续提取提示

同步返工次数、problematic 终态和 512 字符校验

补充 separation DTO 类型、回归测试与技术方案
2026-09-09 16:29:54 +08:00
k88936 8a0dcf8be7 增强分离标记框的可视辨识度
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 3m4s
Project CI / Native shell tests (pull_request) Failing after 4m38s
为分离标记框增加两条绿色角到角交叉线。

新增 MARKER_LINE_WIDTH 常量统一配置标记线宽,并确保绘制结果裁剪在矩形内。

补充标记框像素级回归测试并同步更新自动分离专题文档。
2026-09-09 16:24:11 +08:00
k88936 aa2a78f7e0 重命名 separated_image_area 为 extracted_area,优化命名一致性并明确区域含义 2026-09-09 15:48:32 +08:00
k88936 7aa96e8438 统一分离标记图中文注释
说明紫色重建与绿色框绘制层级
2026-09-09 15:16:39 +08:00
k88936 feb6bc0ad4 修正分离失败恢复边界
图片编辑、写入和裁切失败保留状态并返回错误
仅视觉模型返工结果进入 problematic
2026-09-09 15:07:49 +08:00
k88936 f349350d60 同步分离状态 TypeScript 类型
加入 root_extractable 并将树字段统一为 trees
2026-09-09 15:03:48 +08:00
k88936 df3a172bc9 补充 Raw GPT Image 2 multipart 合同
明确分离图片编辑请求字段与旧协议边界
2026-09-09 14:57:55 +08:00
k88936 9b4924c73e 补充分离批次重叠筛选测试
验证 DFS 顺序下贪心跳过重叠叶节点
2026-09-09 14:54:37 +08:00
k88936 d30bc462c5 格式化自动分离 Rust 模块
统一树选择、标记图和批次流程代码风格
2026-09-09 14:50:19 +08:00
k88936 26b9ad7fad 重构分离树与非重叠批次选择
保留真实根节点并记录 root_extractable
按终态反查和 DFS 贪心筛选逻辑叶
拆出父子区域标记图生成模块
2026-09-09 14:48:18 +08:00
k88936 bc5398894e 补充分离树与批次算法约定
明确真实根节点、逻辑叶和非重叠贪心选择
补充父节点紫色重建与错误恢复边界
2026-09-09 14:29:38 +08:00
k88936 11d4d3d930 适配 UI 分离图片编辑 multipart 接口
Project CI / Frontend tests (pull_request) Successful in 4m57s
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / Backend tests (pull_request) Failing after 11s
Project CI / Native shell tests (pull_request) Failing after 5m40s
将标记图 data URL 解码为 PNG 文件部件。

按 Raw GPT Image 2 新合同发送 prompt、尺寸和输出参数。

保留响应 data[].b64_json 解析与 separation 流程不变。
2026-09-09 13:17:36 +08:00
k88936 418d5732de 调整UI识别指令,细化粒度要求并优化组件返回规则 2026-09-09 13:12:51 +08:00
k88936 592b6b4ee7 简化识别树验证测试中的断言格式 2026-09-09 13:12:51 +08:00
k88936 99c19e3ed9 补充分离流程排障日志
记录 separation sidecar 状态读写与恢复阶段

记录树构造、批次选择、视觉绑定、裁切和 patch 结果

避免输出 base64、完整提示词和敏感凭据
2026-09-09 13:12:51 +08:00
k88936 15e30acb0f 调整UI识别指令细节,明确文字组件识别规则与粒度标准 2026-09-09 13:12:51 +08:00
k88936 56fff8325b 将自动分离图像处理移出异步执行器
在 spawn_blocking 中构建标记图并编码写入处理图

在 spawn_blocking 中完成处理图裁切与文件输出

保留 image-edit 和视觉绑定网络请求的 async 调度边界
2026-09-09 13:12:51 +08:00
k88936 884c5ec5ee 补充自动分离 sidecar 并发边界约束
记录前端单次运行与 runWithStateLocked 的并发前提

明确 sidecar 不参与正式资产写入和项目 revision

补充未来多窗口多进程场景的进程级锁 TODO

记录图像本地处理使用 spawn_blocking 的执行边界
2026-09-09 13:12:51 +08:00
k88936 207b0820dd 统一分离树文件格式
按仓库 rustfmt 规范整理 synthetic root 实现
2026-09-09 13:12:51 +08:00
k88936 19f3d62d78 隔离非法分离区域导致的批次失败
将裁切错误记录为 problematic 并继续流程
避免单个模型区域终止整页分离
2026-09-09 13:12:51 +08:00
k88936 3c1e7bd599 保留分离问题节点的真实重做次数
避免基础设施失败伪造达到上限
保持 problematic 节点诊断信息准确
2026-09-09 13:12:51 +08:00
k88936 dda6b3946a 阻止识别结果引用未授权字体素材
补齐识别阶段字体引用校验
增加伪造字体绑定回归测试
2026-09-09 13:12:51 +08:00
k88936 aff40f794d 修复分离树合成根节点 ID 冲突
避免单图根节点重复进入重做计数
补充根图片构造回归测试
2026-09-09 13:12:50 +08:00
k88936 187faa607d 保留原始分离提示并拆分模块
按模型、树、持久化、提示词和工作流拆分 separation

提取支持 more_turn 的反馈重试 harness

删除旧 separation.rs 文件
2026-09-09 13:12:50 +08:00
k88936 109cc81740 拆分UI自动分离命令模块
保留原始图片分离与绑定提示词

提取模型、树、持久化和工作流子模块

新增可配置 more_turn 反馈重试 harness
2026-09-09 13:12:50 +08:00
k88936 f796aef7e2 完善UI自动分离批次处理
复用资源ID安全路径并修正像素坐标

加入标记图、Raw编辑、视觉绑定修复与问题节点继续处理
2026-09-09 13:12:50 +08:00
k88936 4cc7f4dd64 实现UI自动分离命令
新增分离树、批次处理与sidecar状态

接入Raw GPT Image 2与视觉绑定重试

注册Tauri命令并补充识别组件草稿
2026-09-09 13:12:50 +08:00
k88936 b2d4690f94 补充UI编辑器自动分离工作流合同
新增自动分离、临时 sidecar 与视觉绑定设计合同

明确前端资产登记职责与恢复 TODO
2026-09-09 13:12:50 +08:00
k88936 0400103a19 将 Raw 图片编辑入站改为 multipart
移除 JSON/base64 入站兼容,仅接受 multipart 图片与参数字段

复用扣费前 PNG、尺寸、mask 和 prompt 校验并补充 multipart 测试

优化上游图片字节转发,避免再次克隆 image bytes

同步 Raw 图片编辑技术方案与 Axum multipart 依赖
2026-09-09 13:06:22 +08:00
k88936 c049d68b8e 收紧 Raw 成功响应字段类型
要求 data 与 b64_json 必填并移除无用 provider id

prompt 上限调整为 4 KiB 原始字节并同步文档
2026-09-09 12:03:03 +08:00
k88936 acfcf0c158 同步 platform-image 的 serde 锁定依赖
为 Raw typed 响应记录 serde workspace 依赖
2026-09-09 11:51:25 +08:00
k88936 5bbedd9a5c 限制 Raw prompt 原始字节大小
将 prompt UTF-8 原始字节限制为 16 KiB

补充超限回归测试并同步请求合同
2026-09-09 11:50:30 +08:00
k88936 40316d82c4 在扣费前校验 Raw mask 尺寸
解码时保留 image 与 mask 宽高并拒绝不一致输入

同步 Raw 图片编辑请求合同与回归测试
2026-09-09 11:45:44 +08:00
k88936 6c77de4a36 为 Raw 成功响应收紧类型透传
使用 typed JSON DTO 提取并原样转发 b64_json

不解码图片内容且忽略 output_format 回显
2026-09-09 11:44:31 +08:00
k88936 b3693765ef 透传 Raw 图片结果避免解码回显字段
仅转发上游 data.b64_json 并忽略 output_format

同步 Raw 技术方案并补充不解码回归测试
2026-09-09 11:34:41 +08:00
k88936 f7edc9d0ee 区分 Raw 图片 PNG 资源限制错误
Project CI / Frontend tests (pull_request) Successful in 4m43s
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Native shell tests (pull_request) Failing after 5m14s
将有效但超出解码限制的 PNG 映射为明确的 400 提示

补充超大合法 PNG 的回归测试
2026-09-09 11:04:44 +08:00
k88936 f60771dd00 提前检查 Raw 图片请求预算
在构造 multipart 表单前校验请求 deadline

避免预算耗尽时复制输入图片并缩短耗时统计范围
2026-09-09 10:58:48 +08:00
k88936 f7cccd8592 补充 Raw 图片客户端错误上下文
为 HTTP 客户端构造失败统一保留操作上下文

补充配置错误文案回归测试
2026-09-09 10:57:04 +08:00
k88936 5ee2d940c1 修正 Raw 图片尺寸校验错误语义
尺寸校验失败改用请求参数无效语义

补充错误文案回归测试
2026-09-09 10:55:36 +08:00
k88936 c75a7725ce Merge remote-tracking branch 'origin/master' into feat/expose-image2edit
Project CI / Repository checks (pull_request) Successful in 2m51s
Project CI / Native shell tests (pull_request) Failing after 4m9s
Project CI / Backend tests (pull_request) Failing after 4m58s
Project CI / Frontend tests (pull_request) Successful in 3m46s
2026-09-09 10:42:22 +08:00
k88936 3a95715990 同步 Raw 图片编辑技术方案
Project CI / Native shell tests (pull_request) Failing after 6m36s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Successful in 4m22s
记录解码资源上限和阻塞线程策略
补充输出格式回退与成功追踪约定
2026-09-08 23:41:27 +08:00
k88936 ed86963de2 修正 Raw 图片追踪结果类型
明确输出数据集合类型
保持 API 编译检查通过
2026-09-08 23:38:25 +08:00
k88936 65e73eee02 补充 Raw 图片生成成功追踪
记录成功任务与输出数量
完善上游响应和失败阶段日志
2026-09-08 23:25:47 +08:00
k88936 6068eeda83 补充 Raw 图片编辑请求日志
记录上游响应状态与耗时
记录传输失败阶段和结构化上下文
2026-09-08 23:22:56 +08:00
k88936 0e244c64ea 统一 GPT Image 2 尺寸常量
集中维护像素边界和对齐规则
供生成与编辑路径共同引用
2026-09-08 22:11:35 +08:00
k88936 ad7c059603 遵守 Raw 图片请求截止时间
发送前裁剪有效超时预算
预算耗尽时提前返回结构化错误
2026-09-08 21:54:22 +08:00
k88936 55d2a393d1 完善 Raw 图片尺寸错误类型
为公开错误实现 Error trait
支持通用错误链处理
2026-09-08 21:52:15 +08:00
k88936 e7f66ce950 修正 Raw 图片传输失败阶段标记
区分请求发送和响应读取失败
让错误详情准确反映故障阶段
2026-09-08 20:03:13 +08:00
k88936 35dcfea3ef 修正 Raw 图片输出格式回退
忽略空值后再使用载荷级格式
补充空字符串和 null 回归测试
2026-09-08 19:56:41 +08:00
k88936 cea8bf77fa 减少 Raw 图片编辑请求拷贝
移动 multipart 选项字段而非克隆
降低掩码和字符串的峰值内存
2026-09-08 19:52:13 +08:00
k88936 0136bfe564 移出 Raw 图片同步解码
将请求预校验放入阻塞线程
避免占用 Tokio 异步工作线程
2026-09-08 19:48:58 +08:00
k88936 22785b4d7b 限制 Raw 图片解码资源
为 PNG 解码设置边长和分配上限
避免压缩图片膨胀导致内存耗尽
2026-09-08 19:45:02 +08:00
k88936 a86a2ee4d2 简化 Raw 图片编辑响应类型
移除无必要的 JSON Value 转换
保持响应结构由类型系统校验
2026-09-08 19:32:55 +08:00
k88936 b22eae2726 收紧 Raw 图片编辑输入契约
Project CI / Frontend tests (pull_request) Successful in 3m51s
Project CI / Native shell tests (pull_request) Successful in 20m20s
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 14s
新增 3840 边长、16 像素对齐、3:1 比例和总像素范围校验

要求 image 与 mask 为可完整解码的 PNG 并在扣费前拒绝非法输入

将 Raw 路由 JSON body limit 提升至 64 MiB

同步 Raw 图片编辑技术方案和边界测试
2026-09-08 18:18:58 +08:00
k88936 35d0db6377 修复 Raw 图片失败审计与响应格式
Project CI / Frontend tests (pull_request) Successful in 6m7s
Project CI / Native shell tests (pull_request) Successful in 19m41s
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / Backend tests (pull_request) Failing after 9s
为 Raw provider 失败分支补齐结构化 failure audit 并接入 api-server 记录链

使用 VectorEngine 响应 output_format 生成返回图片 MIME 与扩展名

补充响应格式和审计字段定向测试并同步技术方案
2026-09-08 16:19:29 +08:00
k88936 f087ba3e2b 隔离 Raw 图片代理实现
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Frontend tests (pull_request) Successful in 36m40s
Project CI / Native shell tests (pull_request) Successful in 54m1s
移除对现有图片编辑 client 与 curl transport 的复用

将 Raw GPT Image 2 请求、multipart 构造和响应解析收敛到独立文件

保持现有 editor 图片链路代码不变
2026-09-08 13:54:31 +08:00
k88936 7fc1b841be 收口 Raw 图片 base64 校验错误
客户端仅返回稳定的 base64 格式错误提示

补充测试避免泄露解码器内部诊断细节
2026-09-08 12:30:55 +08:00
k88936 a576fdcc37 移除未使用的 multipart 请求包装函数
无选项测试直接调用统一传输入口

避免生产构建保留未使用函数告警
2026-09-08 12:29:59 +08:00
k88936 4dcf38715b 补充图片编辑选项 multipart 测试
覆盖质量、背景、输出格式与 mask 文件字段

断言文件名、MIME 类型和字节内容均正确发送
2026-09-08 12:21:11 +08:00
k88936 d1f9f4e1ef 减少图片编辑 multipart 字节复制
将已克隆的选项按值传入阻塞传输函数

构造 mask 与参考图表单时直接移动字节缓冲
2026-09-08 12:16:00 +08:00
k88936 5836aaec26 简化图片编辑 multipart 请求分支
统一通过带选项的 multipart 传输函数发送请求

移除冗余包装函数调用与未使用导入
2026-09-08 12:10:56 +08:00
k88936 18d60feb04 补充 Raw 图片参数预检查
在计费前校验质量、背景和输出格式

规范化可选参数并保持单图请求契约
2026-09-08 10:40:09 +08:00
k88936 4e1316e272 实现 Raw GPT Image 2 图片编辑代理
新增受 Bearer 保护的 /api/raw/v1/images/edit JSON 路由

按单图 image 与可选 mask 转发 GPT Image 2 参数

固定 model 与 n 并返回仅含 data[].b64_json 的响应

复用钱包计费与退款边界并补充单元测试
2026-09-08 10:36:48 +08:00
k88936 302b4addae 补充 Raw GPT Image 2 代理方案
Project CI / Native shell tests (pull_request) Successful in 55m40s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Frontend tests (pull_request) Successful in 23m43s
明确 JSON 请求与 data 数组响应

记录预检查和钱包事务边界

拆分 api-server 与 platform-image 文件职责
2026-09-07 16:33:34 +08:00
186 changed files with 7534 additions and 4960 deletions
+87 -202
View File
@@ -27,26 +27,9 @@ env:
RUSTC_WRAPPER: ''
CARGO_BUILD_RUSTC_WRAPPER: ''
# job 声明顺序就是 runner 领取顺序,因此把最长尾的客户端 Rust 门禁排在前面,
# 让它在最少的等待下占用并发槽位;其余 job 按时长递减排列。
#
# 客户端(微信壳 / Expo 移动壳 / Tauri 桌面壳 / AI 游戏创作壳)门禁原先全部串在
# `Native shell tests` 一个 job 里,实测 18 分 37 秒。现在按门禁组拆成三个 job:
# `Native shell tests`(契约 + H5 / 微信 / 移动 / 桌面壳门禁 + 发布构建 smoke)、
# `AI game creator shell web tests`typecheck + 壳内测试)与
# `AI game creator shell Rust tests`AGC 壳 bin 单测分片并行 + agent-run smoke),
# 再把 AGC 壳依赖的共享 / 平台 crate 测试拆成 `AI game creator shell Rust crates`。
# 各自的命令与拆分前逐一对应,本地 `npm run check:native-shells` 仍是同一条串行序列。
#
# AGC 壳的 bin 单测(2466 条)按名单分 4 片、每片一个进程并行执行,片内保持
# `--test-threads=1`:当年线程并行会互相干扰的是进程内后台锁与异步终态,进程分片
# 天然隔离,每片另有独立 TMPDIR,因此不必再让整套用例串成一小时级的尾巴。
jobs:
# 客户端 AGC 壳自身的 Rust 门禁:bin target 单测按名单分 4 片并行(片内仍保持
# `--test-threads=1`)加 agent-run smoke。这里不装 npm 依赖:壳 Rust 门禁与 smoke
# 只用 cargo 与 node 内建模块,也只需要 AGC 壳自己那份锁定依赖。
ai-game-creator-shell-rust-tests:
name: AI game creator shell Rust tests
repository-checks:
name: Repository checks
runs-on: genarrative-ci
steps:
- name: Checkout full history from Gitea
@@ -58,94 +41,76 @@ jobs:
- name: Validate preinstalled CI job image and sandbox
run: GENARRATIVE_GITEA_CI_CHECK_RUNTIME=1 bash scripts/check-gitea-ci-job-image.sh
- name: Prepare AI game creator shell Rust dependencies
- name: Resolve comparison base
shell: bash
run: |
set -euo pipefail
# AGC 壳有独立 Cargo.lock,其 path 依赖已含 platform-llm、platform-agent、
# agent-runtime-core 与 shared-contracts,因此只锁这一份 manifest 就能覆盖壳测试
# 与 smoke 的全部第三方依赖;server-rs 那次预热归 crate 级 job,不在这里重复。
for attempt in $(seq 1 5); do
if cargo fetch --locked \
--target x86_64-unknown-linux-gnu \
--manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml; then
break
fi
if [[ "${attempt}" -eq 5 ]]; then
echo 'AI game creator shell Cargo dependency fetch failed after 5 attempts.' >&2
base_ref="$(node -e '
const fs = require("node:fs");
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
process.stdout.write(event.pull_request?.base?.sha ?? event.before ?? "");
')"
if [[ -n "${base_ref}" && ! "${base_ref}" =~ ^0+$ ]]; then
git cat-file -e "${base_ref}^{commit}" 2>/dev/null || {
echo "comparison base commit is unavailable: ${base_ref}" >&2
exit 1
fi
sleep $((attempt * 2))
done
}
else
base_ref="$(git merge-base HEAD origin/master 2>/dev/null || git rev-parse HEAD)"
fi
resolved_base_ref="$(git rev-parse --verify "${base_ref}^{commit}" 2>/dev/null || true)"
head_ref="$(git rev-parse HEAD)"
if [[ "${resolved_base_ref}" == "${head_ref}" ]]; then
resolved_base_ref="$(git rev-parse --verify HEAD^ 2>/dev/null || true)"
fi
if [[ -z "${resolved_base_ref}" ]]; then
echo 'comparison base must resolve to a commit distinct from HEAD.' >&2
exit 1
fi
base_ref="${resolved_base_ref}"
if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]] \
&& ! git merge-base --is-ancestor "${base_ref}" HEAD; then
echo 'pull request head does not contain the latest base commit; update the branch and rerun CI.' >&2
exit 1
fi
echo "SPACETIME_SCHEMA_BASE_REF=${base_ref}" >> "${GITHUB_ENV}"
- name: Run AI game creator shell Rust gates
run: npm run check:native-shells:agc-rust-shell
- name: Install npm dependencies
run: bash scripts/ci-npm-ci-with-retry.sh
# AGC 壳依赖的共享 / 平台 crate 测试用的是 server-rs workspace 与两个无锁独立 crate
# 的 manifest,属另一套依赖图,因此单独一个 job 预热、单独跑。
ai-game-creator-shell-rust-crates:
name: AI game creator shell Rust crates
- name: Run repository checks
run: npm run check:repository-ci
frontend-tests:
name: Frontend tests
runs-on: genarrative-ci
steps:
- name: Checkout full history from Gitea
- name: Checkout source from Gitea
env:
GENARRATIVE_GITEA_FETCH_DEPTH: '0'
GENARRATIVE_GITEA_FETCH_DEPTH: '1'
GENARRATIVE_GITEA_TOKEN: ${{ github.token }}
run: genarrative-gitea-checkout
- name: Validate preinstalled CI job image and sandbox
run: GENARRATIVE_GITEA_CI_CHECK_RUNTIME=1 bash scripts/check-gitea-ci-job-image.sh
- name: Prepare server-rs Rust dependencies
shell: bash
run: |
set -euo pipefail
for attempt in $(seq 1 5); do
if cargo fetch --locked \
--target x86_64-unknown-linux-gnu \
--manifest-path server-rs/Cargo.toml; then
break
fi
if [[ "${attempt}" -eq 5 ]]; then
echo 'server-rs Cargo dependency fetch failed after 5 attempts.' >&2
exit 1
fi
sleep $((attempt * 2))
done
- name: Install npm dependencies
run: bash scripts/ci-npm-ci-with-retry.sh
- name: Prepare standalone Rust crate dependencies
shell: bash
run: |
set -euo pipefail
# agent-runtime-core / agent-runtime-orchestration 被 server-rs/Cargo.toml 的
# exclude 排除,不参与上面的 workspace 锁文件,因此上面那次锁定 fetch 覆盖不到它们;
# 而 `npm run ai-game-creator-shell:check:rust:crates` 会用
# `cargo test --manifest-path` 单独跑这两个 crate。不在这里预热的话,这两条测试
# 会在测试阶段自己 `Updating crates.io index`crates.io 一抖动整条 job 就红
# (见 #327 / PR #316 run 1950)。
# 两个 crate 都没有提交 Cargo.lock,所以这里只能做不带锁标志的 fetch:
# 加锁标志会因为缺少锁文件直接失败。生成的 Cargo.lock 落在两个 crate 目录内,
# 已被各自的 .gitignore 忽略,只留在容器里;随后的测试阶段因此能用锁定版本
# 解析,不再触碰 registry index。
for manifest_path in \
server-rs/crates/agent-runtime-core/Cargo.toml \
server-rs/crates/agent-runtime-orchestration/Cargo.toml; do
for attempt in $(seq 1 5); do
if cargo fetch \
--target x86_64-unknown-linux-gnu \
--manifest-path "${manifest_path}"; then
break
fi
if [[ "${attempt}" -eq 5 ]]; then
echo "standalone crate dependency fetch failed after 5 attempts: ${manifest_path}" >&2
exit 1
fi
sleep $((attempt * 2))
done
done
- name: Run frontend and script tests
run: npm run test
- name: Run AI game creator shell shared crate gates
run: npm run check:native-shells:agc-rust-crates
- name: Run BgFilter worker smoke harness tests
run: npm run bgfilter-worker:smoke-test
- name: Validate production health patrol behavior
run: npm run check:production-health-patrol
- name: Validate production API release behavior
run: npm run check:production-api-release
- name: Validate production API deploy behavior
run: npm run check:production-api-deploy
backend-tests:
name: Backend tests
@@ -229,8 +194,6 @@ jobs:
- name: Check SpacetimeDB module
run: cargo check --locked -p spacetime-module --manifest-path server-rs/Cargo.toml
# 客户端的壳级与契约门禁:静态契约断言、H5 / 微信 / 移动 / 桌面壳运行时门禁,
# 以及依赖发布产物的构建 smoke。
native-shell-tests:
name: Native shell tests
runs-on: genarrative-ci
@@ -252,6 +215,7 @@ jobs:
run: |
set -euo pipefail
for manifest_path in \
server-rs/Cargo.toml \
apps/desktop-shell/src-tauri/Cargo.toml \
apps/ai-game-creator-shell/src-tauri/Cargo.toml; do
for attempt in $(seq 1 5); do
@@ -268,118 +232,39 @@ jobs:
done
done
- name: Run native shell contract gates
run: npm run check:native-shells:contract
- name: Run native shell gates
run: npm run check:native-shells:shells
- name: Run native shell release build smoke
run: npm run check:native-shells:release
- name: Ensure native lockfiles are unchanged
run: git diff --exit-code -- apps/desktop-shell/src-tauri/Cargo.lock apps/ai-game-creator-shell/src-tauri/Cargo.lock
frontend-tests:
name: Frontend tests
runs-on: genarrative-ci
steps:
- name: Checkout source from Gitea
env:
GENARRATIVE_GITEA_FETCH_DEPTH: '1'
GENARRATIVE_GITEA_TOKEN: ${{ github.token }}
run: genarrative-gitea-checkout
- name: Validate preinstalled CI job image and sandbox
run: GENARRATIVE_GITEA_CI_CHECK_RUNTIME=1 bash scripts/check-gitea-ci-job-image.sh
- name: Install npm dependencies
run: bash scripts/ci-npm-ci-with-retry.sh
- name: Run frontend and script tests
run: npm run test
- name: Run BgFilter worker smoke harness tests
run: npm run bgfilter-worker:smoke-test
- name: Validate production health patrol behavior
run: npm run check:production-health-patrol
- name: Validate production API release behavior
run: npm run check:production-api-release
- name: Validate production API deploy behavior
run: npm run check:production-api-deploy
repository-checks:
name: Repository checks
runs-on: genarrative-ci
steps:
- name: Checkout full history from Gitea
env:
GENARRATIVE_GITEA_FETCH_DEPTH: '0'
GENARRATIVE_GITEA_TOKEN: ${{ github.token }}
run: genarrative-gitea-checkout
- name: Validate preinstalled CI job image and sandbox
run: GENARRATIVE_GITEA_CI_CHECK_RUNTIME=1 bash scripts/check-gitea-ci-job-image.sh
- name: Resolve comparison base
- name: Prepare standalone Rust crate dependencies
shell: bash
run: |
set -euo pipefail
base_ref="$(node -e '
const fs = require("node:fs");
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
process.stdout.write(event.pull_request?.base?.sha ?? event.before ?? "");
')"
if [[ -n "${base_ref}" && ! "${base_ref}" =~ ^0+$ ]]; then
git cat-file -e "${base_ref}^{commit}" 2>/dev/null || {
echo "comparison base commit is unavailable: ${base_ref}" >&2
exit 1
}
else
base_ref="$(git merge-base HEAD origin/master 2>/dev/null || git rev-parse HEAD)"
fi
resolved_base_ref="$(git rev-parse --verify "${base_ref}^{commit}" 2>/dev/null || true)"
head_ref="$(git rev-parse HEAD)"
if [[ "${resolved_base_ref}" == "${head_ref}" ]]; then
resolved_base_ref="$(git rev-parse --verify HEAD^ 2>/dev/null || true)"
fi
if [[ -z "${resolved_base_ref}" ]]; then
echo 'comparison base must resolve to a commit distinct from HEAD.' >&2
exit 1
fi
base_ref="${resolved_base_ref}"
if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]] \
&& ! git merge-base --is-ancestor "${base_ref}" HEAD; then
echo 'pull request head does not contain the latest base commit; update the branch and rerun CI.' >&2
exit 1
fi
echo "SPACETIME_SCHEMA_BASE_REF=${base_ref}" >> "${GITHUB_ENV}"
# agent-runtime-core / agent-runtime-orchestration 被 server-rs/Cargo.toml 的
# exclude 排除,不参与上面的 workspace 锁文件,因此上面那次锁定 fetch 覆盖不到它们;
# 而 check:native-shells 会经 agent-runtime-*:check 用 `cargo test --manifest-path`
# 单独跑这两个 crate。不在这里预热的话,这两条测试会在测试阶段自己
# `Updating crates.io index`crates.io 一抖动整条 native shell 作业就红
# (见 #327 / PR #316 run 1950)。
# 两个 crate 都没有提交 Cargo.lock,所以这里只能做不带锁标志的 fetch:
# 加锁标志会因为缺少锁文件直接失败。生成的 Cargo.lock 落在两个 crate 目录内,
# 已被各自的 .gitignore 忽略,只留在容器里;随后的测试阶段因此能用锁定版本
# 解析,不再触碰 registry index。
for manifest_path in \
server-rs/crates/agent-runtime-core/Cargo.toml \
server-rs/crates/agent-runtime-orchestration/Cargo.toml; do
for attempt in $(seq 1 5); do
if cargo fetch \
--target x86_64-unknown-linux-gnu \
--manifest-path "${manifest_path}"; then
break
fi
if [[ "${attempt}" -eq 5 ]]; then
echo "standalone crate dependency fetch failed after 5 attempts: ${manifest_path}" >&2
exit 1
fi
sleep $((attempt * 2))
done
done
- name: Install npm dependencies
run: bash scripts/ci-npm-ci-with-retry.sh
- name: Run native shell gates
run: npm run check:native-shells
- name: Run repository checks
run: npm run check:repository-ci
# 客户端的 AI 游戏创作壳前端门禁:typecheck 与壳内测试,不触碰 Cargo。
ai-game-creator-shell-web-tests:
name: AI game creator shell web tests
runs-on: genarrative-ci
steps:
- name: Checkout full history from Gitea
env:
GENARRATIVE_GITEA_FETCH_DEPTH: '0'
GENARRATIVE_GITEA_TOKEN: ${{ github.token }}
run: genarrative-gitea-checkout
- name: Validate preinstalled CI job image and sandbox
run: GENARRATIVE_GITEA_CI_CHECK_RUNTIME=1 bash scripts/check-gitea-ci-job-image.sh
- name: Install npm dependencies
run: bash scripts/ci-npm-ci-with-retry.sh
- name: Run AI game creator shell web gates
run: npm run check:native-shells:agc-web
- name: Ensure native lockfiles are unchanged
run: git diff --exit-code -- apps/desktop-shell/src-tauri/Cargo.lock apps/ai-game-creator-shell/src-tauri/Cargo.lock
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@genarrative/ai-game-creator-shell",
"private": true,
"version": "0.1.29",
"version": "0.1.27",
"type": "module",
"scripts": {
"dev": "node scripts/start-tauri-dev.mjs",
@@ -108,6 +108,8 @@ const rustSharedContractSource = fs.readFileSync(
);
const allowedUncalledTauriCommands = [
'append_direct_project_conversation_message',
// TODO: Remove the retired binding command after the legacy runtime path is removed.
'bind_components',
'chat_with_game_creator_agent',
'check_ui_editor_font_glyph_coverage',
'create_ui_design_resource',
@@ -1,426 +0,0 @@
#!/usr/bin/env node
// AGC 壳 Rust 套件的分片运行器。
//
// 背景:AGC 壳的 Rust 单测集中在 src/main.rs 的 bin target(实测 2466 条),仓库口径用
// `--test-threads=1` 跑,理由是并行调度会让共享 Agent Runtime 后台锁与异步终态的用例在
// **同一进程内**互相干扰(见 development-workflow 的 Tauri suite 单线程口径)。代价是
// 整套用例串行跑满 507 秒,占掉 CI 上 `AI game creator shell Rust tests` job 的大头。
//
// 这里保留「片内串行」的既有口径,只把用例集合切成 N 片、让每片在**独立进程**里并行:
// 当年线程并行的两个根因(进程内全局锁、异步终态)在多进程下不存在,每片还会拿到自己的
// TMPDIR,避免 tempfile 目录互相踩。片并集必须等于全集、且不得重复,数量不符即失败,
// 防止分片规则改动后静默漏跑。
//
// 用法:
// node scripts/run-rust-shell-test-shards.mjs [--shards=4] [--concurrency=4]
// node scripts/run-rust-shell-test-shards.mjs --manifest=<Cargo.toml> --target-kind=lib --no-locked
//
// 参数:
// --shards=<n> 分片数,默认 4
// --concurrency=<n> 同时运行的片数,默认等于分片数
// --manifest=<path> Cargo.toml,默认 ../src-tauri/Cargo.toml(相对本脚本)
// --target-kind=<k> bin | lib,默认 bin(本地自测小 crate 时用 lib
// --bin=<name> bin target 名,默认 genarrative-ai-game-creator-shell
// --package=<name> target-kind=lib 时要跑的包名(配合 lib 目标使用)
// --no-locked 传给 cargo 时不带 --locked(只对没有提交 Cargo.lock 的 crate 需要)
// --shard-tmp-root=<path> 片专属 TMPDIR 的父目录,默认 <系统临时目录>/agc-rust-shards
import { spawn } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
const shellRoot = path.resolve(scriptDirectory, '..');
function fail(message) {
console.error(`[rust-shards] ${message}`);
process.exit(1);
}
function parsePositiveInteger(name, rawValue) {
if (!/^[1-9][0-9]*$/.test(rawValue)) {
fail(`${name} must be a positive integer, received: ${rawValue}`);
}
return Number(rawValue);
}
const options = {
shards: 4,
concurrency: undefined,
manifestPath: path.join(shellRoot, 'src-tauri', 'Cargo.toml'),
targetKind: 'bin',
binName: 'genarrative-ai-game-creator-shell',
packageName: undefined,
locked: true,
shardTmpRoot: path.join(os.tmpdir(), 'agc-rust-shards'),
};
for (const rawArgument of process.argv.slice(2)) {
if (rawArgument === '--no-locked') {
options.locked = false;
continue;
}
const separatorIndex = rawArgument.indexOf('=');
if (!rawArgument.startsWith('--') || separatorIndex === -1) {
fail(`unexpected argument: ${rawArgument}`);
}
const name = rawArgument.slice(2, separatorIndex);
const value = rawArgument.slice(separatorIndex + 1);
switch (name) {
case 'shards':
options.shards = parsePositiveInteger('--shards', value);
break;
case 'concurrency':
options.concurrency = parsePositiveInteger('--concurrency', value);
break;
case 'manifest':
options.manifestPath = path.resolve(process.cwd(), value);
break;
case 'target-kind':
if (value !== 'bin' && value !== 'lib') {
fail(`--target-kind must be bin or lib, received: ${value}`);
}
options.targetKind = value;
break;
case 'bin':
options.binName = value;
break;
case 'package':
options.packageName = value;
break;
case 'shard-tmp-root':
options.shardTmpRoot = path.resolve(process.cwd(), value);
break;
default:
fail(`unexpected argument: ${rawArgument}`);
}
}
if (!fs.existsSync(options.manifestPath)) {
fail(`manifest does not exist: ${options.manifestPath}`);
}
const concurrency = options.concurrency ?? options.shards;
const crateRoot = path.dirname(options.manifestPath);
function buildCargoArguments(target) {
const cargoArguments = ['test'];
if (options.locked) {
cargoArguments.push('--locked');
}
cargoArguments.push('--manifest-path', options.manifestPath);
if (target.kind === 'lib') {
if (options.packageName !== undefined) {
cargoArguments.push('-p', options.packageName);
}
cargoArguments.push('--lib');
return cargoArguments;
}
cargoArguments.push('--bin', target.name);
return cargoArguments;
}
function formatDuration(milliseconds) {
return `${(milliseconds / 1000).toFixed(1)}s`;
}
// 编译一次,直接拿到测试可执行文件:后续每片都运行同一个二进制,不再各自调用 cargo,
// 免得 N 个 cargo 去争 package cache 与 target 目录锁。
function resolveTestExecutable() {
return new Promise((resolve, reject) => {
const cargoArguments = buildCargoArguments({
kind: options.targetKind,
name: options.binName,
});
cargoArguments.push('--no-run', '--message-format=json');
console.log(`[rust-shards] cargo ${cargoArguments.join(' ')}`);
const child = spawn('cargo', cargoArguments, {
cwd: crateRoot,
env: process.env,
stdio: ['ignore', 'pipe', 'inherit'],
});
let buffered = '';
const executables = [];
child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
buffered += chunk;
const lines = buffered.split('\n');
buffered = lines.pop() ?? '';
for (const line of lines) {
if (!line.startsWith('{')) {
continue;
}
let message;
try {
message = JSON.parse(line);
} catch {
continue;
}
if (
message.reason === 'compiler-artifact' &&
typeof message.executable === 'string'
) {
executables.push(message.executable);
}
}
});
child.on('error', (error) => {
reject(new Error(`unable to start cargo: ${error.message}`));
});
child.on('close', (code) => {
if (code !== 0) {
reject(
new Error(
`cargo ${cargoArguments.join(' ')} failed with exit code ${code}`,
),
);
return;
}
const uniqueExecutables = [...new Set(executables)];
if (uniqueExecutables.length !== 1) {
reject(
new Error(
`expected exactly one test executable for the ${options.targetKind} target, found ${uniqueExecutables.length}: ${uniqueExecutables.join(', ')}`,
),
);
return;
}
resolve(uniqueExecutables[0]);
});
});
}
function listTestNames(executable) {
return new Promise((resolve, reject) => {
const child = spawn(executable, ['--list'], {
cwd: crateRoot,
env: process.env,
stdio: ['ignore', 'pipe', 'pipe'],
});
let stdout = '';
let stderr = '';
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
stdout += chunk;
});
child.stderr.on('data', (chunk) => {
stderr += chunk;
});
child.on('error', (error) => {
reject(new Error(`unable to list tests: ${error.message}`));
});
child.on('close', (code) => {
if (code !== 0) {
reject(
new Error(
`listing tests failed with exit code ${code}: ${stderr.trim()}`,
),
);
return;
}
const names = [];
for (const line of stdout.split('\n')) {
const match = /^(.*): test$/.exec(line.trim());
if (match !== null && match[1].length > 0) {
names.push(match[1]);
}
}
resolve(names);
});
});
}
function splitTestNames(testNames, shardCount) {
const sortedNames = [...testNames].sort();
const shards = Array.from({ length: shardCount }, () => []);
sortedNames.forEach((testName, index) => {
shards[index % shardCount].push(testName);
});
return shards;
}
function assertShardsCoverEveryTest(testNames, shards) {
const flattened = shards.flat();
if (flattened.length !== testNames.length) {
fail(
`shard split covered ${flattened.length} of ${testNames.length} tests; the split rule must be exhaustive`,
);
}
if (new Set(flattened).size !== flattened.length) {
fail(
'shard split selected the same test more than once; the split rule must be disjoint',
);
}
const missing = testNames.filter((testName) => !flattened.includes(testName));
if (missing.length > 0) {
fail(
`shard split is missing tests, for example: ${missing.slice(0, 5).join(', ')}`,
);
}
}
function runShard(executable, shardIndex, shardCount, shardTestNames) {
const label = `shard ${shardIndex + 1}/${shardCount}`;
const shardTmpDirectory = path.join(
options.shardTmpRoot,
`shard-${shardIndex + 1}`,
);
fs.rmSync(shardTmpDirectory, { recursive: true, force: true });
fs.mkdirSync(shardTmpDirectory, { recursive: true });
const startedAt = Date.now();
return new Promise((resolve) => {
const child = spawn(
executable,
['--exact', ...shardTestNames, '--test-threads=1'],
{
cwd: crateRoot,
env: {
...process.env,
TMPDIR: shardTmpDirectory,
TMP: shardTmpDirectory,
TEMP: shardTmpDirectory,
},
stdio: ['ignore', 'pipe', 'pipe'],
},
);
const failureLines = [];
let inFailureList = false;
let stderr = '';
const consumeLine = (rawLine) => {
const line = rawLine.replace(/\r$/, '');
if (line.includes('failures:')) {
inFailureList = true;
return;
}
if (inFailureList) {
if (line.trim().length === 0) {
inFailureList = false;
return;
}
failureLines.push(line.trim());
}
};
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
let stdoutBuffer = '';
child.stdout.on('data', (chunk) => {
stdoutBuffer += chunk;
const lines = stdoutBuffer.split('\n');
stdoutBuffer = lines.pop() ?? '';
for (const line of lines) {
consumeLine(line);
}
});
child.stderr.on('data', (chunk) => {
stderr += chunk;
});
child.on('error', (error) => {
resolve({
label,
ok: false,
durationMs: Date.now() - startedAt,
testCount: shardTestNames.length,
failures: [`unable to start test binary: ${error.message}`],
stderr,
});
});
child.on('close', (code) => {
resolve({
label,
ok: code === 0,
durationMs: Date.now() - startedAt,
testCount: shardTestNames.length,
failures: failureLines,
stderr,
});
});
});
}
async function runWithConcurrency(shards, runner) {
const results = new Array(shards.length);
let nextIndex = 0;
const workers = Array.from(
{ length: Math.min(concurrency, shards.length) },
async () => {
while (nextIndex < shards.length) {
const index = nextIndex;
nextIndex += 1;
results[index] = await runner(shards[index], index);
}
},
);
await Promise.all(workers);
return results;
}
async function main() {
const executable = await resolveTestExecutable();
const testNames = await listTestNames(executable);
if (testNames.length === 0) {
fail(
`no tests discovered in ${options.manifestPath} (${options.targetKind})`,
);
}
const shards = splitTestNames(testNames, options.shards);
assertShardsCoverEveryTest(testNames, shards);
console.log(
`[rust-shards] ${testNames.length} tests, ${shards.length} shard(s), concurrency ${Math.min(concurrency, shards.length)}`,
);
shards.forEach((shardTestNames, index) => {
console.log(
`[rust-shards] shard ${index + 1}/${shards.length}: ${shardTestNames.length} test(s)`,
);
});
const results = await runWithConcurrency(shards, (shardTestNames, index) =>
runShard(executable, index, shards.length, shardTestNames),
);
let failed = false;
for (const result of results) {
if (result.ok) {
console.log(
`[rust-shards] ${result.label} ok: ${result.testCount} test(s) in ${formatDuration(result.durationMs)}`,
);
continue;
}
failed = true;
console.error(
`[rust-shards] ${result.label} FAILED: ${result.testCount} test(s) in ${formatDuration(result.durationMs)}`,
);
for (const failure of result.failures) {
console.error(`[rust-shards] ${failure}`);
}
if (result.stderr.trim().length > 0) {
console.error(
`[rust-shards] stderr: ${result.stderr.trim().split('\n').slice(-20).join('\n[rust-shards] ')}`,
);
}
}
if (failed) {
process.exit(1);
}
console.log('[rust-shards] OK');
}
main().catch((error) => {
fail(error instanceof Error ? error.message : String(error));
});
@@ -84,7 +84,6 @@ function resolveBackendTargetsFromState(
requireAgcBackend = false,
expectedDatabase = backendDatabase,
expectedSpacetimeDataDir = backendSpacetimeDataDir,
expectedRepoRoot = repoRoot,
fallbackApiTarget = defaultApiTarget,
} = {},
) {
@@ -102,25 +101,7 @@ function resolveBackendTargetsFromState(
const hasMatchingDataDir =
Boolean(spacetimeDataDir) &&
spacetimeDataDir === resolve(expectedSpacetimeDataDir);
const instanceId =
typeof state?.instanceId === 'string' ? state.instanceId.trim() : '';
const hasMatchingRepoRoot =
typeof state?.repoRoot === 'string' &&
resolve(state.repoRoot) === resolve(expectedRepoRoot);
const hasMatchingInstance =
Boolean(instanceId) &&
[apiServer, spacetime, bgfilterWorker]
.filter(Boolean)
.every(
(service) =>
service.repoRoot &&
resolve(service.repoRoot) === resolve(expectedRepoRoot) &&
service.instanceId === instanceId,
);
const hasMatchingBackend =
hasMatchingDatabase &&
hasMatchingDataDir &&
(!requireAgcBackend || (hasMatchingRepoRoot && hasMatchingInstance));
const hasMatchingBackend = hasMatchingDatabase && hasMatchingDataDir;
const canReuseState = !requireAgcBackend || hasMatchingBackend;
const apiUrl =
canReuseState && isActive(apiServer) && apiServer.url
@@ -146,8 +127,6 @@ function resolveBackendTargetsFromState(
spacetimeDataDir,
hasMatchingDatabase,
hasMatchingDataDir,
hasMatchingRepoRoot,
hasMatchingInstance,
hasMatchingBackend,
};
}
+1 -1
View File
@@ -1725,7 +1725,7 @@ dependencies = [
[[package]]
name = "genarrative-ai-game-creator-shell"
version = "0.1.29"
version = "0.1.27"
dependencies = [
"agent-runtime-core",
"axum",
@@ -1,6 +1,6 @@
[package]
name = "genarrative-ai-game-creator-shell"
version = "0.1.29"
version = "0.1.27"
edition = "2021"
publish = false
@@ -1,6 +1,6 @@
处理代码任务时先用 project.search 定位,再用带行号的 file.read 获取足够上下文;单文件小改优先使用 file.patch;涉及多个文件时优先使用 project.patchset,它会自动创建 checkpoint,无需额外调用 project.checkpoint,并在成功后用返回的 checkpointId 调用 project.diff(includeContent=true) 审查整体变更;只有确认文件已废弃时才删除。
每次成功执行 file.write、file.patch、file.delete、project.patchset 或 project.restore,以及每次真正启动 command.execcommand.start 或 project.bootstrap,都会产生新的项目 revisionDirectProject 的 npm/Phaser 工程先用 project.bootstrap {cwd:"game"} 执行受控无参数 npm install,再用 project.verify {cwd:"game",script:"build",expectedCommand:从 game/package.json 原样读取} 构建,并确认 game/dist/index.html 存在。最后一次修改后必须成功执行 project.verify、可验证 command.exec,或成功执行 command.run_limited 的 game.static_smoke,才能调用 respond_to_user 收束。文件回读不能替代可执行验证,验证后再次修改必须重新验证。需要执行 package.json 中的验证脚本时,先读取 package.json,再把真实脚本名和读到的完整命令原样提交给 project.verifyscript 可以是 check、typecheck、test、lint、build,或使用 check:<name>、test:<name>(例如 test:unit)、lint:<name>、typecheck:<name>、build:<name>、verify:<name>、validate:<name> 形式的命名脚本,其中冒号后的每个非空段必须以字母或数字开头且只能包含字母、数字、连字符、下划线或点;不得猜测或改写 expectedCommand。
每次成功执行 file.write、file.patch、file.delete、project.patchset 或 project.restore,以及每次真正启动 command.execcommand.start,都会产生新的项目 revision最后一次修改后必须成功执行 project.verify、可验证 command.exec,或成功执行 command.run_limited 的 game.static_smoke,才能调用 respond_to_user 收束。文件回读不能替代可执行验证,验证后再次修改必须重新验证。需要执行 package.json 中的验证脚本时,先读取 package.json,再把真实脚本名和读到的完整命令原样提交给 project.verifyscript 可以是 check、typecheck、test、lint、build,或使用 check:<name>、test:<name>(例如 test:unit)、lint:<name>、typecheck:<name>、build:<name>、verify:<name>、validate:<name> 形式的命名脚本,其中冒号后的每个非空段必须以字母或数字开头且只能包含字母、数字、连字符、下划线或点;不得猜测或改写 expectedCommand。
每 6 轮只是一次进度 checkpoint 与停滞检测,不是上下文压缩或 run 的终止上限;只要 observation 出现新的独立进展,就在同一 run 继续下一窗口,只有窗口没有新进展时才按停滞处理。真正的上下文压缩仅由 token 阈值或显式 compact 触发。Agent 私有记忆只能由本人写入,跨 Agent 共享稳定结论用 blackboard.write,给单个 Agent 留上下文用 agent.message。
@@ -1378,19 +1378,15 @@ fn codex_app_server_thread_start_params(
base_instructions: String,
use_model_provider: bool,
) -> serde_json::Value {
// DirectProject is an autonomous Codex session with explicit full OS
// access; approval prompts are not a second harness that can stall a turn.
// DirectHome/ToolHost stay passive.
// DirectProject is an autonomous Codex session. The app-server sandbox
// remains the hard write boundary; approval prompts are not a second
// harness that can stall a turn. DirectHome/ToolHost stay passive.
let approval_policy = "never";
let mut params = serde_json::json!({
"model": model,
"cwd": workspace_path,
"approvalPolicy": approval_policy,
"sandbox": if workspace_mode == CodexAppServerWorkspaceMode::DirectProject {
"danger-full-access"
} else {
"read-only"
},
"sandbox": if workspace_mode.allows_workspace_writes() { "workspace-write" } else { "read-only" },
"ephemeral": true,
"baseInstructions": base_instructions
});
@@ -1408,6 +1404,7 @@ fn codex_app_server_turn_start_params(
thread_id: &str,
input: serde_json::Value,
model: &str,
workspace_path: &std::path::Path,
workspace_mode: CodexAppServerWorkspaceMode,
client_user_message_id: Option<&str>,
) -> serde_json::Value {
@@ -1418,12 +1415,14 @@ fn codex_app_server_turn_start_params(
"model": model,
"approvalPolicy": approval_policy,
});
if workspace_mode == CodexAppServerWorkspaceMode::DirectProject {
// DirectProject is an explicitly user-selected local Codex session.
// Give the native Codex tools the full OS sandbox profile so they are
// not narrowed by a project-root writableRoots allowlist.
if workspace_mode.allows_workspace_writes() {
// npm install/build must resolve project dependencies. Network access
// is enabled only for DirectProject; writableRoots keeps the file-write
// boundary at the real game workspace.
params["sandboxPolicy"] = serde_json::json!({
"type": "dangerFullAccess"
"type": "workspaceWrite",
"writableRoots": [workspace_path],
"networkAccess": true
});
}
if let Some(client_user_message_id) = client_user_message_id
@@ -1437,27 +1436,40 @@ fn codex_app_server_turn_start_params(
}
fn game_creator_codex_app_server_interaction_response(
workspace_path: &std::path::Path,
workspace_mode: CodexAppServerWorkspaceMode,
id: u64,
_method: &str,
_requested_grant_root: Option<&str>,
method: &str,
requested_grant_root: Option<&str>,
) -> serde_json::Value {
if workspace_mode == CodexAppServerWorkspaceMode::DirectProject {
// Full-access DirectProject sessions do not use a file-root allowlist
// or a second approval gate. The declared sandbox policy is the only
// capability boundary for native Codex operations.
return serde_json::json!({
let direct_workspace = workspace_mode.allows_workspace_writes();
let file_change_within_workspace = game_creator_codex_file_change_request_is_allowed(
workspace_path,
method,
requested_grant_root,
);
if direct_workspace && file_change_within_workspace {
serde_json::json!({
"id": id,
"result": { "decision": "accept" }
});
})
} else if direct_workspace && method == "item/fileChange/requestApproval" {
serde_json::json!({
"id": id,
"error": {
"code": -32602,
"message": "Genarrative AGC 只允许当前项目工作区的文件变更审批"
}
})
} else {
serde_json::json!({
"id": id,
"error": {
"code": -32601,
"message": "Genarrative AGC 拒绝 app-server 的交互、审批与工具请求"
}
})
}
serde_json::json!({
"id": id,
"error": {
"code": -32601,
"message": "Genarrative AGC 拒绝 app-server 的交互、审批与工具请求"
}
})
}
#[cfg(test)]
@@ -2722,6 +2734,7 @@ impl CodexAppServerConnection {
&thread_id,
input,
model,
&self.inner.workspace_path,
self.inner.workspace_mode,
direct_client_turn_id,
);
@@ -3280,6 +3293,7 @@ async fn read_game_creator_codex_app_server_stdout(
);
}
let response = game_creator_codex_app_server_interaction_response(
&inner.workspace_path,
inner.workspace_mode,
id,
method,
@@ -3621,6 +3635,82 @@ async fn read_game_creator_codex_app_server_stderr(
}
}
#[cfg(windows)]
fn game_creator_codex_workspace_path_key(path: &std::path::Path) -> String {
let value = path.to_string_lossy();
value
.strip_prefix("\\\\?\\")
.unwrap_or(value.as_ref())
.replace('/', "\\")
.trim_end_matches('\\')
.to_ascii_lowercase()
}
fn game_creator_codex_grant_root_is_within_workspace(
workspace: &std::path::Path,
grant_root: &str,
) -> bool {
fn canonicalize_with_missing_tail(path: &std::path::Path) -> Option<std::path::PathBuf> {
if !path.is_absolute()
|| path
.components()
.any(|component| matches!(component, std::path::Component::ParentDir))
{
return None;
}
let mut existing = path.to_path_buf();
let mut missing_tail = Vec::new();
while !existing.exists() {
missing_tail.push(existing.file_name()?.to_os_string());
if !existing.pop() {
return None;
}
}
let mut normalized = existing.canonicalize().ok()?;
for component in missing_tail.iter().rev() {
normalized.push(component);
}
Some(normalized)
}
let workspace = workspace
.canonicalize()
.unwrap_or_else(|_| workspace.to_path_buf());
let Some(grant_root) = canonicalize_with_missing_tail(std::path::Path::new(grant_root)) else {
return false;
};
#[cfg(windows)]
{
let workspace_key = game_creator_codex_workspace_path_key(&workspace);
let grant_key = game_creator_codex_workspace_path_key(&grant_root);
grant_key == workspace_key
|| grant_key
.strip_prefix(&workspace_key)
.is_some_and(|suffix| suffix.starts_with('\\'))
}
#[cfg(not(windows))]
{
grant_root == workspace || grant_root.starts_with(&workspace)
}
}
fn game_creator_codex_file_change_request_is_allowed(
workspace: &std::path::Path,
method: &str,
grant_root: Option<&str>,
) -> bool {
if method != "item/fileChange/requestApproval" {
return false;
}
// `grantRoot: null` means the already-declared turn sandbox root. It is
// valid only for file changes; it must never authorize another capability
// or a broader permission request.
grant_root.is_none()
|| grant_root.is_some_and(|grant_root| {
game_creator_codex_grant_root_is_within_workspace(workspace, grant_root)
})
}
async fn fail_game_creator_codex_app_server_connection(
inner: &Weak<CodexAppServerInner>,
error: String,
@@ -4391,6 +4481,7 @@ mod tests {
"home-thread",
serde_json::json!([{ "type": "text", "text": "你好" }]),
"fixture-model",
workspace,
CodexAppServerWorkspaceMode::DirectHome,
None,
);
@@ -4404,6 +4495,7 @@ mod tests {
"item/permissions/requestApproval",
] {
let response = game_creator_codex_app_server_interaction_response(
workspace,
CodexAppServerWorkspaceMode::DirectHome,
7,
method,
@@ -4421,10 +4513,14 @@ mod tests {
}
#[test]
fn direct_project_protocol_uses_full_access_without_a_root_allowlist() {
fn direct_project_protocol_and_interactions_expose_only_the_real_game_workspace() {
let temp = tempfile::tempdir().expect("temp dir");
let project_root = temp.path().join("project");
let assets = project_root.join("assets");
let agent = project_root.join(".agent");
std::fs::create_dir_all(&project_root).expect("project root");
std::fs::create_dir(&assets).expect("assets directory");
std::fs::create_dir(&agent).expect("agent directory");
let workspace =
resolve_direct_codex_game_workspace(&project_root).expect("resolve project workspace");
assert_eq!(
@@ -4440,40 +4536,83 @@ mod tests {
true,
);
assert_eq!(thread["cwd"], serde_json::json!(workspace));
assert_eq!(thread["sandbox"], "danger-full-access");
assert_eq!(thread["sandbox"], "workspace-write");
let turn = codex_app_server_turn_start_params(
"project-thread",
serde_json::json!([{ "type": "text", "text": "修复游戏" }]),
"fixture-model",
&workspace,
CodexAppServerWorkspaceMode::DirectProject,
Some("direct-turn-0001"),
);
assert_eq!(turn["clientUserMessageId"], "direct-turn-0001");
assert_eq!(
turn.pointer("/sandboxPolicy/type"),
Some(&serde_json::json!("dangerFullAccess"))
turn.pointer("/sandboxPolicy/writableRoots/0"),
Some(&serde_json::json!(workspace))
);
assert_eq!(
turn.pointer("/sandboxPolicy/networkAccess"),
Some(&serde_json::json!(true))
);
let authority_paths = [
turn.get("cwd"),
turn.pointer("/sandboxPolicy/writableRoots/0"),
];
assert!(
authority_paths
.iter()
.flatten()
.all(|value| value.as_str() == Some(workspace.to_string_lossy().as_ref())),
"writable params must be exactly the project workspace"
);
assert!(turn.pointer("/sandboxPolicy/writableRoots").is_none());
assert!(turn.pointer("/sandboxPolicy/networkAccess").is_none());
for (id, method) in [
(9, "item/fileChange/requestApproval"),
(10, "item/commandExecution/requestApproval"),
(11, "item/permissions/requestApproval"),
(12, "item/tool/call"),
] {
let workspace_string = workspace.to_string_lossy().into_owned();
for allowed_root in [None, Some(workspace_string.as_str())] {
let response = game_creator_codex_app_server_interaction_response(
&workspace,
CodexAppServerWorkspaceMode::DirectProject,
id,
method,
Some("C:\\outside-project"),
9,
"item/fileChange/requestApproval",
allowed_root,
);
assert_eq!(
response.pointer("/result/decision"),
Some(&serde_json::json!("accept"))
);
}
for forbidden_root in [assets, agent] {
let forbidden_root = forbidden_root.to_string_lossy().into_owned();
let response = game_creator_codex_app_server_interaction_response(
&workspace,
CodexAppServerWorkspaceMode::DirectProject,
10,
"item/fileChange/requestApproval",
Some(&forbidden_root),
);
assert_eq!(
response.pointer("/result/decision"),
Some(&serde_json::json!("accept")),
"project-root children must stay writable: {forbidden_root}"
);
}
for method in [
"item/commandExecution/requestApproval",
"item/permissions/requestApproval",
"item/tool/call",
] {
for requested_root in [None, Some(workspace_string.as_str())] {
let response = game_creator_codex_app_server_interaction_response(
&workspace,
CodexAppServerWorkspaceMode::DirectProject,
11,
method,
requested_root,
);
assert!(response.get("error").is_some());
assert!(response.get("result").is_none());
}
}
}
#[test]
@@ -4491,6 +4630,26 @@ mod tests {
assert!(resolve_direct_codex_game_workspace(&file_root).is_err());
}
#[cfg(all(unix, not(target_os = "macos")))]
#[test]
fn direct_project_grant_root_comparison_remains_case_sensitive() {
let temp = tempfile::tempdir().expect("temp dir");
let project_root = temp.path().join("Project");
let child = project_root.join("assets");
let different_case = temp.path().join("project").join("assets");
std::fs::create_dir_all(&child).expect("child directory");
std::fs::create_dir_all(&different_case).expect("different-case directory");
assert!(game_creator_codex_grant_root_is_within_workspace(
&project_root,
project_root.to_string_lossy().as_ref()
));
assert!(!game_creator_codex_grant_root_is_within_workspace(
&project_root,
different_case.to_string_lossy().as_ref()
));
}
#[cfg(unix)]
#[test]
fn direct_project_rejects_a_non_directory_workspace() {
@@ -5087,25 +5246,51 @@ while IFS= read -r line; do :; done
}
#[test]
fn direct_project_interactions_accept_full_access_without_a_root_allowlist() {
for method in [
fn direct_file_change_approval_is_limited_to_workspace() {
let temp = tempfile::tempdir().expect("temp dir");
let workspace = temp.path().join("demo");
let child = workspace.join("assets");
let sibling = temp.path().join("demolition");
std::fs::create_dir_all(&child).expect("workspace child");
std::fs::create_dir(&sibling).expect("sibling");
assert!(game_creator_codex_file_change_request_is_allowed(
&workspace,
"item/fileChange/requestApproval",
"item/commandExecution/requestApproval",
"item/permissions/requestApproval",
"item/tool/call",
] {
let response = game_creator_codex_app_server_interaction_response(
CodexAppServerWorkspaceMode::DirectProject,
1,
method,
Some("C:\\outside-project"),
);
assert_eq!(
response.pointer("/result/decision"),
Some(&serde_json::json!("accept"))
);
assert!(response.get("error").is_none());
}
None
));
assert!(game_creator_codex_grant_root_is_within_workspace(
&workspace,
workspace.to_string_lossy().as_ref()
));
assert!(game_creator_codex_grant_root_is_within_workspace(
&workspace,
child.to_string_lossy().as_ref()
));
assert!(!game_creator_codex_grant_root_is_within_workspace(
&workspace,
sibling.to_string_lossy().as_ref()
));
assert!(!game_creator_codex_file_change_request_is_allowed(
&workspace,
"item/fileChange/requestApproval",
Some(sibling.to_string_lossy().as_ref())
));
assert!(!game_creator_codex_grant_root_is_within_workspace(
&workspace,
sibling.join("missing").to_string_lossy().as_ref()
));
assert!(game_creator_codex_grant_root_is_within_workspace(
&workspace,
workspace.join("missing").to_string_lossy().as_ref()
));
assert!(!game_creator_codex_grant_root_is_within_workspace(
&workspace,
workspace
.join("..")
.join("outside")
.to_string_lossy()
.as_ref()
));
}
#[test]
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@ JSON schema:
{ "group": "balance", "role": "Difficulty", "summary": "数值交接摘要", "outputs": ["game/balance.json"], "next": "交给程序组读取" },
{ "group": "art", "role": "Asset", "summary": "美术交接摘要", "outputs": ["assets/manifest.art.json"], "next": "进入画板或本地资产登记" },
{ "group": "audio", "role": "SFX", "summary": "音乐音效交接摘要", "outputs": ["assets/manifest.audio.json"], "next": "进入画板音频链路" },
{ "group": "code", "role": "Code", "summary": "程序交接摘要", "outputs": ["game/index.html", "game/game.js", "game/package.json", "game/vite.config.js"], "next": "先 project.bootstrap,再 project.verify(build)交给 Playtest" },
{ "group": "code", "role": "Code", "summary": "程序交接摘要", "outputs": ["game/index.html"], "next": "交给 Playtest" },
{ "group": "publishing", "role": "Publish", "summary": "运营交接摘要", "outputs": ["exports/README.md"], "next": "等待预览验收" }
],
"handoffSummary": "六组 agent 的交接摘要,每组一行",
@@ -24,7 +24,6 @@ JSON schema:
}
gameHtml 规则:
- 本次若目标是 Phaser/npmworkspaceMode 必须为 DirectProject;先写入完整 game/ 工程文件,再由受控项目工具安装与构建。
- 此 JSON 协议仅用于已有的单文件 HTML 项目;npm / Phaser 项目必须使用 DirectProject,不能通过 gameHtml 交付 package.json 或模块源码。
- 必须是单文件 HTML,不能加载远程脚本、远程图片、远程 CSS 或 CDN。
- 必须包含 canvas、canvas getContext、实际绘制调用、键盘或鼠标输入、requestAnimationFrame 主循环、目标、失败或胜利状态、R 或按钮重开。
@@ -1156,6 +1156,10 @@ mod tests {
assert!(with_canvas.contains("根据当前玩法需求编写规格和界面建议"));
assert!(with_canvas.contains("用途、数量、输出路径、尺寸、参考资源和是否需要 spritesheet"));
assert!(with_canvas.contains("再调用 canvas.asset_generate"));
assert!(with_canvas.contains("调用 canvas.asset_generate"));
assert!(with_canvas.contains("不要使用固定图片合同"));
assert!(with_canvas.contains("不修改 game/index.html"));
assert!(!with_canvas.contains("不调用 canvas.asset_generate"));
}
#[test]
@@ -801,7 +801,7 @@ fn agent_runtime_action_receipt_safe_detail_with_owner(
let initial_step = route.get("initialStep")?.as_str()?;
let render_mode = route.get("renderMode")?.as_str()?;
if resource_id.is_empty()
|| initial_step != "visual-binding"
|| initial_step != "asset-separation"
|| render_mode != "final-preview"
{
return None;
@@ -1192,7 +1192,6 @@ pub(in crate::agent) fn agent_runtime_public_action_input_summary(
| "project.patchset"
| "project.search"
| "project.verify"
| "project.bootstrap"
| "file.list"
| "file.read"
| "file.write"
@@ -1260,7 +1259,6 @@ pub(crate) fn agent_runtime_tool_action_fingerprint(
| "command.stdin"
| "command.terminate"
| "project.verify"
| "project.bootstrap"
)
.then(|| {
let metadata = command_sandbox_platform_metadata();
@@ -1470,23 +1468,11 @@ pub(crate) fn agent_runtime_tool_action_input_summary(
.and_then(|value| value.as_bool())
.unwrap_or(false)
),
"project.bootstrap" => {
format!(
"cwd={} · timeoutSeconds={}",
relative_path(&["cwd"]),
input
.get("timeoutSeconds")
.or_else(|| input.get("timeout_seconds"))
.and_then(|value| value.as_u64())
.unwrap_or(300)
)
}
"project.verify" => {
let expected_command = text(&["expectedCommand", "expected_command"]);
let command_chars = expected_command.chars().count();
format!(
"cwd={} · script={} · expectedCommandSha256={:x} · expectedCommandChars={} · timeoutSeconds={}",
relative_path(&["cwd"]),
"script={} · expectedCommandSha256={:x} · expectedCommandChars={} · timeoutSeconds={}",
text(&["script"]),
Sha256::digest(expected_command.as_bytes()),
command_chars,
@@ -184,17 +184,6 @@ pub(crate) async fn execute_game_creator_agent_runtime_tool_action_with_pending_
)
.await
}
"project.bootstrap" => {
observe_agent_runtime_project_bootstrap(
root,
agent_id,
run_id,
action_id,
&action_fingerprint,
&action.input,
)
.await
}
"project.checkpoint" => observe_agent_runtime_project_checkpoint(root),
"project.restore" => {
observe_agent_runtime_project_restore(root, agent_id, run_id, &action.input)
@@ -8,15 +8,10 @@ pub(crate) struct AgentRuntimeAutonomousSourcePayloadStats {
}
pub(in crate::agent) fn agent_runtime_autonomous_project_verify_available(root: &Path) -> bool {
[root.join("package.json"), root.join("game/package.json")]
.into_iter()
.any(|package_path| {
fs::symlink_metadata(package_path)
.map(|metadata| {
metadata.file_type().is_file() && !metadata.file_type().is_symlink()
})
.unwrap_or(false)
})
let package_path = root.join("package.json");
fs::symlink_metadata(package_path)
.map(|metadata| metadata.file_type().is_file() && !metadata.file_type().is_symlink())
.unwrap_or(false)
}
pub(in crate::agent) fn add_agent_runtime_autonomous_source_field(
@@ -345,7 +345,7 @@ fn build_game_creator_agent_background_tool_plan_request_at(
let project_tools_contract = if runtime_owner_artifact_validation_available {
"project.search 使用 {\"query\":\"要查找的字面文本\",\"path\":\"\",\"maxResults\":20,\"caseSensitive\":false},path 为空字符串时搜索整个项目,返回 path:line 和匹配行;当前固定 owner 的函数目录不广告 project.verifyproject.checkpoint 使用空对象,只用于多个 file.* 写动作前或需要独立回退点时创建本地 checkpointproject.patchset 会自动创建 checkpoint,不要为同一批变更额外调用 project.checkpointproject.restore 使用 {\"checkpointId\":\"checkpoint id\"}project.diff 使用 {\"checkpointId\":\"checkpoint id\",\"includeContent\":true,\"maxFiles\":20,\"maxChars\":24000}git.inspect 使用 {\"includeDiff\":true,\"maxFiles\":20,\"maxChars\":24000},只读项目根 Git 状态和有界 diff,不得用它提交、暂存、切分支、合并、重置、stash、worktree 或访问 remote。".to_string()
} else {
"project.search 使用 {\"query\":\"要查找的字面文本\",\"path\":\"\",\"maxResults\":20,\"caseSensitive\":false},path 为空字符串时搜索整个项目,返回 path:line 和匹配行;project.bootstrap 使用 {\"cwd\":\"game\",\"timeoutSeconds\":300},只执行 game 目录无参数 npm install 并记录 package/lock 指纹;project.verify 使用 {\"script\":\"check|typecheck|test|lint|build\",\"expectedCommand\":\"对应 cwd 的 package.json 读取的完整原始脚本\",\"timeoutSeconds\":120,\"cwd\":\"game\"},只执行对应 cwd package.json 中同名 npm 脚本,build 必须确认 game/dist/index.htmlexpectedCommand 不一致时拒绝执行,确认策略以当前工具策略中 project.verify 的独立权限为准;project.checkpoint 使用空对象,只用于多个 file.* 写动作前或需要独立回退点时创建本地 checkpointproject.patchset 会自动创建 checkpoint,不要为同一批变更额外调用 project.checkpointproject.restore 使用 {\"checkpointId\":\"checkpoint id\"}project.diff 使用 {\"checkpointId\":\"checkpoint id\",\"includeContent\":true,\"maxFiles\":20,\"maxChars\":24000}git.inspect 使用 {\"includeDiff\":true,\"maxFiles\":20,\"maxChars\":24000},只读项目根 Git 状态和有界 diff,不得用它提交、暂存、切分支、合并、重置、stash、worktree 或访问 remote。".to_string()
"project.search 使用 {\"query\":\"要查找的字面文本\",\"path\":\"\",\"maxResults\":20,\"caseSensitive\":false},path 为空字符串时搜索整个项目,返回 path:line 和匹配行;project.verify 使用 {\"script\":\"check|typecheck|test|lint|build\",\"expectedCommand\":\"从 package.json 读取的完整原始脚本\",\"timeoutSeconds\":120},只执行项目根 package.json 中同名 npm 脚本,expectedCommand 不一致时拒绝执行,确认策略以当前工具策略中 project.verify 的独立权限为准;project.checkpoint 使用空对象,只用于多个 file.* 写动作前或需要独立回退点时创建本地 checkpointproject.patchset 会自动创建 checkpoint,不要为同一批变更额外调用 project.checkpointproject.restore 使用 {\"checkpointId\":\"checkpoint id\"}project.diff 使用 {\"checkpointId\":\"checkpoint id\",\"includeContent\":true,\"maxFiles\":20,\"maxChars\":24000}git.inspect 使用 {\"includeDiff\":true,\"maxFiles\":20,\"maxChars\":24000},只读项目根 Git 状态和有界 diff,不得用它提交、暂存、切分支、合并、重置、stash、worktree 或访问 remote。".to_string()
};
let prompt = format!(
concat!(
@@ -28,7 +28,6 @@ pub(crate) fn agent_runtime_executable_tools() -> Vec<&'static str> {
"project.index",
"project.search",
"project.verify",
"project.bootstrap",
"project.checkpoint",
"project.restore",
"project.diff",
@@ -84,7 +83,6 @@ pub(crate) fn agent_runtime_acceptance_evidence_tools() -> BTreeSet<&'static str
"project.index",
"project.search",
"project.verify",
"project.bootstrap",
"project.diff",
"git.inspect",
"project.patchset",
@@ -156,7 +156,6 @@ pub(super) const AGENT_RUNTIME_AUTONOMOUS_GAME_BUILD_AUTO_COMMAND_IDS: &[&str] =
"file.delete",
"project.patchset",
"project.verify",
"project.bootstrap",
"command.run_limited",
"preview.validate",
"canvas.asset_generate",
@@ -109,7 +109,6 @@ pub(crate) fn agent_runtime_tool_requires_repository_context_fingerprint_gate(to
| "project.index"
| "project.search"
| "project.verify"
| "project.bootstrap"
| "project.checkpoint"
| "project.patchset"
| "project.restore"
@@ -857,12 +857,6 @@ pub(crate) async fn observe_agent_runtime_project_verify(
.and_then(serde_json::Value::as_str)
.unwrap_or_default()
.to_string();
let cwd = input
.get("cwd")
.and_then(serde_json::Value::as_str)
.filter(|value| !value.trim().is_empty())
.unwrap_or(".")
.to_string();
let timeout_seconds =
agent_runtime_tool_input_usize(input, &["timeoutSeconds", "timeout_seconds"])
.unwrap_or(AGENT_RUNTIME_PROJECT_VERIFY_DEFAULT_TIMEOUT_SECONDS);
@@ -902,7 +896,6 @@ pub(crate) async fn observe_agent_runtime_project_verify(
script.as_str(),
expected_command.as_str(),
timeout_seconds,
cwd.as_str(),
|| {
verification_state = Some(begin_agent_runtime_project_verification_locked(
root,
@@ -938,7 +931,6 @@ pub(crate) async fn observe_agent_runtime_project_verify(
"script": verification.script,
"expectedCommand": audit_expected_command,
"packageManager": verification.package_manager,
"cwd": verification.cwd_relative,
"status": verification.status,
"exitCode": verification.exit_code,
"timedOut": verification.timed_out,
@@ -1047,81 +1039,3 @@ pub(crate) async fn observe_agent_runtime_project_verify(
}
}
}
pub(crate) async fn observe_agent_runtime_project_bootstrap(
root: &Path,
agent_id: &str,
run_id: &str,
action_id: Option<&str>,
action_fingerprint: &str,
input: &serde_json::Value,
) -> AgentRuntimeToolObservation {
let cwd = input
.get("cwd")
.and_then(serde_json::Value::as_str)
.unwrap_or_default();
let timeout = agent_runtime_tool_input_usize(input, &["timeoutSeconds", "timeout_seconds"])
.unwrap_or(300);
if cwd != "game" {
return AgentRuntimeToolObservation {
tool: "project.bootstrap".to_string(),
status: "failed".to_string(),
summary: "project.bootstrap 只允许 cwd=game".to_string(),
detail: None,
};
}
let _lock = match acquire_project_write_lock(root, "project.bootstrap") {
Ok(lock) => lock,
Err(error) => {
return AgentRuntimeToolObservation {
tool: "project.bootstrap".to_string(),
status: "failed".to_string(),
summary: "project.bootstrap 无法取得项目执行锁".to_string(),
detail: Some(redact_agent_runtime_project_paths(root, &error, 240)),
}
}
};
let result = crate::project::run_project_bootstrap_at(root, timeout as u64).await;
match result {
Ok(value) if value.status == "completed" => {
if let Err(error) = append_agent_db_record(
root,
serde_json::json!({
"recordType":"agent.runtime.project.bootstrap", "agentId":agent_id, "runId":run_id,
"actionId":action_id, "actionFingerprint":action_fingerprint, "cwd":"game",
"packageSha256":value.package_sha256, "lockSha256":value.lock_sha256,
"status":value.status, "logPath":value.log_path, "output":value.output
}),
) {
return AgentRuntimeToolObservation {
tool: "project.bootstrap".to_string(),
status: AGENT_RUNTIME_TOOL_OBSERVATION_STATUS_NEEDS_RECONCILIATION.to_string(),
summary: "project.bootstrap 已安装,但审计记录无法落盘".to_string(),
detail: Some(redact_agent_runtime_project_paths(root, &error, 500)),
};
}
AgentRuntimeToolObservation {
tool: "project.bootstrap".to_string(),
status: "ok".to_string(),
summary: "game 依赖安装已完成".to_string(),
detail: Some(format!(
"cwd=game · packageSha256={} · lockSha256={}",
value.package_sha256,
value.lock_sha256.as_deref().unwrap_or("none")
)),
}
}
Ok(value) => AgentRuntimeToolObservation {
tool: "project.bootstrap".to_string(),
status: "failed".to_string(),
summary: "game 依赖安装失败".to_string(),
detail: Some(value.output),
},
Err(error) => AgentRuntimeToolObservation {
tool: "project.bootstrap".to_string(),
status: "failed".to_string(),
summary: redact_agent_runtime_project_paths(root, &error, 240),
detail: None,
},
}
}
@@ -1009,8 +1009,7 @@ fn runtime_tool_description(tool: &str) -> &'static str {
}
"project.index" => "刷新并读取有界仓库启动上下文。",
"project.search" => "在项目文本文件中做有界字面量搜索。",
"project.verify" => "在项目或指定相对 cwd 中运行 package.json 原样声明的验证脚本,并检查构建产物",
"project.bootstrap" => "仅在项目 game 目录受控执行无参数 npm install,并记录依赖文件指纹。",
"project.verify" => "运行 package.json 原样声明的验证脚本。",
"project.checkpoint" => "创建项目本地 checkpoint。",
"project.restore" => "从 checkpoint 恢复当前项目。",
"project.diff" => "读取 checkpoint 与当前项目之间的有界差异。",
@@ -1155,18 +1154,10 @@ fn runtime_tool_input_schema(tool: &str) -> Value {
}
}),
"project.verify" => json!({
"type": "object", "required": ["script", "expectedCommand", "timeoutSeconds", "cwd"], "additionalProperties": false,
"type": "object", "required": ["script", "expectedCommand", "timeoutSeconds"], "additionalProperties": false,
"properties": {
"script": { "type": "string", "minLength": 1 },
"expectedCommand": { "type": "string", "minLength": 1 },
"timeoutSeconds": { "type": "integer", "minimum": 1, "maximum": 600 },
"cwd": { "type": ["string", "null"], "pattern": "^[A-Za-z0-9._/-]+$" }
}
}),
"project.bootstrap" => json!({
"type": "object", "required": ["cwd", "timeoutSeconds"], "additionalProperties": false,
"properties": {
"cwd": { "type": "string", "const": "game" },
"timeoutSeconds": { "type": "integer", "minimum": 1, "maximum": 600 }
}
}),
@@ -647,9 +647,9 @@ pub(crate) fn register_design_artifacts_at(root: &Path) -> Result<usize, String>
register_local_asset_at(
root,
&relative,
"document",
"design-document",
media_type,
"document",
"design-document",
GameCreationAppAssetSource {
kind: GameCreationAppAssetSourceKind::Uploaded,
canvas_project_id: None,
@@ -321,44 +321,6 @@ pub(crate) fn resolve_project_command_spec_at(
.map_err(|error| ProjectCommandError::new(ProjectCommandErrorStage::Validation, error))
}
/// Resolves the one privileged npm operation used to hydrate a DirectProject.
/// It intentionally bypasses the general command.exec npm allow-list: callers
/// must use the dedicated `project.bootstrap` action, which only accepts the
/// literal `npm install` in the project's `game` directory.
pub(crate) fn resolve_project_bootstrap_spec_at(
root: &Path,
timeout_seconds: u64,
) -> Result<ProjectCommandSpec, ProjectCommandError> {
validate_project_root(root)
.map_err(|error| ProjectCommandError::new(ProjectCommandErrorStage::Validation, error))?;
let cwd_relative = "game".to_string();
let cwd = resolve_local_project_path(root, &cwd_relative)
.map_err(|error| ProjectCommandError::new(ProjectCommandErrorStage::Validation, error))?;
validate_project_command_cwd_components(root, &cwd_relative)
.map_err(|error| ProjectCommandError::new(ProjectCommandErrorStage::Validation, error))?;
if !(PROJECT_COMMAND_MIN_TIMEOUT_SECONDS..=PROJECT_COMMAND_MAX_TIMEOUT_SECONDS)
.contains(&timeout_seconds)
{
return Err(ProjectCommandError::new(
ProjectCommandErrorStage::Validation,
format!("project.bootstrap timeoutSeconds 必须在 {PROJECT_COMMAND_MIN_TIMEOUT_SECONDS}-{PROJECT_COMMAND_MAX_TIMEOUT_SECONDS} 之间"),
));
}
let program = "npm".to_string();
let (executable, safe_path) = resolve_project_command_executable(root, &program)
.map_err(|error| ProjectCommandError::new(ProjectCommandErrorStage::Validation, error))?;
Ok(ProjectCommandSpec {
program,
executable,
safe_path,
arguments: vec!["install".to_string()],
cwd_relative,
cwd,
timeout_seconds,
verification_eligible: false,
})
}
fn resolve_project_command_spec_inner(
root: &Path,
program: &str,
@@ -1240,19 +1202,6 @@ pub(crate) fn prepare_project_command_launch_spec(
(OsString::from("NO_PROXY"), OsString::new()),
(OsString::from("PATH"), spec.safe_path.clone()),
];
if spec
.arguments
.first()
.is_some_and(|argument| argument == "install")
{
for (name, value) in &mut environment {
match name.to_string_lossy().as_ref() {
"npm_config_offline" => *value = OsString::from("false"),
"HTTP_PROXY" | "HTTPS_PROXY" | "ALL_PROXY" => *value = OsString::new(),
_ => {}
}
}
}
for name in ["SystemRoot", "PATHEXT", "RUSTUP_HOME"] {
if let Some(value) = std::env::var_os(name) {
environment.push((OsString::from(name), value));
@@ -2049,16 +1998,6 @@ pub(crate) async fn run_project_command_with_output_at(
.await
}
pub(crate) async fn run_project_bootstrap_command_at(
root: &Path,
timeout_seconds: u64,
) -> Result<ProjectCommandResult, ProjectCommandError> {
let spec = resolve_project_bootstrap_spec_at(root, timeout_seconds)?;
let launch = prepare_project_command_launch_spec(root, &spec)?;
let staged = stage_project_command_launch_spec(&spec, launch)?;
run_prepared_project_command_with_output_at(root, &spec, staged, None, || Ok(())).await
}
pub(crate) async fn run_prepared_project_command_with_output_at<F>(
root: &Path,
spec: &ProjectCommandSpec,
@@ -302,19 +302,7 @@ mod linux {
cwd: &Path,
environment: &[(OsString, OsString)],
) -> Result<CommandSandboxLaunch, CommandSandboxError> {
let mut metadata = CommandSandboxMetadata::enforced_linux();
let network_enabled = executable
.file_name()
.and_then(OsStr::to_str)
.is_some_and(|name| {
name.eq_ignore_ascii_case("npm") || name.eq_ignore_ascii_case("npm.cmd")
})
&& arguments
.first()
.is_some_and(|argument| argument == "install");
if network_enabled {
metadata.network = "enabled";
}
let metadata = CommandSandboxMetadata::enforced_linux();
let bwrap = find_trusted_bwrap().map_err(|error| {
CommandSandboxError::new(
format!("command sandbox unavailable: {error}"),
@@ -375,7 +363,7 @@ mod linux {
)?;
let fixed_system_read_only = collect_fixed_system_mounts();
let mut launch = build_linux_bwrap_launch(LinuxSandboxPlan {
let launch = build_linux_bwrap_launch(LinuxSandboxPlan {
bwrap,
root,
cwd,
@@ -387,7 +375,6 @@ mod linux {
external_read_only,
fixed_system_read_only,
});
launch.metadata = metadata.clone();
run_project_mount_preflight(&launch).map_err(|error| {
CommandSandboxError::new(
format!("command sandbox project mount preflight 失败:{error}"),
@@ -615,19 +602,7 @@ mod linux {
fn build_linux_bwrap_launch(plan: LinuxSandboxPlan) -> CommandSandboxLaunch {
let mut args = Vec::<OsString>::new();
push_namespace_arguments(
&mut args,
plan.executable
.file_name()
.and_then(OsStr::to_str)
.is_some_and(|name| {
name.eq_ignore_ascii_case("npm") || name.eq_ignore_ascii_case("npm.cmd")
})
&& plan
.arguments
.first()
.is_some_and(|argument| argument == "install"),
);
push_namespace_arguments(&mut args);
push_ro_bind(&mut args, Path::new("/usr"), Path::new("/usr"));
for (target, destination) in &plan.merged_usr_links {
push_option(
@@ -698,7 +673,7 @@ mod linux {
}
}
fn push_namespace_arguments(args: &mut Vec<OsString>, share_network: bool) {
fn push_namespace_arguments(args: &mut Vec<OsString>) {
for argument in [
"--die-with-parent",
"--unshare-all",
@@ -711,9 +686,6 @@ mod linux {
] {
args.push(OsString::from(argument));
}
if share_network {
args.push(OsString::from("--share-net"));
}
}
fn push_option<'a, I>(args: &mut Vec<OsString>, option: &str, values: I)
@@ -857,7 +829,7 @@ mod linux {
merged_usr_links: &[(OsString, PathBuf)],
) -> Result<(), String> {
let mut args = Vec::<OsString>::new();
push_namespace_arguments(&mut args, false);
push_namespace_arguments(&mut args);
push_ro_bind(&mut args, Path::new("/usr"), Path::new("/usr"));
for (target, destination) in merged_usr_links {
push_option(
@@ -1945,36 +1945,28 @@ pub(crate) fn read_platform_account_session_generation() -> u64 {
}
#[tauri::command]
pub(crate) async fn install_platform_account_session(
pub(crate) fn install_platform_account_session(
user_id: String,
access_token: String,
api_base_url: String,
generation: u64,
) -> Result<(), String> {
tokio::task::spawn_blocking(move || {
validate_platform_session_input(&user_id, &access_token, &api_base_url, generation)?;
install_external_agent_runner_platform_session(
&user_id,
&access_token,
&api_base_url,
generation,
)?;
install_platform_session(&user_id, &access_token, &api_base_url, generation)
})
.await
.map_err(|error| format!("安装本地运行时会话任务意外终止:{error}"))?
validate_platform_session_input(&user_id, &access_token, &api_base_url, generation)?;
install_external_agent_runner_platform_session(
&user_id,
&access_token,
&api_base_url,
generation,
)?;
install_platform_session(&user_id, &access_token, &api_base_url, generation)
}
#[tauri::command]
pub(crate) async fn clear_platform_account_session(generation: u64) -> Result<(), String> {
tokio::task::spawn_blocking(move || {
shutdown_game_creator_codex_app_servers()?;
clear_external_agent_runner_platform_session(generation)?;
clear_platform_session(generation);
Ok(())
})
.await
.map_err(|error| format!("清除本地运行时会话任务意外终止:{error}"))?
pub(crate) fn clear_platform_account_session(generation: u64) -> Result<(), String> {
shutdown_game_creator_codex_app_servers()?;
clear_external_agent_runner_platform_session(generation)?;
clear_platform_session(generation);
Ok(())
}
#[tauri::command]

Some files were not shown because too many files have changed in this diff Show More