完善Agent受控命令与推理配置

新增受控 command.exec 固定程序、参数策略、隔离环境和有界审计
接入项目 revision、验证资格、确认动作复核与失败核对门禁
支持全局及每 Agent 独立推理档位并提供发布默认配置
补齐前端配置、共享契约、Runtime 回归和真实 Provider 验收
同步开发流程、技术方案与项目共享决策记录
This commit is contained in:
AIGameCreator App
2026-07-12 23:22:11 +08:00
parent 5e627a4677
commit 49ea9eec67
18 changed files with 4068 additions and 111 deletions
@@ -21,7 +21,7 @@ pub struct GameCreationAppCommandDescriptor {
pub permission: GameCreationAppPermission,
}
pub const GAME_CREATION_APP_COMMANDS: [GameCreationAppCommandDescriptor; 51] = [
pub const GAME_CREATION_APP_COMMANDS: [GameCreationAppCommandDescriptor; 52] = [
command("help.show", GameCreationAppPermission::Auto),
command("project.create", GameCreationAppPermission::Confirm),
command("project.status", GameCreationAppPermission::Auto),
@@ -63,6 +63,7 @@ pub const GAME_CREATION_APP_COMMANDS: [GameCreationAppCommandDescriptor; 51] = [
command("preview.stop", GameCreationAppPermission::Auto),
command("preview.status", GameCreationAppPermission::Auto),
command("command.run_limited", GameCreationAppPermission::Confirm),
command("command.exec", GameCreationAppPermission::Confirm),
command("canvas.project_open", GameCreationAppPermission::Confirm),
command("canvas.project_sync", GameCreationAppPermission::Confirm),
command("canvas.asset_import", GameCreationAppPermission::Confirm),
@@ -90,7 +91,7 @@ pub struct GameCreationAgentCapabilityDescriptor {
pub title: &'static str,
}
pub const GAME_CREATION_AGENT_CAPABILITIES: [GameCreationAgentCapabilityDescriptor; 31] = [
pub const GAME_CREATION_AGENT_CAPABILITIES: [GameCreationAgentCapabilityDescriptor; 32] = [
capability("chat", "user", "聊天入口"),
capability("file-upload", "user", "上传文件"),
capability("built-in-commands", "agent-runtime", "内置命令调用"),
@@ -135,6 +136,11 @@ pub const GAME_CREATION_AGENT_CAPABILITIES: [GameCreationAgentCapabilityDescript
capability("canvas-project-sync", "local-runtime", "画板项目资源同步"),
capability("developer-window", "dev-runtime", "开发窗口"),
capability("persistent-runner", "dev-runtime", "独立持久 Runner"),
capability(
"command-exec",
"dev-runtime",
"受控命令执行(固定 program + argv、非 shell、项目内 cwd、有界输出)",
),
capability("guardrails", "dev-runtime", "权限 Gate"),
capability("project-policy", "dev-runtime", "项目级权限策略"),
capability("trace-log", "dev-runtime", "执行日志"),
@@ -631,6 +637,22 @@ mod tests {
#[test]
fn command_contract_keeps_expected_permissions() {
assert_eq!(GAME_CREATION_APP_COMMANDS.len(), 52);
let command_ids = GAME_CREATION_APP_COMMANDS
.iter()
.map(|command| command.id)
.collect::<Vec<_>>();
let limited_index = command_ids
.iter()
.position(|command_id| *command_id == "command.run_limited")
.expect("command.run_limited should exist");
let exec_index = command_ids
.iter()
.position(|command_id| *command_id == "command.exec")
.expect("command.exec should exist");
assert_eq!(exec_index, limited_index + 1);
let help = GAME_CREATION_APP_COMMANDS
.iter()
.find(|command| command.id == "help.show")
@@ -643,6 +665,12 @@ mod tests {
.expect("command should exist");
assert_eq!(command.permission, GameCreationAppPermission::Confirm);
let command_exec = GAME_CREATION_APP_COMMANDS
.iter()
.find(|command| command.id == "command.exec")
.expect("command.exec should exist");
assert_eq!(command_exec.permission, GameCreationAppPermission::Confirm);
let project_verify = GAME_CREATION_APP_COMMANDS
.iter()
.find(|command| command.id == "project.verify")
@@ -849,6 +877,8 @@ mod tests {
#[test]
fn capabilities_cover_standard_agent_runtime_needs() {
assert_eq!(GAME_CREATION_AGENT_CAPABILITIES.len(), 32);
let ids = GAME_CREATION_AGENT_CAPABILITIES
.iter()
.map(|capability| capability.id)
@@ -873,9 +903,19 @@ mod tests {
"canvas-project-sync",
"local-preview",
"developer-window",
"command-exec",
] {
assert!(ids.contains(&expected), "missing {expected}");
}
let command_exec = GAME_CREATION_AGENT_CAPABILITIES
.iter()
.find(|capability| capability.id == "command-exec")
.expect("command-exec capability should exist");
assert_eq!(command_exec.area, "dev-runtime");
assert_eq!(
command_exec.title,
"受控命令执行(固定 program + argv、非 shell、项目内 cwd、有界输出)"
);
assert_eq!(
GAME_CREATION_AGENT_CAPABILITIES
.iter()