1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Pre-spawn daemon liveness gate and daemon-backed tool runner.
//!
//! Phase 4 delivered `ensure_daemon_running` — the liveness probe gate.
//! Phase 5 adds `run_daemon` — the full spawn path for daemon-class tools
//! (currently OpenClaw via the `acpx` client).
//!
//! # Design
//!
//! `run_daemon` first calls `ensure_daemon_running` to verify the daemon is
//! reachable, then delegates to [`pipe_runner::run_pipe`] for the actual
//! process spawn. The `acpx` client communicates over NDJSON like any other
//! pipe-mode CLI; the only difference is the pre-spawn daemon check.
use crateprobe_daemon;
use crateAgentError;
use crate;
use crate;
use crateCliTool;
/// Probe daemon liveness, returning early if the daemon is unreachable.
///
/// Call this before spawning a daemon-class client (e.g. `acpx openclaw`).
/// Returns `Ok(())` if the daemon is accepting TCP connections, or an
/// appropriate `AgentError` variant if not.
///
/// See `probe_daemon` in `crate::daemon::probe` for the full error semantics.
/// Spawn a daemon-backed CLI process and return a [`PipeRunnerHandle`].
///
/// 1. Calls [`ensure_daemon_running`] against `probe`.
/// Returns `Err(DaemonNotRunning)` or `Err(DaemonProbeTimeout)` on failure.
/// 2. Delegates to [`run_pipe`] to spawn the client command (e.g. `acpx openclaw`).
///
/// The `tool` determines which `CliCommandBuilder` and NDJSON parser are selected,
/// just as with `run_pipe`. For OpenClaw, this selects `OpenClawPipeBuilder` and
/// `OpenClawNdjsonParser`.