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
69
70
71
//! Output treatments: the embedder's judgement of what a script's output is.
//!
//! The output pipeline cleans what a command prints for the model: it renders
//! the bytes as a terminal shows them, then collapses runs of blank lines and
//! turns a JSON array of records into TSV. That fits command output, but a
//! script that reads a file prints the file, and cleaning it hands the model
//! text the file does not hold. Which scripts produce content of that kind is
//! the embedder's judgement, so the [`ShellBuilder`](crate::ShellBuilder)
//! takes a [`TreatOutput`] that sees each script before it runs and chooses
//! its [`OutputTreatment`]. Without one every script's output is treated as
//! [`Command`](OutputTreatment::Command) output.
use fmt;
use Arc;
use crateScriptCheck;
/// What the shell does to a foreground script's text output before the
/// model reads it.
///
/// Either way the output is rendered as a terminal shows it: escape
/// sequences are consumed and `\r` resolves to the last frame of each line.
/// Output over the inline budget is cut the same way under both: the text
/// is written to disk whole and named, and the model reads a folded view or
/// a preview of it.
/// Chooses the [`OutputTreatment`] of every script of a shell, before it
/// runs.
///
/// Every script of the `terminal` tool, the main agent's and every
/// subagent's, and every [`Shell::run`](crate::Shell::run), is put to it
/// with the same view its [`ScriptPolicy`](crate::ScriptPolicy)s see, the
/// shell parsed once for all of them.
/// A type-erased [`TreatOutput`], shared by a shell and the subagent shells
/// derived from it.
;