Documentation
¶
Overview ¶
Package opsview is the ops view: a gotth-live page that shows every harness session on this machine as a live card, read from the run directories under the harness state directory. Each card is a widget SDK widget in a keyed collection; cards update the moment a line lands in a session's event log, because the page follows the files through the kernel's change notification rather than polling them.
It is a service: it owns no listener and no process. The harness host app grants it the file and watch capabilities over the state directory, mounts it into the host runtime and binds the listener.
Index ¶
Constants ¶
const ( PagePath = "/" LivePath = "/live" // BoardRegion is the parent region every card lives in: the keyed // collection's region, so a card's region is BoardRegion:<assignment>. BoardRegion = "opsview.sessions" )
Routes: the page and the live mount under it. The live handler serves its own runtime script beneath the mount.
const ( KindTool = "tool" KindGate = "gate" KindHarness = "harness" KindResult = "result" KindMessage = "message" )
The kinds of recent event a card lists, which are also its CSS classes.
const ( WidgetName = "SessionCard" // EventSession carries one whole card, as JSON in the card field. It is // internal: the follow effect emits it, and a browser may not, because a // browser posting one would be forging the event log's own truth. EventSession = "opsview.session" FieldCard = "card" // EventExpand is the one event a browser may send: show or hide the rest // of a card's recent events. It reads nothing and changes no session. EventExpand = "opsview.expand" )
The session widget's identity on the wire. Every card is one instance of this definition under the board's keyed collection, at region opsview.sessions:<assignment>; the board region is the collection's own.
Variables ¶
var ( // ErrNoFiles reports a view built without the file capability. ErrNoFiles = errors.New("ops view: the file capability over the state directory is required") // ErrNoWatcher reports a view built without the watch capability. ErrNoWatcher = errors.New("ops view: the watch capability over the state directory is required") )
Functions ¶
Types ¶
type OpsView ¶
type OpsView struct {
// contains filtered or unexported fields
}
OpsView is the live application and its routes.
func NewOpsView ¶
func NewOpsView(files ipcfs.IFiles, watcher ipcfs.IWatcher, origins []string, logger *slog.Logger) (*OpsView, error)
NewOpsView builds the view over the harness state directory: files reads it and watcher reports its changes. origins is the browser Origin allowlist, one per address the host serves; nothing else is accepted.
type RecentEvent ¶
type RecentEvent struct {
Time string `json:"time"`
Kind string `json:"kind"`
Text string `json:"text"`
}
RecentEvent is one of the last few typed events a card shows.
type SessionCard ¶
type SessionCard struct {
Assignment string `json:"assignment"`
Agent string `json:"agent"`
Branch string `json:"branch"`
TicketURL string `json:"ticket_url"`
PullRequestURL string `json:"pull_request_url"`
Model string `json:"model"`
Status Status `json:"status"`
Turns int `json:"turns"`
ToolCalls int `json:"tool_calls"`
GateDenials int `json:"gate_denials"`
StartedAt time.Time `json:"started_at"`
// LastAt is the follow effect's own bookkeeping for Elapsed and is not on
// the wire: a line that moves nothing a card shows then moves nothing on
// the page, and the executor logs such lines several times a second.
LastAt time.Time `json:"-"`
Elapsed string `json:"elapsed"`
Error string `json:"error"`
// Recent is the last few typed events, newest last. A card shows the
// last recentShown of them until the browser asks for the rest.
Recent []RecentEvent `json:"recent"`
// Expanded is the one thing a browser decides: whether the card shows
// every recent event it holds. It survives the card being replaced.
Expanded bool `json:"expanded"`
}
SessionCard is everything the ops view shows about one harness session, derived from its run record and its event log and nothing else. It is the session widget's state: a pure projection, replaced whole whenever the follow effect reads more of the log.
func Fold ¶
func Fold(card SessionCard, line []byte) (SessionCard, bool)
Fold applies one event log line to the card and reports whether it read a record. It is pure: equal cards and equal lines fold to equal cards.
type Status ¶
type Status string
Status is where a session stands, read from its event log.
const ( StatusRunning Status = "running" StatusFinished Status = "finished" StatusFailed Status = "failed" StatusClosed Status = "closed" )
The statuses a card shows. A session is running from its first turn request until the harness records the turn's end; a finished session keeps its turn executor open for the next message until the harness closes it.