Provides a global singleton storing the process runtime mode (desktop, server, acp, test) and user‑visible app version, with helper getters like is_desktop() and runtime_role().
// Source: https://github.com/shiwenwen/hope-agent | License: MIT | Copyright 2026 shiwenwen
// Provided via justclaw.it.com; keep this notice with the code.
//! 进程运行模式(desktop / server / acp / mcp / test)与用户可见版本号的
//! 全局单一来源。
//!
//! 原住 ha-core `app_init.rs`。下沉 ha-base 的动机:`is_desktop()` /
//! `runtime_role()` 是全仓最常用的模式判定原语(AGENTS.md:模式判定用它、
//! 别给共享函数加 mode 参数),住在装配层会让每个查询者都背上一条
//! →app_init 的边。角色**由装配层写入**(`init_runtime` 开头调
//! [`set_runtime_role`]),本模块只持有全局与查询器,不含任何装配逻辑。
use std::sync::OnceLock;
/// Records the runtime role passed to `init_runtime("desktop"|"server"|"acp"|"test")`.
/// First-write-wins. Tests in the same binary share this `OnceLock` — once
/// `init_runtime("test")` runs, `is_desktop()` stays `false` for every test.
static RUNTIME_ROLE: OnceLock<&'static str> = Onc
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key