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
68
//! Output capping and signal-name lookup for the bash executor. Both
//! stdout and stderr are capped at [`MAX_BASH_OUTPUT_BYTES`] before
//! truncation — large per-stream output is rejected outright so the
//! tool result stays under the API's payload ceiling.
use Duration;
/// Hard per-stream byte cap on bash output. Past this the executor
/// returns a `ToolExecution` error rather than truncating, so the
/// model sees the failure clearly instead of a silently chopped
/// `stdout` that might happen to end mid-statement.
pub const MAX_BASH_OUTPUT_BYTES: usize = 10 * 1024 * 1024;
/// Wall-clock ceiling on a single bash invocation. Past this the
/// supervisor kills the child process tree and surfaces a clear
/// "timeout" message instead of blocking the turn forever on a stuck
/// build, hung test runner, or accidental `tail -f`.
pub const BASH_COMMAND_TIMEOUT: Duration = from_secs;
/// How often the supervisor polls for child exit, output overflow,
/// interrupt, and timeout. Short enough that the user does not feel
/// latency on ESC; long enough that the loop is not a busy wait.
pub const SUPERVISOR_POLL_INTERVAL: Duration = from_millis;
/// Buffer size used by the per-stream reader threads. 8 KiB matches
/// the kernel pipe buffer chunk most operating systems hand out, which
/// keeps the read loop in step with how the OS delivers writes.
pub const BASH_READ_CHUNK_BYTES: usize = 8 * 1024;
/// Grace period between sending `SIGTERM` to the child process group
/// and escalating to `SIGKILL`. Enough time for a well-behaved shell
/// or test runner to print a final line and exit, short enough that a
/// stuck process is killed promptly when the user hits ESC.
pub const TERMINATION_GRACE_PERIOD: Duration = from_millis;
/// Why the supervisor terminated a running bash command before its
/// natural exit. The executor maps each variant to a distinct error
/// message so the model can recognise the failure mode.
pub
/// Convert a Unix signal number to its standard short name. Used by
/// the executor when a command was killed by a signal rather than
/// exiting normally — `signal: 9 (SIGKILL)` reads better than the
/// bare integer for both humans and the model.
pub