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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use bevy::prelude::Resource;
use std::{net::SocketAddr, path::PathBuf, time::Duration};
/// Runtime configuration for [`crate::AgentFeedbackPlugin`].
///
/// Defaults bind to localhost on port `15712`, write `agent-feedback.json`,
/// keep captures in `agent-feedback-captures`, and refresh a heartbeat for v2
/// stale-session checks.
#[derive(Clone, Debug, Resource)]
pub struct AgentFeedbackConfig {
/// TCP address used by the local JSON-lines control socket.
///
/// Use port `0` to let the operating system choose a free port. The chosen
/// address is written to [`protocol_file`](Self::protocol_file).
pub bind_addr: SocketAddr,
/// JSON file written at startup so Pi/Codex agents can discover the socket.
pub protocol_file: PathBuf,
/// Directory where `capture` commands write PNG screenshots.
pub capture_dir: PathBuf,
/// Maximum queued agent commands drained per frame.
pub max_pending_commands: usize,
/// Maximum accepted frame count for a single `wait` command.
pub max_wait_frames: u16,
/// Maximum accepted step count for compound actions such as `drag`.
pub max_action_steps: u16,
/// How often the plugin refreshes the session heartbeat file.
pub heartbeat_interval: Duration,
/// How old the heartbeat may be before clients reject the session as stale.
pub session_stale_after: Duration,
/// Maximum number of retained PNG captures.
///
/// Older capture files created by this plugin are removed after this limit.
pub max_captures: usize,
/// Maximum time a socket client waits for the game to answer a command.
pub command_timeout: Duration,
/// Optional app exit after no accepted agent commands for this duration.
/// Values below 5 seconds are clamped up; `None` disables idle shutdown.
pub idle_shutdown_after: Option<Duration>,
}
impl Default for AgentFeedbackConfig {
fn default() -> Self {
Self {
bind_addr: SocketAddr::from(([127, 0, 0, 1], 15712)),
protocol_file: PathBuf::from("agent-feedback.json"),
capture_dir: PathBuf::from("agent-feedback-captures"),
max_pending_commands: 32,
max_wait_frames: 300,
max_action_steps: 120,
heartbeat_interval: Duration::from_millis(250),
session_stale_after: Duration::from_secs(3),
max_captures: 32,
command_timeout: Duration::from_secs(10),
idle_shutdown_after: None,
}
}
}