Documentation
¶
Overview ¶
Package browser drives the headless Chrome that browser mode reads GitHub through. It owns the browser process and its tabs, paces their page loads, reads a repository's issues page, a Projects board, and an issue's conversation off the rendered markup, recovers a signed-out profile by opening a login window, and falls back to asking a coding agent about a screenshot when a page's markup is no longer recognisable.
Everything it hands back is a core type, and everything it needs from the rest of Aviary -- child-process ownership, the agent to ask, the login flow -- is handed in, so the driver never reaches back into the root package.
Index ¶
- Constants
- Variables
- func ImportSession(from, profile string) error
- func OpenWindow(ctx context.Context, config Config) error
- func ProfileDir(override string) (string, error)
- type AgentRunner
- type AgentSpec
- type Board
- type Browser
- func (b *Browser) Close() error
- func (b *Browser) LoadQueue() *LoadQueue
- func (b *Browser) Profile() string
- func (b *Browser) Recover() bool
- func (b *Browser) Resume() error
- func (b *Browser) SetLoadQueue(queue *LoadQueue)
- func (b *Browser) SetTabIdleTimeout(idle time.Duration, logf func(string, ...interface{}))
- func (b *Browser) Suspend() error
- func (b *Browser) Tab(name string) (*Tab, error)
- type CommentSource
- func (c *CommentSource) API() core.CommentClient
- func (s *CommentSource) AddReaction(ctx context.Context, repo string, commentID int64, content string) error
- func (s *CommentSource) AddReviewCommentReaction(ctx context.Context, repo string, commentID int64, content string) error
- func (s *CommentSource) AddReviewReaction(ctx context.Context, repo string, nodeID string, content string) error
- func (s *CommentSource) IssueAuthor(ctx context.Context, repo string, number int) (string, error)
- func (s *CommentSource) ListComments(ctx context.Context, repo string, number int) ([]core.Comment, error)
- func (s *CommentSource) ListReviewComments(ctx context.Context, repo string, number int) ([]core.Comment, error)
- func (s *CommentSource) PostComment(ctx context.Context, repo string, number int, body string) error
- func (s *CommentSource) PostCommentURL(ctx context.Context, repo string, number int, body string) (string, error)
- func (s *CommentSource) PostCommentWithAttachments(ctx context.Context, repo string, number int, body string, files []string) (string, error)
- func (c *CommentSource) ReadsPages() bool
- type Config
- type ExtractionError
- type Handover
- type Hydration
- type IssueHydrator
- type IssueSource
- type IssueSourceOptions
- type LoadQueue
- type LoginFunc
- type Page
- type SignIn
- type SignInGuard
- func (g SignInGuard) HydrateIssue(ctx context.Context, repo string, issue *core.Issue) error
- func (g SignInGuard) ListIssues(ctx context.Context, target string) ([]core.Issue, error)
- func (g SignInGuard) OriginatingWorkState(ctx context.Context, repo string, number int) (core.OriginatingWorkState, error)
- func (g SignInGuard) Recovery() *SignInRecovery
- func (g SignInGuard) Source() core.IssueSource
- func (g SignInGuard) StacksEnabled(ctx context.Context, repo string) (bool, error)
- type SignInRecovery
- type SignedOutError
- type Supervisor
- type Tab
- type Vision
- type VisionRef
- type WatchIssues
- func (s WatchIssues) HydrateIssue(ctx context.Context, repo string, issue *core.Issue) error
- func (s WatchIssues) ListIssues(ctx context.Context, target string) ([]core.Issue, error)
- func (s WatchIssues) OriginatingWorkState(ctx context.Context, repo string, number int) (core.OriginatingWorkState, error)
- func (s WatchIssues) StacksEnabled(ctx context.Context, repo string) (bool, error)
Constants ¶
const DefaultWatchInterval = 20 * time.Second
DefaultWatchInterval is the poll interval browser mode defaults to. Reading a page Aviary already has a tab open on is far cheaper than the API path's `gh` invocations, so browser mode can poll faster than the half-minute the API default is chosen to stay inside rate limits. It is not free, though: a tick reloads every watched target's page, waits out GitHub's client-side render, and re-reads the conversation of every issue an agent is working, none of which fits in the five seconds this was first set to (issue #441).
Variables ¶
var ErrExtraction = errors.New("issue list extraction failed")
ErrExtraction marks the failure of reading an issues page that loaded but whose contents Aviary did not recognise. Callers match it with errors.Is to tell "GitHub rendered something we cannot read" (which usually means the browser profile is signed out, or GitHub's markup moved) apart from an ordinary navigation or protocol error.
var ErrNoSavedSession = errors.New("the profile has no saved GitHub sign-in")
ErrNoSavedSession reports a profile that has no saved GitHub sign-in to import.
ErrSignInWindowUnavailable reports a machine where no sign-in window can appear, such as a container or a server with no display.
var ErrSignedOut = errors.New("browser profile is signed out of GitHub")
ErrSignedOut marks a page that came back with nothing because the browser profile is not signed in to GitHub. Callers match it with errors.Is to tell it apart from a page whose markup Aviary could not read (ErrExtraction): the two look identical from the outside -- no issues -- but only one of them can be fixed by changing an extractor, and neither can be fixed by looking at a screenshot of a signed-out page.
var ErrSigningIn = errors.New("a GitHub sign-in window is already open")
ErrSigningIn reports a sign-in window that is already open.
Functions ¶
func ImportSession ¶
ImportSession copies the GitHub sign-in saved in a profile that was signed in elsewhere, such as on a desktop machine, into profile. It is how a machine where no sign-in window can appear (Docker, a server with no display) gets a signed-in session: the next browser started on profile restores it before its first page load.
func OpenWindow ¶
OpenWindow launches a visible browser on the profile itself and blocks until the user closes its window or ctx is canceled. Nothing drives the browser, so it behaves as if the user had started it by hand on that profile.
Unlike launch, it never falls back to a private directory when another Aviary instance holds the profile: the point is to change the profile, and changes made in a directory removed on exit would be silently lost.
func ProfileDir ¶
ProfileDir reports the profile directory the browser is launched against: the override when one was given, otherwise Aviary's own browser profile, so a GitHub sign-in made in Aviary's browser is the one Code Loop reads with.
Types ¶
type AgentRunner ¶
type AgentRunner interface {
// VisionAgent reports the agent to ask, read without advancing the
// round-robin cursor that load balances real issue dispatch.
VisionAgent() AgentSpec
// RunAgent runs binary with args and returns everything it wrote.
RunAgent(ctx context.Context, binary string, args []string) (string, error)
// RunInProcess runs one turn of an in-process agent definition with the
// image at mediaURL and returns the reply it wrote.
RunInProcess(ctx context.Context, spec AgentSpec, prompt, mediaURL string) (string, error)
}
AgentRunner supplies and runs that invocation. The root package implements it over the same runner that dispatches issues, so a screenshot is read by the agent the run is already configured for, and so the browser driver needs to know nothing about how Aviary spawns clidefs.
type AgentSpec ¶
type AgentSpec struct {
// Name is the agent provider, which decides how the screenshot is handed
// over.
Name string
// Definition is that provider's agent definition, which carries the argv
// template the invocation is rendered from. The root package supplies the
// one the run was configured with; a spec that names only an agent falls
// back to the built-in definition of that name.
Definition *clidefs.Definition
// Binary is the executable that provider is invoked through.
Binary string
// Model and Level are the model and reasoning level to ask for. Both are
// empty when the agent's own defaults are wanted.
Model, Level string
// Approval is the approval mode the call renders, matching the run's
// own.
Approval clidefs.ApprovalMode
}
AgentSpec names the one-shot coding-agent invocation a vision recovery is made with: which agent, run how, from which executable.
type Board ¶
type Board struct {
// Page hands out the tab a target is read in, one tab per target.
Page func(name string) (Page, error)
// Filter and AllIssues mirror the GHCLI fields of the same name so the
// board page is asked for the same items the GraphQL query selects.
Filter string
AllIssues bool
// FilterOverrides are per-target filters, which replace Filter and
// AllIssues for their targets.
FilterOverrides *core.FilterOverrides
// Vision is the bounded screenshot-to-agent fallback, shared with the
// repository issue source so the per-run cap is one budget for the whole
// run. Nil (the default, without the browser vision fallback) means a board that never
// renders is simply reported as an extraction failure.
Vision *Vision
// Profile is the browser profile directory, named in the signed-out error
// the same way the repository issues page names it.
Profile string
// contains filtered or unexported fields
}
Board reads a Projects v2 board through its rendered page instead of the projects(v2) GraphQL API, which is where the remaining GraphQL calls in the watch loop live (issue #276). It satisfies both IssueSource and ProjectStateSource for project targets.
Only reads move to the browser. Writing a status back still goes through `gh api graphql` in GHCLI.SetIssueStatus: the board page offers no stable way to drive a status change, and SetIssueStatus already looks an item's id up by issue number when the caller has none, which is exactly the case for issues extracted here.
func NewBoard ¶
func NewBoard(browser *Browser, filter string, allIssues bool, vision *Vision, hydration *Hydration) *Board
NewBoard builds the board reader for a run's browser, giving each target its own tab so boards are reloaded rather than reopened.
func (*Board) ListIssues ¶
ListIssues reports the board's issues with the fields the dispatch gate reads: number, repository, title, and the Status column. The body and the dependency/sub-issue state are not on the board page, so they are hydrated afterwards through the shared helper, on the same budget the repository issues page keeps: one targeted REST read per newly seen dispatch candidate, memoized for the life of the run, never per tick and never for the whole list. The Status column the board owns is not part of that hydration and survives it.
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser owns the single headless browser process a `Aviary watch` run drives, and the tabs it reads pages in. Every target Aviary watches gets one tab that is navigated or reloaded on each tick: opening a tab per poll would leak renderer processes for as long as the run lasts.
func Start ¶
Start launches a headless browser against Aviary's own profile and connects to it. The returned Browser must be closed, which is also what stops the browser process.
func (*Browser) Close ¶
Close shuts the browser down: the tabs are closed, the connection is dropped, and the process is terminated so no browser survives the run that started it. It is safe to call more than once, so shutdown paths can call it defensively.
func (*Browser) LoadQueue ¶
LoadQueue reports the queue this browser paces its page loads through, or nil when it is not pacing them at all -- the browser `Aviary auth` signs in through polls nothing and waits for no one.
func (*Browser) Profile ¶
Profile reports the profile directory the browser was launched against, or an empty string when there is no launched process to ask (the tests' fakes).
func (*Browser) Recover ¶
Recover restarts the browser when it has stopped answering, which is how a run picks itself up after the machine wakes from sleep (issue #683). A browser that still answers keeps its process: any tab whose own connection dropped is retired on its next read instead. It reports whether the browser was restarted.
func (*Browser) Resume ¶
Resume starts the browser again after Suspend. Tabs are not restored: a tab belongs to the process that owned it, and every reader re-opens the one it needs on its next read, navigating it where it needs to be anyway.
func (*Browser) SetLoadQueue ¶
SetLoadQueue attaches the run's shared page-load queue, which every tab this browser opens paces its navigations and reloads through. It is set before anything is read, because tabs are opened lazily on their first read.
func (*Browser) SetTabIdleTimeout ¶
SetTabIdleTimeout sets how long a tab may go unread before the browser closes it, and where the closures are logged. A run watching a handful of targets reloads their pages every tick, so only a page Aviary has genuinely stopped reading ages out.
func (*Browser) Suspend ¶
Suspend stops the browser process and drops its tabs, leaving the Browser itself usable. Chrome allows exactly one process per --user-data-dir, so putting a login window on the same profile the watch loop reads GitHub with means getting out of the way first; Resume starts a new process afterwards and the readers holding this Browser keep working, because they ask for their tab by name on every read rather than holding one.
type CommentSource ¶
type CommentSource struct {
// contains filtered or unexported fields
}
CommentSource reads an issue's or pull request's comments off its rendered GitHub conversation page instead of calling the API. The handoff handshake polls comments on every active issue -- once per contested candidate per reap, and again on a timer for the whole time an agent is running (see watchForCompetingClaim) -- which is the heaviest API user left in browser mode and exactly the kind of read browser mode exists to move onto a page (issue #441).
Only the read moves. Posting a comment has no page affordance Aviary could drive, so PostComment still goes through the API client this wraps, and that same client answers any read the page could not produce: the handshake decides who owns a ticket, so a page that failed to load, came back signed out, or rendered markup the extractor does not recognise falls back to the API rather than reporting a conversation as having no comments and letting two instances claim the same work.
func NewCommentSource ¶
func NewCommentSource(browser *Browser, api core.CommentClient, logf func(string, ...interface{})) *CommentSource
NewCommentSource builds the comment client browser mode runs the handoff handshake through, reading conversations in one tab of the shared browser and keeping api for writes and for reads the page could not answer.
func (*CommentSource) API ¶
func (c *CommentSource) API() core.CommentClient
API reports the client the source posts through and falls back to.
func (*CommentSource) AddReaction ¶
func (s *CommentSource) AddReaction(ctx context.Context, repo string, commentID int64, content string) error
AddReaction writes through the API client, same as PostComment: the conversation page offers no affordance Aviary could drive to react with. It is a no-op when the wrapped client has no reaction capability.
func (*CommentSource) AddReviewCommentReaction ¶
func (s *CommentSource) AddReviewCommentReaction(ctx context.Context, repo string, commentID int64, content string) error
AddReviewCommentReaction writes through the API client, same as AddReaction, and is a no-op when it cannot react to review comments.
func (*CommentSource) AddReviewReaction ¶
func (s *CommentSource) AddReviewReaction(ctx context.Context, repo string, nodeID string, content string) error
AddReviewReaction writes through the API client, same as AddReaction, and is a no-op when it cannot react to reviews.
func (*CommentSource) IssueAuthor ¶
IssueAuthor reads through the API client: the MCP update-issue tool and the prompt agent's update action mention the author in the comment they post, and that mention is what delivers the update to the owning job (issue #832).
func (*CommentSource) ListComments ¶
func (s *CommentSource) ListComments(ctx context.Context, repo string, number int) ([]core.Comment, error)
ListComments reads repo#number's conversation page and returns its comments in creation order. A conversation that rendered with no comments yields an empty slice; anything else falls back to the API client.
func (*CommentSource) ListReviewComments ¶
func (s *CommentSource) ListReviewComments(ctx context.Context, repo string, number int) ([]core.Comment, error)
ListReviewComments reads a pull request's review comments and review bodies through the API client. The conversation page this source reads folds inline comments into collapsed review threads, so the API is the reliable reader. It returns nothing when the API client cannot list them.
func (*CommentSource) PostComment ¶
func (s *CommentSource) PostComment(ctx context.Context, repo string, number int, body string) error
PostComment writes through the API client: GitHub's conversation page offers no affordance Aviary could drive to post one.
func (*CommentSource) PostCommentURL ¶
func (s *CommentSource) PostCommentURL(ctx context.Context, repo string, number int, body string) (string, error)
PostCommentURL posts through the API client, same as PostComment, and reports the posted comment's URL (issue #832).
func (*CommentSource) PostCommentWithAttachments ¶ added in v0.7.6
func (s *CommentSource) PostCommentWithAttachments(ctx context.Context, repo string, number int, body string, files []string) (string, error)
PostCommentWithAttachments writes through the API client, same as PostCommentURL.
func (*CommentSource) ReadsPages ¶
func (c *CommentSource) ReadsPages() bool
ReadsPages reports whether the comment source has a tab to read conversations in.
type Config ¶
type Config struct {
// Binary is an explicit browser executable (the browser `binary` setting).
Binary string
// Profile is an explicit profile directory (the browser
// `profile_directory` setting).
Profile string
// Headed launches a visible browser window instead of a headless one. It is
// how `Aviary auth` puts a login form in front of the user, on the same
// profile the headless watch loop reads GitHub with.
Headed bool
// Supervisor starts, waits on, and kills the browser process. A nil
// supervisor hands it to Aviary's own child-process tracking, so it cannot
// outlive the run that started it.
Supervisor Supervisor
}
Config collects the overrides that decide which browser Code Loop drives and where it keeps that browser's state. Both are empty by default, which means "discover a Chromium-based browser" and "use Aviary's browser profile"; ConfigFrom fills them in from Aviary's browser settings.
func ConfigFrom ¶
func ConfigFrom(settings config.BrowserConfig) Config
ConfigFrom builds the launch config from Aviary's browser settings.
type ExtractionError ¶
ExtractionError is the distinguishable error the issue source returns for a page it could not read, carrying the URL that produced it.
func (*ExtractionError) Error ¶
func (e *ExtractionError) Error() string
func (*ExtractionError) Is ¶
func (e *ExtractionError) Is(target error) bool
Is reports ErrExtraction so callers can match the category without depending on this concrete type.
type Handover ¶
Handover stops a browser so a sign-in window can take its profile, and starts it again afterwards. *Browser is one.
type Hydration ¶
type Hydration struct {
// contains filtered or unexported fields
}
Hydration is the candidate selection and memoization both browser page readers hydrate through: the repository issues page (issue #381) and the Projects v2 board (issue #395). One instance is shared by both, keyed by target, so the request budget below is a property of the whole run rather than of either reader.
func NewHydration ¶
func NewHydration(hydrate IssueHydrator, handled func(core.Issue) bool) *Hydration
NewHydration builds the shared hydration helper for a run.
type IssueHydrator ¶
type IssueHydrator interface {
HydrateIssue(ctx context.Context, repo string, issue *core.Issue) error
}
IssueHydrator fills in the fields a rendered issues page does not carry. GHCLI satisfies it with targeted REST calls; tests supply a fake that counts requests.
type IssueSource ¶
type IssueSource struct {
// FilterOverrides are per-target filters, which replace filter and
// allIssues for their targets.
FilterOverrides *core.FilterOverrides
// Hydration is the shared candidate/memo hydration helper. It is
// embedded so the source's own hydrate, handled, and hydrated fields read
// and write the one memo the project board reader shares (issue #395).
*Hydration
// contains filtered or unexported fields
}
IssueSource lists a repository's issues by reading its rendered GitHub issues page instead of calling the API: one tab per target, reloaded on each tick, and one Runtime.evaluate per page load that returns the rows. It spends no API quota and no agent tokens, and it never issues a GraphQL query.
It implements IssueSource, so the watch loop needs no structural change to use it. Issue bodies, dependencies, and sub-issue state are deliberately not scraped here: those are hydrated by targeted REST calls just before dispatch (see hydrateIssues).
func NewIssueSource ¶
func NewIssueSource(browser *Browser, options IssueSourceOptions) *IssueSource
NewIssueSource builds the issue source browser mode polls with, reading each target through its own tab of the shared browser.
func (*IssueSource) AllIssues ¶
func (s *IssueSource) AllIssues() bool
AllIssues reports whether the filter is dropped in favour of every open issue.
func (*IssueSource) Filter ¶
func (s *IssueSource) Filter() string
Filter and AllIssues report the search the issues page is read with, mirroring the run's own -filter and -all-issues.
func (*IssueSource) Hydrates ¶
func (s *IssueSource) Hydrates() bool
Hydrates reports whether the source can fill in the dispatch-only fields a rendered page does not carry.
func (*IssueSource) ListIssues ¶
ListIssues reads the target repository's issues page and returns the issues on it. A page with no results yields an empty slice rather than an error; a page that loaded but could not be read yields ErrExtraction.
func (*IssueSource) ReadsPages ¶
func (s *IssueSource) ReadsPages() bool
ReadsPages reports whether the source has a tab to read pages in.
func (*IssueSource) Vision ¶
func (s *IssueSource) Vision() *Vision
Vision reports the screenshot fallback attached to this source, nil when the browser vision fallback was not passed.
type IssueSourceOptions ¶ added in v1.0.2
type IssueSourceOptions struct {
// Hydrate and Handled build the source's Hydration; see NewHydration.
Hydrate IssueHydrator
Handled func(core.Issue) bool
// Filter is the issue search filter, and AllIssues lists every issue
// rather than only the filtered ones.
Filter string
AllIssues bool
// Vision, when set, is the fallback reader for pages the extractor
// cannot read.
Vision *Vision
// Logf logs the source's progress.
Logf func(string, ...interface{})
}
IssueSourceOptions configures NewIssueSource.
type LoadQueue ¶
type LoadQueue struct {
// contains filtered or unexported fields
}
LoadQueue paces every page load a browser-mode run makes. It is one queue for the whole run rather than one per reader, because the burst it exists to smooth is the sum of what all the readers do on the same tick: the issues page of every repository, every project board, and the conversation of every issue an agent is working.
Loads are spaced loadStagger apart by default. That spacing only holds while the pages due within one poll interval fit inside it; past that point a run that insisted on 2.5s per load would take longer than its own interval to get round them all and fall further behind on every tick, so the spacing compresses to interval/N.
N is the number of distinct pages the queue has loaded recently, not the number of callers waiting on it: the readers mostly load their pages one after another (the issue list walks its targets in turn), so at any instant the queue has one caller and no idea that twenty more loads are behind it. Counting the pages themselves sees the whole demand even while the queue is throttling it, and settles where a full pass over them takes one interval.
func NewLoadQueue ¶
NewLoadQueue builds the queue a browser-mode run paces its page loads with. An interval of zero falls back to browser mode's own default, so a queue is never left dividing by a window it does not have.
type LoginFunc ¶
type LoginFunc func(ctx context.Context, config Config, out io.Writer, timeout time.Duration) (string, error)
LoginFunc opens a headed sign-in window on config's profile and returns the GitHub login it ended up signed in as. It reports the flow's one progress line to out.
type Page ¶
Page is the part of a browser tab the issue source drives. Tab satisfies it; tests supply a fake so the extraction logic can be exercised without a browser or a network.
type SignIn ¶
type SignIn struct {
// Login opens the window and waits for the sign-in.
Login LoginFunc
// Headed reports whether a window could appear on this machine at all,
// naming what is missing when one could not.
Headed func() error
// Timeout bounds the wait for a sign-in to finish.
Timeout time.Duration
}
SignIn is the headed login flow a recovery hands the profile to.
type SignInGuard ¶
type SignInGuard struct {
// contains filtered or unexported fields
}
SignInGuard wraps browser mode's issue source so a read that came back signed out is recorded for the board's banner, and a read that worked clears it. The error is still returned: the poll that hit a signed-out page genuinely failed, and is never reported as "no issues".
func NewSignInGuard ¶
func NewSignInGuard(source core.IssueSource, recovery *SignInRecovery) SignInGuard
NewSignInGuard wraps source so a read that came back signed out triggers recovery before the next tick asks again.
func (SignInGuard) HydrateIssue ¶
HydrateIssue passes the paused watch's issue read through to the wrapped source for the same reason OriginatingWorkState does (issue #769).
func (SignInGuard) ListIssues ¶
ListIssues reads through the wrapped source, recording a signed-out read for the banner and clearing it on a read that worked.
func (SignInGuard) OriginatingWorkState ¶
func (g SignInGuard) OriginatingWorkState(ctx context.Context, repo string, number int) (core.OriginatingWorkState, error)
OriginatingWorkState passes the active-work check through to the wrapped source. The guard exists to recover a signed-out *page* read; this check is an API read that cannot come back signed out, so it is forwarded untouched rather than being lost because the guard does not implement it (issue #469).
func (SignInGuard) Recovery ¶
func (g SignInGuard) Recovery() *SignInRecovery
Recovery reports the sign-in recovery a signed-out read is handed to.
func (SignInGuard) Source ¶
func (g SignInGuard) Source() core.IssueSource
Source reports the reader the guard wraps.
func (SignInGuard) StacksEnabled ¶
StacksEnabled passes the stacked pull request check through to the wrapped source for the same reason OriginatingWorkState does (issue #657).
type SignInRecovery ¶
type SignInRecovery struct {
// contains filtered or unexported fields
}
SignInRecovery handles a signed-out read without opening a window on its own: it records the signed-out session for the board's banner, and opens GitHub's sign-in page in a visible window only when the user asks (the banner's "Sign in to GitHub"). Polling carries on throughout, so the first read after a sign-in lands picks the work back up in the same run.
Chrome allows one process per --user-data-dir, so signing in has to hand the profile over rather than share it: stop the headless browser, open a headed one on the same profile at GitHub's login page, wait for the sign-in, close it, and start the headless browser again.
func NewSignInRecovery ¶
func NewSignInRecovery(browser Handover, config Config, signIn SignIn, logf func(string, ...interface{})) *SignInRecovery
NewSignInRecovery builds the recovery for a run's browser.
func (*SignInRecovery) SignIn ¶
func (r *SignInRecovery) SignIn(ctx context.Context) (string, error)
SignIn opens GitHub's sign-in page in a visible window on the run's profile, waits for the sign-in, and hands the profile back to the headless browser. It is what the banner's "Sign in to GitHub" does. Where no window can appear it fails with ErrSignInWindowUnavailable, naming the two ways forward: gh polling, or importing a profile signed in elsewhere.
func (*SignInRecovery) State ¶
func (r *SignInRecovery) State() core.GitHubSession
State reports the GitHub session as the board's banner shows it.
type SignedOutError ¶
type SignedOutError struct {
URL string
Profile string
// Status is the main-frame HTTP status the page was served with when that
// is what gave the session away (404 or 403), and zero when the diagnosis
// came from a page that loaded normally. It is carried so the recovery
// path can say which of the two it saw.
Status int
}
SignedOutError is the error a signed-out read returns, carrying the page that produced it and the profile directory to sign in.
func (*SignedOutError) Error ¶
func (e *SignedOutError) Error() string
func (*SignedOutError) Is ¶
func (e *SignedOutError) Is(target error) bool
Is reports ErrSignedOut so callers can match the category without depending on this concrete type.
type Supervisor ¶
type Supervisor = aviarybrowser.Supervisor
Supervisor starts, waits on, and kills the browser subprocess. Every browser Aviary starts goes through one, so none of them can outlive Aviary (issue #773): Chrome allows one process per --user-data-dir, and a browser left running holds the profile against the next launch.
type Tab ¶
type Tab struct {
// contains filtered or unexported fields
}
Tab is one reusable tab. Its methods serialize on the tab because a single CDP target cannot service two commands at once.
func (*Tab) Eval ¶
Eval evaluates a JavaScript expression in the tab and decodes its result into out, which may be nil when the result is not needed.
func (*Tab) HTTPStatus ¶
HTTPStatus reports the status code the tab's last main-frame navigation was served with, or zero when it has not navigated anywhere yet.
func (*Tab) Reload ¶
Reload loads the tab's current URL again, which is how a watched page is polled without opening anything new.
func (*Tab) Screenshot ¶
Screenshot captures the full page as PNG bytes.
type Vision ¶
type Vision struct {
// contains filtered or unexported fields
}
Vision is the budget around the screenshot-to-agent fallback. It owns the accounting (per-target cooldown, per-run cap) so the issue and board sources cannot spend the budget by accident, and it logs every call it does make with the reason and the running count so a runaway is obvious in the dashboard. One instance is shared by every target, so the per-run cap is a budget for the whole run rather than per page kind.
func NewVision ¶
func NewVision(runner AgentRunner, logf func(string, ...interface{})) *Vision
NewVision builds the fallback for a watch run, dispatching screenshots to the same agent the run is otherwise configured to use.
func (*Vision) Recover ¶
func (v *Vision) Recover(ctx context.Context, target, pageURL, reason string, screenshot func() ([]byte, error), qualified bool) []VisionRef
Recover spends one unit of budget, if any is left, to read the issues off a screenshot of a page the DOM extractor could not read. qualified asks the agent for OWNER/REPO#NUMBER strings, which is what a project board needs; without it the agent is asked for bare numbers, which is what an issues page needs. It returns nil whenever the budget forbids the call, the screenshot fails, or the agent's answer is not the strict shape it was asked for; nothing is ever retried.
A nil receiver means the fallback is off, which is the default.
type VisionRef ¶
VisionRef is one issue the agent read off a screenshot. Repository is empty for a repository target, where the page itself fixes the repository and a bare number is unambiguous; it is always set for a project board, which spans repositories and where a bare number cannot be turned back into an addressable issue.
Status is the board's Status column for the item, and is only ever set for a project target: it is what the --ready-state gate reads, so a recovered board item without it is addressable but undispatchable (issue #398). It is empty when the board itself shows the item no status, which is a real answer rather than a parse failure.
type WatchIssues ¶
type WatchIssues struct {
// Repos reads a repository's rendered issues page (issue #377).
Repos core.IssueSource
// Board reads a project's rendered Projects v2 page (issue #378).
Board *Board
// Work answers the per-issue state the run loop watches while an agent is
// working: whether the ticket closed and what its description now says
// (issue #469). Neither page reader produces it, and a closed issue drops
// out of the rendered list rather than reporting itself closed, so it is
// read through the API the same way posting a comment is.
Work core.WorkClosureChecker
}
WatchIssues is browser mode's issue source. The two page readers answer for different targets — a repository has an issues page, a project has a board — so a run needs both, and each target goes to the one that can read it.
func (WatchIssues) HydrateIssue ¶
HydrateIssue forwards the paused watch's issue read to the API client, so browser mode wakes paused work the page readers no longer list the same way poll mode does (issue #769).
func (WatchIssues) ListIssues ¶
ListIssues reads a board target through the board and any other target through the repository issues page.
func (WatchIssues) OriginatingWorkState ¶
func (s WatchIssues) OriginatingWorkState(ctx context.Context, repo string, number int) (core.OriginatingWorkState, error)
OriginatingWorkState forwards the active-work check to the API client, so browser mode watches an in-flight issue the same way poll mode does.
func (WatchIssues) StacksEnabled ¶
StacksEnabled forwards the stacked pull request check to the API client, so browser mode stacks a blocked issue the same way poll mode does (issue #657).