Files
Genarrative/apps/ai-game-creator-shell/src-tauri/src/runner.rs
T
kdletters 54d0fb75ea 接入 Godot 编辑器插件与受控执行链路
新增 GDExtension 自动引导、GDScript 执行和实例隔离缓存
接入 AGC 插件开关、Runner、Agent 工具与权限审计
完善执行回执确认、不确定状态阻断及卸载恢复
补齐 Windows 分发资源、定向测试与实机验收文档
2026-09-20 16:35:04 +08:00

75 lines
3.2 KiB
Rust

mod client;
mod dispatch;
mod endpoint;
mod project_owner;
mod protocol;
mod server;
mod state;
#[allow(unused_imports)]
pub(crate) use client::{
attach_external_agent_runner_gui_owner, cancel_external_agent_runner_goal,
clear_external_agent_runner_platform_session, compact_external_agent_runner_context,
configure_external_agent_runner, configure_external_agent_runner_read_only,
continue_external_agent_runner_action, ensure_external_agent_runner_started,
ensure_external_agent_runner_started_for_gui, hold_external_agent_runner_gui_participant_lock,
install_external_agent_runner_platform_session,
interrupt_external_agent_runner_provider_for_steer_decision, notify_external_agent_runner,
pause_external_agent_runner, read_external_agent_runner_status,
require_external_agent_runner_configured_for_cli_runtime_write,
require_external_agent_runner_for_cli_runtime_write, resume_external_agent_runner,
shutdown_external_agent_runner, shutdown_external_agent_runner_for_client_exit,
shutdown_external_agent_runner_for_gui_exit, shutdown_external_agent_runner_if_idle,
steer_external_agent_runner, wake_external_agent_runner_pending,
wake_external_agent_runner_pending_for_run,
};
pub(crate) use client::{
call_external_managed_editor, disconnect_external_managed_editor,
disconnect_external_managed_editor_project, mark_external_editor_uncertain,
};
#[cfg(windows)]
pub(crate) use endpoint::validate_windows_regular_file_handle;
pub(crate) use endpoint::{external_agent_runner_enabled, external_agent_runner_is_server_process};
#[allow(unused_imports)]
pub(crate) use protocol::{ExternalAgentRunnerStatus, EXTERNAL_AGENT_RUNNER_PROTOCOL_VERSION};
pub(crate) use server::{
bind_loopback_listener_with_linux_fallback, run_external_agent_runner_server,
};
#[cfg(test)]
pub(crate) fn simulate_external_agent_runner_cross_boot_owner_claim_for_test(
root: &std::path::Path,
config_dir: &std::path::Path,
previous_boot_id: &str,
current_boot_id: &str,
) -> Result<(std::path::PathBuf, Option<String>), String> {
let previous = project_owner::acquire_external_agent_runner_project_execution_owner(
root,
previous_boot_id,
protocol::EXTERNAL_AGENT_RUNNER_PROTOCOL_VERSION,
)?;
drop(previous);
let state = state::ExternalAgentRunnerServerState::new(
config_dir.join(protocol::EXTERNAL_AGENT_RUNNER_ENDPOINT_FILE_NAME),
protocol::ExternalAgentRunnerEndpoint {
protocol_version: protocol::EXTERNAL_AGENT_RUNNER_PROTOCOL_VERSION,
pid: std::process::id(),
boot_id: current_boot_id.to_string(),
port: 41009,
token: "owner-provider-token-owner-provider-token".to_string(),
heartbeat_at: 1_725_000_000_000,
executable_fingerprint: Some("a".repeat(64)),
process_start_identity: None,
},
);
let claim = state.claim_project_execution_owner(root)?;
let result = (claim.root, claim.recovered_from_boot_id);
let second = state.claim_project_execution_owner(root)?;
if second.recovered_from_boot_id.is_some() {
return Err("同 boot execution owner 重入重复触发恢复".to_string());
}
Ok(result)
}
#[cfg(test)]
mod tests;