f121257cca
- 四个 direct_* 文件移入 agent/thread_manager:wire.rs(运行态事件契约)、queue.rs(待发消息队列规则)、dispatch.rs(放行与占用)、mod.rs(管理器主体与对外入口) - 类型去掉 Direct 前缀:ThreadEvent / ThreadManager / ThreadItem / ThreadFileChange / ThreadDeltaKind / ThreadRequestKind / PendingTurn / QueueRemovalReason / QueueRemovalOutcome / DispatchedTurn / TurnReservation / TurnIdentity / StaleTurnRelease / ConsumeResult / SubscriptionBootstrap / ActiveTurn / ActiveTurnSnapshot - 对外函数改名:subscribe_thread / consume_thread / unsubscribe_thread / append_thread_event / enqueue_pending_turn / remove_pending_turn / claim_pending_turn / update_active_turn / list_active_turns / complete_turn / complete_turn_if_reserved / active_turn_id_at / read_turn_identity / stale_turn_for_release / thread_id_for_project - 生成绑定跟着改名(DirectThreadEvent→ThreadEvent 等十个文件为 rename),前端八处 import 同步;Tauri 命令名与前端 IPC 契约不变 - 定向验证:cargo test agent::(945 passed,另两条并发用例为既有 flaky、重跑通过)、npx vitest run appSurface/directThreadChat/directHistoryPaging(247 passed)、typecheck 通过
153 lines
5.1 KiB
Rust
153 lines
5.1 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 claude_code_cli;
|
|
mod codex_app_server;
|
|
mod codex_cli;
|
|
mod codex_provider_proxy;
|
|
mod design_runtime;
|
|
pub(crate) mod design_tools;
|
|
mod direct_codex_attachments;
|
|
mod direct_codex_user_item;
|
|
mod direct_execution;
|
|
pub(crate) use direct_execution::WritePermit;
|
|
mod direct_delivery;
|
|
mod direct_paid_submission;
|
|
mod direct_patch;
|
|
pub(crate) use direct_paid_submission::ensure_direct_paid_submission_dispatch;
|
|
#[cfg(test)]
|
|
pub(crate) use direct_paid_submission::with_test_direct_paid_submission_scope;
|
|
mod direct_project_context;
|
|
mod direct_project_history;
|
|
mod direct_project_turn_history;
|
|
mod direct_runtime;
|
|
mod direct_tool_bridge;
|
|
mod direct_tool_calls;
|
|
mod direct_tools_mcp;
|
|
mod direct_turn_error;
|
|
mod direct_turn_failure;
|
|
mod direct_turn_stream;
|
|
mod direct_validation;
|
|
mod generation;
|
|
mod prompt;
|
|
mod runtime_actions;
|
|
mod runtime_adapter;
|
|
mod runtime_driver;
|
|
mod runtime_error;
|
|
mod runtime_protocol;
|
|
mod runtime_state;
|
|
mod runtime_tools;
|
|
mod skill_pack;
|
|
mod thread_manager;
|
|
|
|
use claude_code_cli::*;
|
|
pub(crate) use claude_code_cli::{
|
|
cancel_direct_claude_code_turn_at, direct_game_creator_claude_code_chat_at,
|
|
direct_game_creator_claude_code_home_chat, game_creator_claude_code_cli_route_error,
|
|
game_creator_claude_code_cli_version_identity,
|
|
};
|
|
use codex_app_server::*;
|
|
pub(crate) use codex_app_server::{
|
|
cancel_direct_codex_turn_at, direct_game_creator_codex_chat_at,
|
|
direct_game_creator_home_codex_chat, thread_id_for_project, DirectTurnCancelView,
|
|
};
|
|
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_user_item::*;
|
|
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_tool_calls::*;
|
|
pub(crate) use direct_tools_mcp::*;
|
|
pub(crate) use direct_turn_error::*;
|
|
pub(crate) use direct_turn_failure::*;
|
|
pub(crate) use direct_turn_stream::*;
|
|
pub(crate) use direct_validation::DirectValidationConfig;
|
|
pub(crate) use generation::*;
|
|
pub(crate) use prompt::*;
|
|
pub(crate) use runtime_actions::*;
|
|
pub(crate) use runtime_adapter::*;
|
|
pub(crate) use runtime_driver::*;
|
|
pub(crate) use runtime_error::*;
|
|
pub(crate) use runtime_protocol::*;
|
|
pub(crate) use runtime_state::*;
|
|
pub(crate) use runtime_tools::*;
|
|
pub(crate) use skill_pack::*;
|
|
pub(crate) use thread_manager::dispatch::*;
|
|
pub(crate) use thread_manager::queue::*;
|
|
pub(crate) use thread_manager::wire::*;
|
|
pub(crate) use thread_manager::*;
|
|
|
|
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())
|
|
}
|
|
}
|
|
}
|