Repository navigation
Expand file tree
/
Copy pathprocess.go
More file actions
114 lines (107 loc) · 3.94 KB
/
Copy pathprocess.go
File metadata and controls
114 lines (107 loc) · 3.94 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package crux
import (
"time"
"github.com/hivecommons/hive/crux/config"
)
// Process is the observable snapshot of one agent: state, pins, overrides,
// kick history, pane-derived conditions. It is what Observer.GetStatus and
// Observer.AllStatuses return.
//
// It is its own type, not the runtime's internal agent record: crux/agent
// copies the exported fields of its AgentProcess into a Process when it takes
// a snapshot, so this package does not import crux/agent (#13962, #13963).
// The field meanings are documented on agent.AgentProcess. A snapshot is a
// read-only display value; writing to one does not change the runtime.
type Process struct {
Name string
ID string
Config config.AgentConfig
State ProcessState
PID int
UID int
StartedAt *time.Time
LastKick *time.Time
KicksUndeliverable int
BusySince time.Time
LastTranscriptActivity time.Time
BusyCondition string
BusyConditionMessage string
Paused bool
PausedAt time.Time
PausedReason string
PausedTrigger string
PausedBy string
OperatorStopped bool
PinnedCLI string
PinnedModel string
ModelOverride string
BackendOverride string
RestartCount int
RestartEvents []RestartEvent
LastRestartReason string
OutputBuffer *RingBuffer
SubAgentModels []SubAgentModel
KickHistory []KickRecord
LastKickMessage string
KickRefused bool
KickRefusalReason string
LaunchedMode AgentMode
HasLaunched bool
BootstrapOverride string
LastError string
NeedsLogin bool
LoginURL string
Starting bool
QuotaExhausted bool
WatchdogConditions []Condition
LastPaneChange time.Time
StallNudges int
StallRecoveries int
// SessionRSSMB is the resident memory of the CLI process tree under the
// agent's tmux pane, in MiB, as of the last health tick (#14842). 0 when
// never sampled. SessionRecycles counts policy recycles since boot.
SessionRSSMB int
SessionRecycles int
CIPollNudges int
AwaitingCI bool
TransientNudges int
ProviderErrorClass string
ProviderErrorLine string
ProviderErrorBackoffUntil time.Time
BackendAuth BackendAuthState
TurnLoss TurnLoss
ActionNudges int
KickOutcome KickOutcome
SandboxLastRun *SandboxRun
StartFailureClass string
StartFailureReason string
StartFailureCount int
StartFailureLastAt time.Time
StartFailureExitCode *int
StartFailureSignal string
StartBlocked bool
StartBackoffUntil time.Time
paneCapture []string
paneFilter func(lines []string, n int) []string
}
// SetPaneCapture records the pane capture a snapshot was taken with and the
// runtime's filter for it, which PaneLines and FilteredPaneLines apply. The
// runtime calls it when it builds a snapshot; lines must not be shared with
// the live capture.
func (p *Process) SetPaneCapture(lines []string, filter func(lines []string, n int) []string) {
p.paneCapture = lines
p.paneFilter = filter
}
// PaneLines returns the last n lines from the most recent tmux pane capture,
// preferring content from the current CLI session (after the last ❯ prompt).
// Falls back to showing the full tail if the current session has too few lines.
func (p *Process) PaneLines(n int) []string {
if len(p.paneCapture) == 0 || p.paneFilter == nil {
return nil
}
return p.paneFilter(p.paneCapture, n)
}
// FilteredPaneLines is PaneLines; both names are kept for their callers.
func (p *Process) FilteredPaneLines(n int) []string {
return p.PaneLines(n)
}