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

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

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

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

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

114 lines
3.9 KiB
Rust

use super::*;
mod action_history;
mod cocos_editor;
mod command_ops;
mod context;
mod delegation;
mod delivery;
mod file_ops;
mod goal_contract;
mod helpers;
mod isolated_joins;
mod media;
pub(in crate::agent) use media::design_foundation_ui_page_output_path_is_valid;
mod policy;
mod preview;
mod process_ops;
mod project_ops;
mod run_status;
mod task_ops;
mod ui_workflow;
pub(in crate::agent) use action_history::*;
pub(in crate::agent) use cocos_editor::*;
pub(in crate::agent) use command_ops::*;
pub(in crate::agent) use context::*;
pub(in crate::agent) use delegation::*;
pub(in crate::agent) use delivery::*;
pub(in crate::agent) use file_ops::*;
pub(in crate::agent) use goal_contract::*;
pub(in crate::agent) use helpers::*;
pub(in crate::agent) use isolated_joins::*;
pub(in crate::agent) use media::*;
pub(in crate::agent) use policy::*;
pub(in crate::agent) use preview::*;
pub(in crate::agent) use process_ops::*;
pub(in crate::agent) use project_ops::*;
pub(in crate::agent) use run_status::*;
pub(in crate::agent) use task_ops::*;
pub(in crate::agent) use ui_workflow::*;
#[cfg(test)]
pub(crate) use delegation::observe_agent_runtime_agent_delegate_at_locked;
#[cfg(test)]
pub(crate) use delivery::{
build_static_delegate_result_for_child_at, wake_waiting_static_delegate_parent_run_for_test_at,
};
#[cfg(test)]
pub(crate) use media::validate_agent_runtime_canvas_replacement_authorization_at;
pub(crate) use action_history::{
is_valid_agent_runtime_action_id, observe_agent_runtime_action_history,
};
pub(crate) use command_ops::{
observe_agent_runtime_limited_command, observe_agent_runtime_project_verify,
};
pub(crate) use delegation::{
observe_agent_runtime_agent_delegate, observe_agent_runtime_agent_message,
observe_agent_runtime_agent_spawn_isolated,
};
pub(crate) use delivery::{
agent_runtime_delegation_id, dispatch_isolated_agent_join_at,
game_creator_agent_runtime_terminal_status, publish_game_creator_agent_delegate_result,
reconcile_game_creator_agent_delegate_receipts_at,
};
#[allow(unused_imports)]
pub(crate) use isolated_joins::{
mark_isolated_join_claim_observed_at, render_isolated_join_status_batch,
};
#[cfg(test)]
pub(crate) use media::observe_agent_runtime_platform_art_asset_generation_after_dispatch_for_test;
#[allow(unused_imports)]
pub(crate) use media::{
AGENT_RUNTIME_UI_PROTOTYPE_INSPECTION_KIND,
AGENT_RUNTIME_UI_PROTOTYPE_LEGACY_VALIDATION_PROFILE, AGENT_RUNTIME_UI_PROTOTYPE_PATH,
AGENT_RUNTIME_UI_PROTOTYPE_VALIDATION_PROFILE,
};
pub(crate) use policy::{
fail_closed_agent_runtime_confirmation_for_run,
game_creator_agent_runtime_tool_policy_block_after_lock,
game_creator_agent_runtime_tool_policy_rule_for_run,
};
pub(crate) use preview::{
observe_agent_runtime_preview_start, observe_agent_runtime_preview_validate,
};
#[allow(unused_imports)]
pub(crate) use project_ops::{
observe_agent_runtime_project_git_commit_locked_with_audit,
observe_agent_runtime_project_patchset_with_audit,
};
pub(crate) use run_status::observe_agent_runtime_run_status;
/// Validation tools are retained for compatibility with older provider turns,
/// but a relaxed autonomous game-build run must not let an accidental call
/// reintroduce the legacy verification/preview gates. Resolve the profile
/// from durable run metadata and report a terminal no-op observation before
/// any tool-specific parsing or side effects occur.
pub(crate) fn relaxed_autonomous_validation_skip_observation(
root: &Path,
agent_id: &str,
run_id: &str,
tool: &str,
) -> Option<AgentRuntimeToolObservation> {
autonomous_relaxed_run_at(root, agent_id, run_id)
.ok()
.filter(|relaxed| *relaxed)
.map(|_| AgentRuntimeToolObservation {
tool: tool.to_string(),
status: "ok".to_string(),
summary: format!("{tool} 在 relaxed autonomous lane 中跳过,未执行平台验证"),
detail: Some("relaxedAutonomous=true · skipped=true".to_string()),
})
}