Files
Genarrative/apps/ai-game-creator-shell/src-tauri/src/agent.rs
T
suzmii 87fbf92c58
Project CI / Repository checks (pull_request) Successful in 3m14s
Project CI / Frontend tests (pull_request) Successful in 3m57s
Project CI / Backend tests (pull_request) Successful in 6m30s
Project CI / Native shell tests (pull_request) Successful in 17m27s
合并 origin/master 到资源工作台 V3 分支:解 4 处冲突并保留两侧行为
- WorkspaceLauncher.tsx:保留本分支清单快照 CAS 拒收提示(manifestMergeNotice 提示条、data-manifest-merge-* 观察点、recoverRejectedManifestSnapshot「重新读取清单」)与 activeVersionId/onActiveVersionChange 版本口径,并入 master 的策划/游戏运行态切换(onMakeGame + switchToGameRuntime、suppressInitialGameTurn 抑制首轮、supervisor key 带 agentRuntimeMode、onSwitchToGameRuntime),planningStartMode 统一取 master 的派生值(上下文 startMode 为 planning 且未切到 game 运行时)
- ProjectSupervisorView.tsx:props 同时保留本分支 versions/activeVersionId 与 master 的 designView/onDesignApprove/onDesignClarify/onDesignRetry,DesignAgentSurface 审批链路与本分支资源引用输入区并存;directCodex 输入区保留本分支 @ 引用按钮 + 模型选择 + 发送按钮控制条,发送按钮禁用条件并入 master 的 designView 审批待定口径,模型选择沿用 master 的「对话中可切换」口径
- styles.css:本分支追加的资源画布/输入区样式块与 master 追加的 .design-agent-reasoning 样式块都保留,并补上本分支最后一条规则的收尾大括号
- view/project-development/index.tsx:保留本分支的 image-editor 引用(ImageCanvasProjectAssetPickerDialog、ImageCanvasQuickEditPanelView、ImageCanvasSelectedLayerToolbarView、useImageCanvasFloatingOptionDismiss),去掉 master 对已退役 features/asset-canvas 的 import(本分支已由 resource-canvas 取代),保留 master 的 DesignWorkspacePanel 与 planningStartMode 策划工作台分支
- tests/workspaceLauncherManifestMerge.test.tsx:补 master 新引入的 get_design_agent_runtime_mode mock(返回 null,与 master 各套件同口径),拒收提示断言不变
- tests/appSurface/design-agent.suite.ts:审批待定禁用输入的断言改用本分支 Lexical 输入区的禁用口径(容器 data-disabled + editor.setEditable(false)),断言意图不变
- 验证:npm run typecheck 通过;apps/ai-game-creator-shell typecheck 通过;apps/ai-game-creator-shell/tests 96 个测试文件 1380 通过 4 跳过 0 失败;全仓 vitest 297 通过 2 失败(scripts 下两例为 Windows 权限语义导致的既有失败,相关文件与实现均未参与本次合并);npm run check:encoding 与 git diff --check 通过
2026-09-12 17:31:51 +08:00

122 lines
3.9 KiB
Rust

use super::*;
use crate::provider_handoff;
use crate::provider_retry::{
self, AgentRuntimeProviderRetryIdentity, AgentRuntimeProviderRetryRecord,
};
use crate::tool_plan_handoff;
use sha2::{Digest, Sha256};
use std::collections::BTreeSet;
use std::io::{Seek, SeekFrom};
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
mod codex_app_server;
mod codex_cli;
mod codex_provider_proxy;
mod design_runtime;
mod design_tools;
mod direct_codex_attachments;
mod direct_codex_audit;
mod direct_codex_references;
mod direct_project_history;
mod direct_project_turn_history;
mod direct_runtime;
mod direct_tool_bridge;
mod direct_tools_mcp;
mod generation;
mod interaction;
mod prompt;
mod runtime_actions;
mod runtime_adapter;
mod runtime_driver;
mod runtime_protocol;
mod runtime_state;
mod runtime_tools;
mod skill_pack;
use codex_app_server::*;
pub(crate) use codex_app_server::{
direct_game_creator_codex_chat_at, direct_game_creator_home_codex_chat,
};
use codex_cli::*;
pub(crate) use codex_cli::{
game_creator_codex_cli_executable_path, game_creator_codex_cli_version_identity,
};
pub(crate) use codex_provider_proxy::*;
pub(crate) use design_runtime::*;
pub(crate) use direct_codex_attachments::*;
pub(crate) use direct_codex_audit::*;
pub(crate) use direct_codex_references::*;
pub(crate) use direct_project_history::*;
pub(crate) use direct_project_turn_history::*;
pub(crate) use direct_runtime::*;
pub(crate) use direct_tool_bridge::*;
pub(crate) use direct_tools_mcp::*;
pub(crate) use generation::*;
pub(crate) use interaction::*;
pub(crate) use prompt::*;
pub(crate) use runtime_actions::*;
pub(crate) use runtime_adapter::*;
pub(crate) use runtime_driver::*;
pub(crate) use runtime_protocol::*;
pub(crate) use runtime_state::*;
pub(crate) use runtime_tools::*;
pub(crate) use skill_pack::*;
pub(crate) fn shutdown_game_creator_codex_app_servers() -> Result<(), String> {
shutdown_game_creator_codex_app_servers_impl()
}
/// Execute a UI editor provider request under the active Agent Runtime
/// identity. UI State remains the persistence authority; this adapter only
/// routes the semantic request through the same mode/lifecycle/retry boundary
/// used by the autonomous Agent.
pub(crate) async fn request_game_creator_ui_editor_llm_at(
root: &Path,
agent_id: &str,
run_id: &str,
operation: &str,
request: LlmRunRequest,
) -> Result<platform_llm::LlmRunResponse, String> {
let config = load_game_creator_app_config()?;
let api_kind = parse_game_creator_llm_api_kind(&config.llm.api_kind)?;
let request = request
.with_api_kind(api_kind)
.with_model(config.llm.model.clone())
.with_request_timeout_ms(config.llm.request_timeout_ms);
let request = apply_game_creator_llm_reasoning_effort(request, &config.llm)?;
let snapshot = {
let _lock = acquire_game_creator_agent_runtime_project_write_lock_with_wait(
root,
"runtime.provider_request.capture.ui_editor",
)?;
let task = read_latest_game_creator_agent_runtime_task_by_run_id(root, agent_id, run_id)?
.ok_or_else(|| {
"UI 编辑器 Provider 请求缺少当前 Agent run 的持久任务".to_string()
})?;
let runtime = read_game_creator_agent_runtime_at(root, agent_id)?.state;
capture_game_creator_agent_runtime_provider_request_snapshot_at_locked(
root,
agent_id,
&task.session_id,
run_id,
operation,
&format!("ui-editor-{operation}-{}", task.task_id),
runtime.applied_steer_cursor,
)?
};
match request_game_creator_agent_runtime_llm_with_transient_retries(
root,
&snapshot,
&config.llm,
"llm",
operation,
&request,
)
.await?
{
Some(response) => Ok(response),
None => {
Err("UI 编辑器 Provider 请求未返回结果(当前 Runtime 正在等待恢复或确认)".to_string())
}
}
}