Documentation
¶
Overview ¶
Package activity is the tiny contract between the action engine and whoever wants to watch it (the Cockpit, recorders, tests). Every acting tool call publishes a "before" event right before input reaches the page and an "after" event once the page settled, both carrying the agent's `why` and the target element. See docs/ACTIVITY-EVENTS.md.
The package has no dependencies on the browser so subscribers can import it freely.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Announce ¶
Announce publishes ev as the "before" event of an action and runs the pre-action hook (bus and hook may be nil). An error from the hook means: don't act. The engine and the tools that act without it (navigate, tabs, dialogs) share this, so every action is reported the same way.
Types ¶
type Box ¶
type Box struct {
X float64 `json:"x"`
Y float64 `json:"y"`
W float64 `json:"w"`
H float64 `json:"h"`
}
Box is a rectangle in CSS pixels relative to the top-level viewport (client coordinates of the tab's main frame, already including iframe offsets). It is what an overlay in the main frame needs to point at the element.
type Bus ¶
type Bus interface {
Publish(Event)
}
Bus receives events. Publish must not block for long: the action engine calls it inline.
type Event ¶
type Event struct {
ID string `json:"id"`
Time time.Time `json:"time"`
// Tab is the short tab id (t1, t2...).
Tab string `json:"tab"`
Kind Kind `json:"kind"`
// Action is the concrete operation: click, type, select, back, accept...
Action string `json:"action,omitempty"`
// Why is the agent's short explanation (≤ 80 chars), shown to the human.
Why string `json:"why,omitempty"`
Target *Target `json:"target,omitempty"`
// Value is the text typed / option chosen, when not sensitive. Empty for passwords.
Value string `json:"value,omitempty"`
Phase Phase `json:"phase"`
// Result is the one-line outcome (after only), e.g. `clicked button "Save"`.
Result string `json:"result,omitempty"`
// Error is set when the action failed (after only).
Error string `json:"error,omitempty"`
}
Event is one step of an action. A "before" and its "after" share the same ID.
type Hooks ¶
type Hooks []PreActionHook
Hooks runs several pre-action hooks in order; the first error stops the chain.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is an in-memory Bus fanning events out to subscribers. Slow subscribers lose events rather than blocking the action engine.
type Kind ¶
type Kind string
Kind is the tool that produced an event.
const ( KindAct Kind = "act" KindFill Kind = "fill" KindTabs Kind = "tabs" KindDialog Kind = "dialog" // KindMock and KindEmulate change what the page receives or how it is shown (debug group): // the human sees them in the feed (SPEC §2.5). KindMock Kind = "mock" KindEmulate Kind = "emulate" // KindRetouch changes how a site looks (retouch group: preview, save, discard, toggle). KindRetouch Kind = "retouch" )
type PreActionHook ¶
PreActionHook runs after the target was scrolled into view and verified, immediately before trusted input is dispatched. ev is the "before" event (target box included). The Cockpit uses it to animate the ghost cursor to the target; returning an error aborts the action and the error is reported to the agent (e.g. the human paused).
type Target ¶
type Target struct {
Ref string `json:"ref,omitempty"`
Role string `json:"role,omitempty"`
Name string `json:"name,omitempty"`
// Box is nil when the action has no on-screen target (navigate, press without ref...).
Box *Box `json:"box,omitempty"`
// Point is where the pointer will land (center of the visible part), when pointer input is
// used.
Point *Point `json:"point,omitempty"`
}
Target is the element an action is aimed at.