refactor: rename COLIBRI_AUTOSPAWN_PI → COLIBRI_AUTOSPAWN
Harness-neutral naming throughout the daemon: - COLIBRI_AUTOSPAWN_PI → COLIBRI_AUTOSPAWN - COLIBRI_PI_BINARY → COLIBRI_AUTOSPAWN_BINARY (default: zot) - COLIBRI_AUTOSPAWN_PI_ARGS → COLIBRI_AUTOSPAWN_ARGS - Function: autospawn_pi_if_configured → autospawn_agent_if_configured - Log prefix: autospawn-pi → autospawn - Variable: pi_binary → agent_binary, pi_name → agent_name
This commit is contained in:
parent
381f530ed8
commit
c3e91189f3
2 changed files with 20 additions and 22 deletions
|
|
@ -76,8 +76,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
// Auto-spawn one Pi agent if configured (live "Operator Image" OOTB flow).
|
||||
// Runs after the socket server is up so the spawn registers on the board;
|
||||
// no-op unless COLIBRI_AUTOSPAWN_PI is set and a DeepSeek key is present.
|
||||
socket::autospawn_pi_if_configured(&state).await;
|
||||
// no-op unless COLIBRI_AUTOSPAWN is set and a DeepSeek key is present.
|
||||
socket::autospawn_agent_if_configured(&state).await;
|
||||
|
||||
// Start the daemon background loop (heartbeat, session rotation, scheduler)
|
||||
let loop_state = state.clone();
|
||||
|
|
|
|||
|
|
@ -400,47 +400,45 @@ async fn cmd_list_sessions(state: &SharedState) -> ColibriResponse {
|
|||
}))
|
||||
}
|
||||
|
||||
/// Auto-spawn a single Pi agent at daemon startup when configured.
|
||||
/// Auto-spawn a single agent at daemon startup when configured.
|
||||
///
|
||||
/// Enabled with `COLIBRI_AUTOSPAWN_PI` (`YES`/`1`/`true`/`on`). Requires a
|
||||
/// Enabled with `COLIBRI_AUTOSPAWN` (`YES`/`1`/`true`/`on`). Requires a
|
||||
/// `DEEPSEEK_API_KEY` in the daemon environment (sourced from `provider.env`) —
|
||||
/// the host-spawned Pi inherits it. Idempotent: skips when a Pi subprocess is
|
||||
/// already running, so a daemon restart (e.g. after the operator enters creds
|
||||
/// and `service colibri_daemon restart` runs) does not stack duplicates.
|
||||
/// the host-spawned agent inherits it. Idempotent: skips when an agent subprocess
|
||||
/// is already running, so a daemon restart does not stack duplicates.
|
||||
///
|
||||
/// The live "Operator Image" is single-agent, so the Pi runs on the host (no
|
||||
/// jail). Binary and argv are env-tunable so the exact Pi invocation can be
|
||||
/// adjusted on the image without a rebuild:
|
||||
/// - `COLIBRI_PI_BINARY` (default `pi`)
|
||||
/// - `COLIBRI_AUTOSPAWN_PI_ARGS` (default `--mode json`)
|
||||
pub async fn autospawn_pi_if_configured(state: &SharedState) {
|
||||
if !env_truthy("COLIBRI_AUTOSPAWN_PI") {
|
||||
/// The live "Operator Image" is single-agent, so the agent runs on the host (no
|
||||
/// jail). Binary and argv are env-tunable without a rebuild:
|
||||
/// - `COLIBRI_AUTOSPAWN_BINARY` (default `zot`)
|
||||
/// - `COLIBRI_AUTOSPAWN_ARGS` (default `--mode json`)
|
||||
pub async fn autospawn_agent_if_configured(state: &SharedState) {
|
||||
if !env_truthy("COLIBRI_AUTOSPAWN") {
|
||||
return;
|
||||
}
|
||||
if state.config.deepseek_api_key.is_none() {
|
||||
info!(
|
||||
"autospawn-pi: DEEPSEEK_API_KEY not set; skipping (operator can add it via Join Hive)"
|
||||
"autospawn: DEEPSEEK_API_KEY not set; skipping (operator can add it via Join Hive)"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let pi_binary = std::env::var("COLIBRI_PI_BINARY")
|
||||
let agent_binary = std::env::var("COLIBRI_AUTOSPAWN_BINARY")
|
||||
.ok()
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.unwrap_or_else(|| "pi".to_string());
|
||||
.unwrap_or_else(|| "zot".to_string());
|
||||
|
||||
// One Pi is enough. Match by binary basename so a restart does not duplicate.
|
||||
let pi_name = basename(&pi_binary);
|
||||
// One agent is enough. Match by binary basename so a restart does not duplicate.
|
||||
let agent_name = basename(&agent_binary);
|
||||
let already = state
|
||||
.agents
|
||||
.iter()
|
||||
.any(|e| basename(&e.value().config.binary) == pi_name);
|
||||
.any(|e| basename(&e.value().config.binary) == agent_name);
|
||||
if already {
|
||||
info!(pi = %pi_name, "autospawn-pi: a Pi agent is already running; skipping");
|
||||
info!(agent = %agent_name, "autospawn: an agent is already running; skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
let args: Vec<String> = std::env::var("COLIBRI_AUTOSPAWN_PI_ARGS")
|
||||
let args: Vec<String> = std::env::var("COLIBRI_AUTOSPAWN_ARGS")
|
||||
.ok()
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.unwrap_or_else(|| "--mode json".to_string())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue