projects

package
v0.7.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 49 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package projects is the Code Loop engine: it watches GitHub repositories, project boards and Discussions boards for ready issues and runs CLI jobs on them through the gh-fix and gh-discuss skills.

Index

Constants

View Source
const (
	BackfillPosted        = "posted"
	BackfillWouldPost     = "would_post"
	BackfillAlreadyPosted = "already_posted"
	BackfillNoMedia       = "no_media"
	BackfillFailed        = "failed"
)

Backfill outcomes for one issue.

View Source
const (
	DeliveryBrowser = "browser"
	DeliveryWebhook = "webhook"
	DeliveryPoll    = "poll"
)

The ways Code Loop reads GitHub. Browser is the default: it reads the rendered pages in Aviary's own browser, signed in as the user, which costs no API rate limit. Webhook and poll are the API-backed modes.

View Source
const (
	ProjectAdded   = "project-added"
	ProjectRemoved = "project-removed"
	ProjectUpdated = "project-updated"
)

The kinds of ProjectEvent. The server forwards them to every dashboard on /api/ws, so a project added, removed or polled in one place shows in every open client at once instead of on its next poll (issue #1211).

View Source
const (
	// InboxDelivered means the job was running or waiting and was woken with
	// the message.
	InboxDelivered = "delivered"
	// InboxQueued means the job was paused or queued and keeps its state; its
	// agent sees the message when the job next runs.
	InboxQueued = "queued"
	// InboxResumed means the job was paused and, with JobDeliveryOptions.Resume,
	// was resumed so its agent sees the message on its first turn.
	InboxResumed = "resumed"
	// InboxReopened means the job was complete and, with
	// JobDeliveryOptions.Reopen, was retried with the message.
	InboxReopened = "reopened"
)

The outcomes of sending a message to a Code Loop job.

View Source
const (
	SkillFix       = "gh-fix"
	SkillSafeMerge = "gh-safe-merge"
	SkillDiscuss   = "gh-discuss"
)

The skills a job is queued for on demand (issue #1095). SkillFix names the gh-fix runs Code Loop dispatches from its own polls.

View Source
const BrowserInterval = browser.DefaultWatchInterval

BrowserInterval is how often browser delivery reloads its pages by default.

View Source
const UsageAgentID = "projects"

UsageAgentID is the agent ID Code Loop job usage is recorded under.

Variables

View Source
var ErrJobGone = errors.New("the Code Loop job no longer exists")

ErrJobGone is returned when a message names a Code Loop job that no longer exists.

View Source
var ErrNoMergeQueue = errors.New("safe merge is turned off: the Code Loop no_merge setting leaves pull requests for a human to merge")

ErrNoMergeQueue refuses queueing a safe merge while the projects' no_merge setting asks for finished pull requests to be left for a human.

View Source
var ErrNotWatching = errors.New("no projects are being watched; add one with project_add or aviary watch")

ErrNotWatching is returned by calls that need a running engine when no project is watched.

Functions

func ApplyBrowserSources

func ApplyBrowserSources(w *Engine, driver *browser.Browser, options BrowserOptions, gh GHCLI) *browser.SignInRecovery

ApplyBrowserSources swaps the engine's GitHub reads for their browser-backed equivalents: issue lists from the rendered issues page, boards from the rendered Projects page with the board's own Status column, and the comments the handoff reads from the rendered conversation. Writes (comments, status moves) and Discussions stay on gh.

Newly seen candidates are hydrated with their body and dependency state through gh, once per issue for the run. A signed-out read is recorded for the board's banner instead of opening a window, and the returned recovery is what the banner's "Sign in to GitHub" calls.

func ExpandTarget

func ExpandTarget(value string) (string, error)

ExpandTarget resolves a target as `aviary watch` accepts it, expanding the projects: and discussions: shorthands against the current checkout's origin remote.

func GitHubSignIn

func GitHubSignIn(ctx context.Context, config browser.Config, out io.Writer, timeout time.Duration) (string, error)

GitHubSignIn opens a visible window on the profile at GitHub's sign-in page and waits until the profile is signed in, returning the login.

func GitHubSignedIn

func GitHubSignedIn(ctx context.Context, config browser.Config) (string, error)

GitHubSignedIn reports the GitHub login Aviary's browser profile is signed in as, or an empty string when it is signed out. It reads headlessly, so asking never puts a window on screen.

func ImportBrowserProfile

func ImportBrowserProfile(from string, config browser.Config) error

ImportBrowserProfile copies the GitHub sign-in saved in a profile signed in elsewhere into the configured profile, for machines where no sign-in window can appear.

func OpenBrowserWindow

func OpenBrowserWindow(ctx context.Context, config browser.Config, out io.Writer) error

OpenBrowserWindow opens Aviary's browser visibly on its profile, with nothing attached, so its settings (and its GitHub sign-in) can be changed. It blocks until the window is closed.

func OriginTarget

func OriginTarget() (string, bool)

OriginTarget is the current checkout's origin GitHub repository.

func ResolveDelivery

func ResolveDelivery(mode string, interval time.Duration, intervalSet bool, options BrowserOptions) (string, time.Duration, error)

ResolveDelivery validates a delivery mode and settles the poll interval it runs at. An empty mode is browser delivery, and browser delivery reloads every BrowserInterval unless an interval was set explicitly.

func SignInFlow

func SignInFlow() browser.SignIn

SignInFlow is the visible sign-in window a signed-out run opens when the user asks.

Types

type AgentIdentifier

type AgentIdentifier interface {
	AgentName() string
}

AgentIdentifier picks the agent for a new job.

type AgentOutputRunner

type AgentOutputRunner interface {
	RunWithOutput(context.Context, Issue, io.Writer) error
}

AgentOutputRunner runs a coding agent on an issue, copying its output.

type AgentRunner

type AgentRunner interface {
	Run(context.Context, Issue) error
}

AgentRunner runs a coding agent on an issue.

type AgentSession

type AgentSession struct {
	ID                string
	Agent             string
	CheckoutDirectory string
	Resume            bool
	// ReusedClone marks CheckoutDirectory as a clone an earlier job left that
	// this fresh run was handed and must not clone again (#622).
	ReusedClone bool
	// RunDir is the sanctioned temp directory a run without a checkout starts
	// in and clones under, chosen once per run by CommandRunner.
	RunDir string
	// Update carries a change made to the issue while the agent was working
	// it. A resumed session that has one is prompted with it
	// instead of the generic "continue", so the closure, edited description,
	// or new comment reaches the agent that is already holding the work
	// rather than being noticed only after the run ends.
	Update string
	// Model overrides the model an in-process agent (an aviary/<agent> spec)
	// runs the turn with, as a scheduled run's model override does; empty
	// runs it with the agent's own.
	Model string
}

AgentSession is the coding-agent session a job runs in.

type AviaryAgentRun

type AviaryAgentRun struct {
	// Agent names the Aviary agent: the model of an aviary/<agent> spec.
	Agent string
	// Model overrides the agent's default model for the turn; empty uses it.
	Model string
	// Prompt is the turn's message.
	Prompt string
	// MediaURL is an image the turn sees, for a vision call.
	MediaURL string
	// Workdir is granted to the agent's file tools and exec for the turn,
	// such as a job's clone.
	Workdir string
	// Event receives each event of the turn's stream.
	Event func(agent.StreamEvent)
	// Hold holds the turn's new tool calls while engaged, such as during the
	// shutdown checkpoint.
	Hold *agent.TurnHold
}

AviaryAgentRun is one turn an in-process agent definition, such as the built-in aviary agent, runs on one of Aviary's own agents.

type AviaryAgentRunner

type AviaryAgentRunner func(ctx context.Context, run AviaryAgentRun) error

AviaryAgentRunner runs one turn through core's agent runner and returns once it ends, with the error it ended on. Cancelling ctx stops the turn.

type BackfillResult added in v0.7.8

type BackfillResult struct {
	Number      int      `json:"number"`
	Status      string   `json:"status"`
	Reason      string   `json:"reason,omitempty"`
	URL         string   `json:"url,omitempty"`
	Prompt      string   `json:"prompt,omitempty"` // the ID of the user message that filed it
	Attachments []string `json:"attachments,omitempty"`
	Skipped     []string `json:"skipped,omitempty"` // the request's media GitHub does not take
}

BackfillResult is what a media backfill did for one issue.

type BrowserOptions

type BrowserOptions struct {
	// Binary and Profile come from Aviary's browser settings, so Code Loop
	// reads GitHub through the same browser and profile as Aviary itself.
	Binary  string
	Profile string
	// Vision enables the opt-in, capped screenshot fallback for pages the
	// DOM extractor stops recognising.
	Vision bool
	// Headed drives a visible browser instead of a headless one, so the pages
	// being read can be watched. It is a debugging switch.
	Headed bool
}

BrowserOptions decide which browser browser delivery drives and how.

func BrowserOptionsFrom

func BrowserOptionsFrom(settings config.BrowserConfig) BrowserOptions

BrowserOptionsFrom builds the options from Aviary's browser settings.

func (BrowserOptions) Config

func (o BrowserOptions) Config() browser.Config

Config converts the options into the launcher's configuration.

type CommandRunner

type CommandRunner struct {
	Binary, CodexBinary, ClaudeBinary string
	// Agents holds every configured agent spec (agent/model:level) to load
	// balance across when dispatching new issues. AgentName rotates through it
	// round robin.
	Agents      []string
	Agent, Repo string
	Identity    Identity
	Output      io.Writer
	// Approval is the Code Loop surface's effective approval mode, which
	// every CLI launch renders through its definition.
	Approval clidefs.ApprovalMode
	NoMerge  bool
	// NoChangelog asks the dispatched /gh-fix prompt to skip adding a
	// changelog entry for the run, mirroring how NoMerge asks it to leave the
	// pull request unmerged.
	NoChangelog bool
	// AllowedCommenters are the GitHub logins whose comments steer the run.
	// The prompt names them, because the agent reads the issue thread itself
	// and would otherwise take instructions from anyone who comments.
	AllowedCommenters []string
	// RemoteControl asks Claude to start its Remote Control bridge so a headless
	// run is viewable from the Claude mobile app and claude.ai/code. Claude does
	// not honour the request under -p (see remoteControlSettings), so it is off
	// by default. It affects Claude runs only; see codexRemoteControlNotice for
	// why Codex runs stay local.
	RemoteControl bool
	// Definitions is the agent registry this runner renders invocations from.
	// A nil registry falls back to the run's own, which is the built-in
	// definitions until a config file replaces them.
	Definitions *clidefs.Registry
	// TargetAgents is each target's own agent specs, in fallback order:
	// a job on that target runs on the first agent whose quota is not used
	// up. A target without an entry load balances across Agents.
	TargetAgents map[string][]string
	// Quotas reports the latest quota reading of each agent, keyed by agent
	// name, so dispatch skips an agent with none left. Nil skips nothing.
	Quotas func() map[string]string

	// Active tracks the agents this runner has started and their checkouts,
	// for the shutdown checkpoint. It is shared by pointer across
	// copies, and nil tracks nothing.
	Active *activeAgents
	// Transcripts records each run's raw output and structured events. Nil
	// records nothing.
	Transcripts *transcriptStore
	// CloneRoot picks the sanctioned temp directory a run without a checkout
	// starts in and clones under. Nil uses the system temp
	// directory.
	CloneRoot func() (string, error)
	// Aviary runs in-process agent definitions through core's agent runner.
	// Nil fails their dispatch.
	Aviary AviaryAgentRunner
	// RecordUsage receives each run's token use for core usage tracking. Nil
	// records nothing.
	RecordUsage UsageRecorder
	// contains filtered or unexported fields
}

CommandRunner runs jobs on CLI processes, rendering each run's argv from the agent definitions.

func (CommandRunner) AgentName

func (r CommandRunner) AgentName() string

AgentName returns the agent spec (agent/model:level) to use for the next newly dispatched issue, rotating round robin through Agents when more than one is configured so work is load balanced evenly across concurrency.

func (CommandRunner) AgentNameFor

func (r CommandRunner) AgentNameFor(target string) string

AgentNameFor returns the agent spec for a new job on target. A target with its own agents takes the first one whose quota is not used up; any other target load balances across Agents, skipping agents with no quota left. When every candidate is out of quota the first one is used anyway, so work is never silently dropped.

func (CommandRunner) Run

func (r CommandRunner) Run(ctx context.Context, issue Issue) error

Run runs a coding agent on issue.

func (CommandRunner) RunSession

func (r CommandRunner) RunSession(ctx context.Context, issue Issue, session AgentSession, updateSession func(AgentSession)) error

RunSession runs a coding agent on issue in session.

func (CommandRunner) RunSessionWithOutput

func (r CommandRunner) RunSessionWithOutput(ctx context.Context, issue Issue, session AgentSession, updateSession func(AgentSession), output io.Writer) error

RunSessionWithOutput runs a coding agent on issue in session, copying its output.

func (CommandRunner) RunWithOutput

func (r CommandRunner) RunWithOutput(ctx context.Context, issue Issue, output io.Writer) error

RunWithOutput runs a coding agent on issue, copying its output.

type Comment

type Comment = core.Comment

Comment is a comment on an issue or pull request.

type CommentClient

type CommentClient = core.CommentClient

CommentClient posts and lists comments.

type CommentKind

type CommentKind int

CommentKind names which of GitHub's comment APIs a comment belongs to. Each has its own IDs, listings, webhook deliveries, and reaction endpoint.

const (
	// ConversationComment is an ordinary comment on an issue or on a pull
	// request's conversation tab.
	ConversationComment CommentKind = iota
	// ReviewComment is an inline comment on a pull request's diff (issue
	// #695).
	ReviewComment
	// ReviewBody is the body of a submitted pull request review.
	ReviewBody
)

type CommentLister

type CommentLister = core.CommentLister

CommentLister lists comments.

type CommentPoster

type CommentPoster = core.CommentPoster

CommentPoster posts comments.

type CommentReactor

type CommentReactor = core.CommentReactor

CommentReactor reacts to issue comments.

type CommitMessageReader added in v0.7.32

type CommitMessageReader interface {
	CommitMessage(ctx context.Context, repo, sha string) (string, error)
}

CommitMessageReader reads a commit's full message, so a merge can be checked for markers that keep its push workflows from running.

type Discussion

type Discussion struct {
	Number    int
	Title     string
	Body      string
	CreatedAt time.Time
}

Discussion is a top-level GitHub Discussion thread that has not yet received any reply.

type DiscussionSource

type DiscussionSource interface {
	ListUnansweredDiscussions(context.Context, string) ([]Discussion, error)
}

DiscussionSource lists the Discussion threads that have no reply yet.

type Engine

type Engine struct {
	Repo        string
	Targets     []string
	Interval    time.Duration
	UseWebhooks bool
	WebUIURL    string
	Events      <-chan WebhookEvent
	Concurrency int
	StatePath   string
	ReadyState  string

	Issues IssueSource
	// Discussions lists unanswered top-level Discussion threads for
	// Discussions-board targets. When nil, Discussions-board targets are
	// never polled.
	Discussions DiscussionSource
	// Candidates lists the open pull requests and Discussion threads the
	// Queue menu offers. It is gh whatever the issue delivery mode, which
	// only decides how issues are polled.
	Candidates QueueCandidateSource

	Runner AgentRunner
	// RecordUsage receives the Code Loop usage the engine observes: each job
	// run's wall time and each issue's merged or failed outcome. Nil records
	// nothing.
	RecordUsage UsageRecorder
	// RouteMention hands a prompt to the built-in Code Loop agent. A direct
	// mention on a finished or paused job goes to it instead of restarting
	// the job; nil restarts the job as before.
	RouteMention func(ctx context.Context, prompt string) error
	// Active is the shutdown checkpoint's record of active runs (issue
	// #741). The runner records runs whose agent is running; the run loop
	// adds runs waiting out a scheduled wakeup, which have a checkout but no
	// agent process. Nil records nothing.
	Active *activeAgents
	Out    io.Writer

	// Projects supplies the push-mode project board fingerprint. When nil,
	// board changes are only picked up by the fallback poll.
	Projects ProjectStateSource

	Status IssueStatuser
	UI     UIReporter
	// Registry is the agent registry this run was configured with. The
	// settings API reports the agents it holds, so the dashboard's agent
	// selector offers a config-defined agent without a code change. A nil
	// registry falls back to the run's own.
	Registry *clidefs.Registry
	Quota    func(context.Context) map[string]string
	// Identity names this instance in cooperative handoff comments. It is
	// generated once at startup and never persisted.
	Identity Identity
	// AllowedCommenters restricts which GitHub logins may trigger a direct
	// @/aviary:ID mention run, and whose new comments are relayed
	// into a running agent. An empty list places no restriction;
	// the CLI defaults it to the authenticated gh user.
	AllowedCommenters []string
	// SelfLogin is the GitHub login this instance runs as. A new comment from
	// an allowed commenter that mentions it triggers a recheck of its issue
	//. Empty turns that trigger off.
	SelfLogin string
	// Comments drives the cooperative handoff handshake. When
	// nil, ownership negotiation is skipped and dispatch behaves as before.
	Comments CommentClient
	// Mentions is scanned on every poll for direct @/aviary:ID mentions when
	// no webhook delivers them, on an issue and on its pull request alike
	//. Nil leaves mentions to the webhook path alone.
	Mentions MentionSource
	// Webhooks re-reconciles push webhooks on every periodic poll so a
	// repository that joins a project board after startup gets a webhook
	// without a restart. Nil skips reconciliation, as in poll
	// mode where no webhooks are configured at all.
	Webhooks func(context.Context)
	// WebhookOnline reports whether push deliveries are reaching the webhook
	// server, such as whether the ngrok tunnel was alive at its last check
	//. Nil reports push mode as always online.
	WebhookOnline func() bool
	// Recover re-establishes the run's own long-lived connections after the
	// machine wakes from sleep, such as browser mode's browser.
	// Nil has nothing to recover.
	Recover func(context.Context)
	// GitHubSession reports browser delivery's GitHub sign-in, which the
	// board shows as a signed-out banner. Nil outside browser delivery.
	GitHubSession func() core.GitHubSession
	// Held reports whether a safe restart is holding new jobs. While it is,
	// polls dispatch nothing and leave waiting jobs as they are; running jobs
	// carry on. Nil never holds.
	Held func() bool
	// RestartNotice returns, once, the notice a safe restart left for the job
	// it stopped on issue, or "" when it stopped none there. The resumed
	// session is prompted with it. Nil has no notices.
	RestartNotice func(Issue) string

	// Transcripts holds every job's structured transcript.
	Transcripts *transcriptStore
	// contains filtered or unexported fields
}

Engine is the Code Loop engine: it watches targets for ready issues, claims them, and runs coding-agent jobs on them up to a concurrency limit.

func (*Engine) ApplySettings

func (w *Engine) ApplySettings(ctx context.Context, update SettingsUpdate) (SettingsSnapshot, error)

ApplySettings validates and applies update, returning the resulting settings snapshot. It hands the update to the running Run loop, which owns the mutated fields, so it only takes effect once Run is looping. An update that changes nothing is a read, answered from CurrentSettings without waiting on the loop at all.

func (*Engine) ClearClones

func (w *Engine) ClearClones(context.Context) (core.ClearClonesResult, error)

ClearClones removes every clone nothing can still need.

func (*Engine) CloneRoot

func (w *Engine) CloneRoot() (string, error)

CloneRoot picks the directory a new run's agent starts in and clones under: the first sanctioned root with room for a clone.

func (*Engine) CloneRoots

func (w *Engine) CloneRoots() []string

CloneRoots reports the sanctioned directories, in the order new clones try them.

func (*Engine) CreateIssue

func (w *Engine) CreateIssue(ctx context.Context, request core.IssueCreate) (core.IssueCreateResult, error)

CreateIssue files an issue on a repository through the gh-create skill , run by the prompt agent with this instance's identity so the issue carries gh-create's created-by marker. A non-empty model overrides the configured prompt-agent model for this call. It waits for the skill to finish and reports the new issue's URL.

A request identical to one still filing joins it, and one identical to an issue filed within filedIssueMemory gets that issue back, so a caller that gave up waiting and asks again never files a duplicate (issue #710). The filing outlives a caller that stops waiting. A different request from the same session on the same repository, made while one is filing or within sessionFilingMemory of one filing, is refused with that filing's issue unless it is marked distinct, since it is most likely the same request reworded (issue #1174).

func (*Engine) CurrentSettings

func (w *Engine) CurrentSettings(ctx context.Context) (SettingsSnapshot, error)

CurrentSettings reports the live settings snapshot without changing anything. It reads the snapshot the Run loop last published rather than asking the loop, which may be in the middle of a poll, so the settings modal renders immediately. Before Run has published one, nothing has changed the settings yet, so they are read as configured.

func (*Engine) ListClones

func (w *Engine) ListClones(ctx context.Context) (core.ClonesSnapshot, error)

ListClones enumerates every recorded clone with its size, adopting leftovers found on disk first.

func (*Engine) PostIssueUpdate

func (w *Engine) PostIssueUpdate(ctx context.Context, update core.IssueUpdate) (core.IssueUpdateResult, error)

PostIssueUpdate posts update as a comment on its issue or pull request that mentions the author and this instance, the way the stuck-job watchdog's unblock agent reaches a job: aviary's mention path delivers it to the owning job. It reports the comment's URL.

func (*Engine) QueueCandidates added in v0.7.25

func (w *Engine) QueueCandidates(ctx context.Context, target, repository, skill string) (map[string]any, error)

QueueCandidates lists what target's board can queue for skill: open pull requests for gh-safe-merge, open Discussion threads for gh-discuss, each naming the job that already owns it. Repository is needed only when target is not a repository. The listing goes through Candidates (gh) whatever the issue delivery mode; when it fails, the result carries an unavailable notice instead of a list, and numbers can still be queued.

func (*Engine) QueueJobs added in v0.7.25

func (w *Engine) QueueJobs(ctx context.Context, request QueueRequest) ([]QueueOutcome, error)

QueueJobs queues request's numbers as merge or discuss jobs, skipping any a job already owns. Merges are refused while no_merge is set.

func (*Engine) Run

func (w *Engine) Run(ctx context.Context) error

Run watches the targets and dispatches jobs until ctx is cancelled.

func (*Engine) SetTempDirs

func (w *Engine) SetTempDirs(dirs []string)

SetTempDirs replaces the ordered temp directories new clones are placed in.

func (*Engine) SetUnblockAgent

func (w *Engine) SetUnblockAgent(config unblockConfig)

SetUnblockAgent sets the unblock call's agent and model override.

func (*Engine) SetUnblockInterval

func (w *Engine) SetUnblockInterval(interval time.Duration)

SetUnblockInterval changes the watchdog's interval, restarting its wait so the new interval takes effect at once.

func (*Engine) TempDirs

func (w *Engine) TempDirs() []string

TempDirs reports the configured temp directories, empty for the system temp directory.

func (*Engine) TriggerUnblock

func (w *Engine) TriggerUnblock(key string) error

TriggerUnblock asks the watchdog for an unblock round now, over every stuck job or, given a job key, over that job alone. It never waits: the round runs on the watchdog's goroutine and logs what it finds and does, as a timed round does.

func (*Engine) UnblockInterval

func (w *Engine) UnblockInterval() time.Duration

UnblockInterval is how often the watchdog runs, or 0 when it is off.

type EngineSnapshot

type EngineSnapshot = core.Snapshot

EngineSnapshot is the engine's published state.

type ForkSource

type ForkSource = core.ForkSource

ForkSource names the fork pull requests come from when a repository is not writable.

type GHCLI

type GHCLI struct {
	Binary    string
	Filter    string
	AllIssues bool
	// FilterOverrides are per-target filters, which replace Filter and
	// AllIssues for their targets.
	FilterOverrides *core.FilterOverrides
	ReadyState      string
	// Timeout bounds each `gh` call; zero uses ghCommandTimeout. Interactive
	// callers that must answer quickly set a shorter one.
	Timeout time.Duration
	// contains filtered or unexported fields
}

GHCLI reads and writes GitHub through the gh CLI, and the public REST API for public repositories.

func (GHCLI) AddReaction

func (g GHCLI) AddReaction(ctx context.Context, repo string, commentID int64, content string) error

AddReaction adds an emoji reaction to a specific comment, used to acknowledge a direct mention was read.

func (GHCLI) AddReviewCommentReaction

func (g GHCLI) AddReviewCommentReaction(ctx context.Context, repo string, commentID int64, content string) error

AddReviewCommentReaction adds an emoji reaction to an inline pull request review comment, acknowledging a direct mention posted in one.

func (GHCLI) AddReviewReaction

func (g GHCLI) AddReviewReaction(ctx context.Context, repo string, nodeID string, content string) error

AddReviewReaction adds an emoji reaction to the body of a submitted pull request review, named by its GraphQL node ID. content uses the REST spelling, such as "eyes".

func (GHCLI) ClosingIssues

func (g GHCLI) ClosingIssues(ctx context.Context, repo string, number int) ([]int, error)

ClosingIssues reads repo#number and, when it is a pull request, returns the issues its description closes.

func (GHCLI) CommitMessage added in v0.7.32

func (g GHCLI) CommitMessage(ctx context.Context, repo, sha string) (string, error)

CommitMessage reads the message of commit sha in repo.

func (GHCLI) ConfigureWebhook

func (g GHCLI) ConfigureWebhook(ctx context.Context, value, endpoint, secret string) ([]string, error)

ConfigureWebhook ensures every webhook the target needs exists, and reports the names of the ones it had to create. Existing webhooks pointing at the endpoint are left untouched, so calling this repeatedly against the same target is safe.

func (GHCLI) ForkFor

func (g GHCLI) ForkFor(ctx context.Context, repo string) (string, error)

ForkFor reports where a fix for an issue in repo is pushed: an empty string when the authenticated user can push to repo, and otherwise the OWNER/REPO of the user's fork of it. GitHub's create-fork call returns the existing fork when there already is one, so it doubles as the lookup.

func (GHCLI) HydrateIssue

func (g GHCLI) HydrateIssue(ctx context.Context, repo string, issue *Issue) error

HydrateIssue fills in the dispatch-only fields a browser-mode extraction cannot read off the rendered issues page: the issue body, its creation time, and its dependency/sub-issue state. It is deliberately the smallest fetch that answers those questions -- one REST `GET /repos/:repo/issues/:number` plus the dependency lookup loadDependencies already performs -- and it goes through apiGETObject, so a public repository is read on the unauthenticated API and spends none of the token's rate limit. No GraphQL query is issued.

Callers are responsible for the request budget: the browser package.s issue source calls this once per newly seen dispatch candidate, never per tick and never for the whole list.

func (GHCLI) IssueAuthor

func (g GHCLI) IssueAuthor(ctx context.Context, repo string, number int) (string, error)

IssueAuthor reads who opened repo#number. The issues endpoint answers for pull requests too, since every pull request is also an issue.

func (GHCLI) ListComments

func (g GHCLI) ListComments(ctx context.Context, repo string, number int) ([]Comment, error)

ListComments lists the comments on an issue or pull request.

func (GHCLI) ListIssues

func (g GHCLI) ListIssues(ctx context.Context, repo string) ([]Issue, error)

ListIssues lists the dispatchable issues of a target.

func (GHCLI) ListOpenDiscussions added in v0.7.25

func (g GHCLI) ListOpenDiscussions(ctx context.Context, repo string) ([]OpenDiscussion, error)

ListOpenDiscussions lists repo's open Discussion threads, most recently updated first. Discussions have no REST API, so this is GraphQL.

func (GHCLI) ListOpenPullRequests added in v0.7.25

func (g GHCLI) ListOpenPullRequests(ctx context.Context, repo string) ([]OpenPullRequest, error)

ListOpenPullRequests lists repo's open pull requests, most recently updated first, with their checks, review decision, and mergeability.

func (GHCLI) ListReviewComments

func (g GHCLI) ListReviewComments(ctx context.Context, repo string, number int) ([]Comment, error)

ListReviewComments lists the inline review comments and submitted review bodies on pull request repo#number, oldest first.

func (GHCLI) ListUnansweredDiscussions

func (g GHCLI) ListUnansweredDiscussions(ctx context.Context, repo string) ([]Discussion, error)

ListUnansweredDiscussions lists top-level Discussion threads that have not received any reply yet. A discussion's own reply count doubles as the record of whether it still needs an answer, so no local state is needed to avoid re-dispatching an already-answered thread.

This is one of only three GraphQL calls left in aviary; GitHub Discussions has no REST API at all, so it is unavoidable. It only runs for repositories explicitly configured with a `discussions:` target, never as part of ordinary issue-repo polling.

func (GHCLI) OriginatingWorkState

func (g GHCLI) OriginatingWorkState(ctx context.Context, repo string, number int) (OriginatingWorkState, error)

OriginatingWorkState reads the state of an issue and the pull requests that work on it.

func (GHCLI) PostComment

func (g GHCLI) PostComment(ctx context.Context, repo string, number int, body string) error

PostComment posts a comment on an issue or pull request.

func (GHCLI) PostCommentURL

func (g GHCLI) PostCommentURL(ctx context.Context, repo string, number int, body string) (string, error)

PostCommentURL posts body on repo#number and reports the comment's URL.

func (GHCLI) PostCommentWithAttachments added in v0.7.6

func (g GHCLI) PostCommentWithAttachments(ctx context.Context, repo string, number int, body string, files []string) (string, error)

PostCommentWithAttachments posts body on repo#number with files uploaded and embedded through gh's --attach, and reports the comment's URL.

func (GHCLI) ProjectState

func (g GHCLI) ProjectState(ctx context.Context, repo string) (string, error)

ProjectState returns a fingerprint of a project board's dispatchable state. It fetches only item IDs, statuses, and issue identities, skipping the issue bodies, labels, and the per-issue dependency lookups a dispatching poll performs, so push mode can check an idle board cheaply and often.

func (GHCLI) RecentComments

func (g GHCLI) RecentComments(ctx context.Context, repo string, since time.Time) ([]RecentComment, error)

RecentComments lists repo's issue and pull request comments updated since the given time through the repository-wide comment listing, so a whole repository costs one request per scan however many issues it has.

func (GHCLI) RecentReviewComments

func (g GHCLI) RecentReviewComments(ctx context.Context, repo string, since time.Time) ([]RecentComment, error)

RecentReviewComments lists the inline review comments and submitted review bodies posted on repo's open pull requests since the given time (issue #695). Inline comments have a repository-wide listing like conversation comments do. Reviews have none, so they are read from each open pull request updated since then, which submitting a review counts as.

func (GHCLI) Run

func (g GHCLI) Run(ctx context.Context, args ...string) ([]byte, error)

Run runs gh with args and returns its standard output. A failure's error carries whatever gh printed, so callers can show its message.

func (GHCLI) SetIssueStatus

func (g GHCLI) SetIssueStatus(ctx context.Context, repo string, issue Issue, status string) error

SetIssueStatus moves an issue's board items to status.

func (GHCLI) StacksEnabled

func (g GHCLI) StacksEnabled(ctx context.Context, repo string) (bool, error)

StacksEnabled reports whether repo has GitHub stacked pull requests enabled. The Stacks API answers 404 Not Found for a repository without them, which is a definite "no" rather than an error.

type Identity

type Identity string

Identity uniquely names one aviary instance. It is the instance ID kept in Aviary's state, so a restarted instance recognizes its own prior claims; ownership claimed by other instances is still renegotiated.

type InboxMessage added in v0.7.8

type InboxMessage struct {
	// Source labels the run that sent the message, such as
	// "workflow bot/triage", and SourceURL links to that run.
	Source    string    `json:"source"`
	SourceURL string    `json:"source_url,omitempty"`
	Text      string    `json:"text"`
	At        time.Time `json:"at"`
}

InboxMessage is a scheduled task's or workflow's output sent to a Code Loop job (issue #999). It reaches the job's agent the way an allowed commenter's comment does: a running or waiting job is interrupted and resumed with it in the same session, and a paused or queued job hears it when it next runs.

type Issue

type Issue = core.Issue

Issue is a GitHub issue or Discussion thread a job works.

type IssueDependency

type IssueDependency = core.IssueDependency

IssueDependency is an issue an issue is blocked by.

type IssueHydrator

type IssueHydrator interface {
	HydrateIssue(ctx context.Context, repo string, issue *Issue) error
}

IssueHydrator reads one issue back from GitHub with its state and dependencies, so paused work whose issue the poll does not list can still be woken when its blockers close.

type IssueLabel

type IssueLabel = core.IssueLabel

IssueLabel is one of an issue's labels.

type IssueSource

type IssueSource = core.IssueSource

IssueSource lists a target's issues.

type IssueStatuser

type IssueStatuser interface {
	SetIssueStatus(context.Context, string, Issue, string) error
}

IssueStatuser moves an issue's board item to a status.

type JobDeliveryOptions added in v0.7.8

type JobDeliveryOptions struct {
	// Resume resumes a paused job when output arrives.
	Resume bool
	// Reopen retries a completed job with the output.
	Reopen bool
}

JobDeliveryOptions are a Code Loop target's delivery options (issue #1008). Without them a paused job queues the output and a completed job rejects it.

type JobObserver added in v0.7.42

type JobObserver func(job core.JobSnapshot, event, text string)

JobObserver learns that a job's status moved to a new reportable event (config.ProjectReportMerged, ProjectReportFailed or ProjectReportWaiting), with the report text it raises.

type JobSnapshot

type JobSnapshot = core.JobSnapshot

JobSnapshot and EngineSnapshot live in package core so the API and later dashboards render the same published state.

type LogSource

type LogSource func(component string, offset, limit int) ([]string, int)

LogSource pages core's log ring: the lines component logged after offset, oldest first, and the offset to ask from next time. An offset of zero or less asks for the latest limit lines; a limit of zero or less asks for every line.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager owns the Code Loop engine inside the Aviary server. It builds the engine from the projects every agent in aviary.yaml owns plus any runtime watches, applies changed settings to the running engine, and restarts it when a change needs a new one, such as a new target.

func NewManager

func NewManager(stateDir string) (*Manager, error)

NewManager returns a manager that keeps its work state and job transcripts under stateDir.

func (*Manager) AddWatch

func (m *Manager) AddWatch(watch Watch) error

AddWatch starts watching targets until RemoveWatch or the server stops.

func (*Manager) AddWatchInBackground added in v0.7.40

func (m *Manager) AddWatchInBackground(watch Watch) error

AddWatchInBackground adds watch as AddWatch does, returning once its targets are watched; the engine restarts onto them in the background.

func (*Manager) BackfillIssueMedia added in v0.7.8

func (m *Manager) BackfillIssueMedia(ctx context.Context, repository string, numbers []int, dryRun bool) (map[string]any, error)

BackfillIssueMedia is project_issue_backfill_media: post the images and videos sent with the request that filed each of repository's issues, before project_issue_create attached them, as one comment per issue. Each issue is matched to the user message whose turn called project_issue_create and got its URL back. An issue that already has the comment, or whose media cannot be found, is reported and left alone, so a rerun posts nothing new. dryRun reports what would be posted.

func (*Manager) ChatContext

func (m *Manager) ChatContext(ctx context.Context, project string) string

ChatContext is the context the Code Loop agent gets with each request: this instance, its targets, the board the chat was opened from when project is set, and a live snapshot of issue and job counts and per-job summaries, read now.

func (*Manager) CheckIssueFilter added in v0.7.41

func (m *Manager) CheckIssueFilter(ctx context.Context, target, filter string) (int, error)

CheckIssueFilter checks filter's search syntax for target and dry-runs it, returning how many open issues of target it matches. An invalid filter, including one GitHub's search rejects, is an error naming the problem.

func (*Manager) Checkpoint

func (m *Manager) Checkpoint(context.Context, saferestart.Marker) error

Checkpoint commits and pushes every running job's work and stops the engine. The work state keeps each job's session, so the jobs resume in the same sessions once Aviary is back.

func (*Manager) CloneClear

func (m *Manager) CloneClear(ctx context.Context) (core.ClearClonesResult, error)

CloneClear is project_clone_clear.

func (*Manager) CloneList

func (m *Manager) CloneList(ctx context.Context) (core.ClonesSnapshot, error)

CloneList is project_clone_list.

func (*Manager) ExplainJob

func (m *Manager) ExplainJob(target string, number int) (map[string]any, error)

ExplainJob is project_job_explain: why a job is where it is and what moves it on.

func (*Manager) GetJob

func (m *Manager) GetJob(target string, number, lines, events int) (map[string]any, error)

GetJob is project_job_get: one job's state, session, transcript events and scrollback. lines and events limit the scrollback lines and transcript events returned; 0 uses the defaults and a negative value returns all.

func (*Manager) GitHubRead added in v0.7.31

func (m *Manager) GitHubRead(ctx context.Context, repository, path, link, media string) (map[string]any, error)

GitHubRead is project_github_read: one GET of the GitHub REST API under a watched repository, named by a path under repos/OWNER/REPO or by a GitHub URL. media asks for a diff, patch or raw body instead of JSON.

func (*Manager) GitHubSession

func (m *Manager) GitHubSession() core.GitHubSession

GitHubSession reports browser delivery's GitHub sign-in, the zero session when GitHub is read some other way.

func (*Manager) GitHubSignIn

func (m *Manager) GitHubSignIn() (map[string]any, error)

GitHubSignIn opens GitHub's sign-in page in Aviary's browser, visibly, and returns at once; reads resume in this run once the sign-in lands, and the session state reports progress. Where no window can appear it fails at once with what to do instead.

func (*Manager) HoldNewJobs

func (m *Manager) HoldNewJobs(hold bool)

HoldNewJobs stops (true) or allows (false) dispatching new jobs. While held, the engine's polls start nothing and leave waiting jobs as they are, and no engine starts. Releasing a hold starts the engine again when a checkpoint stopped it, and polls at once for the work the hold kept back.

func (*Manager) Identity

func (m *Manager) Identity() string

Identity is this server's instance identity, as signed into its GitHub comments.

func (*Manager) ImportBrowserProfile

func (m *Manager) ImportBrowserProfile(from string) (map[string]any, error)

ImportBrowserProfile copies the GitHub sign-in from an Aviary browser profile signed in elsewhere into the profile browser delivery reads with, for machines where no sign-in window can appear. A running browser is restarted so its next read is signed in.

func (*Manager) InFlightJobs

func (m *Manager) InFlightJobs(target string) []int

InFlightJobs lists the issue numbers of target's jobs that still hold work, which removing the project stops: the engine restarts without target, so its running jobs are checkpointed and none of them resume.

func (*Manager) IssueComment

func (m *Manager) IssueComment(ctx context.Context, repository string, number int, text string, attachments []string) (map[string]any, error)

IssueComment is project_issue_comment: post an update that mentions the issue's author and this instance, so the owning job hears it.

func (*Manager) IssueCreate

func (m *Manager) IssueCreate(ctx context.Context, request core.IssueCreate) (map[string]any, error)

IssueCreate is project_issue_create: file an issue through gh-create with this instance's identity, uploading and embedding request's attachments. An empty request.Repository means the only watched repository.

func (*Manager) IssueFilter added in v0.7.41

func (m *Manager) IssueFilter(target string) string

IssueFilter is the issue search that selects target's work: its own filter, else the shared one, empty when every open issue is picked up.

func (*Manager) JobAction

func (m *Manager) JobAction(ctx context.Context, action, target string, number int) (map[string]any, error)

JobAction is project_job_retry, _pause, _resume, _stop and _dismiss. It refuses what the job's status does not allow. Stop waits for the agent to exit. Dismiss takes a failed scheduled run off the board's Failed state.

func (*Manager) ListJobs

func (m *Manager) ListJobs(targets []string, status string, states, kinds []string, query string, offset, limit int) map[string]any

ListJobs is project_job_list: every job, running and errored ones first, filtered by projects, engine status, board states, job kinds and a search query, and paged. A schedule is one entry, its latest run with the schedule's last_run, next_run and recent_runs, rather than a job per fire. No targets means every project. total counts the jobs that match them all; with a query, unfiltered_total counts those matching all but the query.

func (*Manager) Log

func (m *Manager) Log(line string)

Log receives one engine log line.

func (*Manager) LogTaskChange added in v0.7.25

func (m *Manager) LogTaskChange(project, task, change string)

LogTaskChange records a change the Code Loop agent made to a project's scheduled task in the Code Loop log.

func (*Manager) NotifyUpdated added in v0.7.41

func (m *Manager) NotifyUpdated(target string)

NotifyUpdated tells every dashboard that target changed, such as its issue filter, so open clients re-read it at once.

func (*Manager) ProjectModels added in v0.7.15

func (m *Manager) ProjectModels() map[string]ProjectModel

ProjectModels returns the effective job model of every watched target.

func (*Manager) QueueCandidates added in v0.7.25

func (m *Manager) QueueCandidates(ctx context.Context, target, repository, skill string) (map[string]any, error)

QueueCandidates is project_queue_candidates: what target's board can queue for skill, with the job that already owns each.

func (*Manager) QueueJobs added in v0.7.25

func (m *Manager) QueueJobs(ctx context.Context, target, repository, skill string, numbers []int, titles map[int]string) (map[string]any, error)

QueueJobs is project_job_queue: queue pull requests for gh-safe-merge or Discussion threads for gh-discuss as board jobs, in the order given, or ask for issues to be fixed with gh-fix. A number a job already owns is reported with that job instead of being queued twice.

func (*Manager) Reconcile

func (m *Manager) Reconcile(cfg *config.Config)

Reconcile applies a newly loaded configuration: the agents, the projects each one owns, the models: section, and the approval: section. A project's jobs run on projects.model and projects.fallbacks when model is set, else on its owning agent's model and fallbacks.

func (*Manager) ReconcileInBackground added in v0.7.40

func (m *Manager) ReconcileInBackground(cfg *config.Config)

ReconcileInBackground applies cfg as Reconcile does, but brings the engine in line with it in the background: a new project is in the watched targets, and shows in project_status as loading, as soon as it returns, while the engine restarts onto it and polls it without holding up the caller.

func (*Manager) Refresh

func (m *Manager) Refresh(target string) (map[string]any, error)

Refresh is project_refresh: poll GitHub now. Polls cover every project, so target only checks that it is watched.

func (*Manager) RemoveWatch

func (m *Manager) RemoveWatch(target string) bool

RemoveWatch stops runtime watches of target. It reports whether one was removed.

func (*Manager) RemoveWatchInBackground added in v0.7.40

func (m *Manager) RemoveWatchInBackground(target string) bool

RemoveWatchInBackground removes target's runtime watches as RemoveWatch does, stopping its jobs in the background.

func (*Manager) ResumeAfterRestart

func (m *Manager) ResumeAfterRestart(marker saferestart.Marker)

ResumeAfterRestart records the notice each job a safe restart stopped is resumed with. The engine resumes those jobs in their own sessions from the work state, as after any restart, and prompts each with marker.Message() instead of a bare "continue". Call it before the engine starts.

func (*Manager) RunProjectTask

func (m *Manager) RunProjectTask(ctx context.Context, run scheduler.ProjectRun) (string, error)

RunProjectTask runs one fire of a core "project" task as a job on the board of run.Project, which must be a watched project, and waits for its agent to exit. It is the scheduler.ProjectRunner core's scheduler hands project tasks to: the schedule itself lives in core, and Code Loop only runs the job.

func (*Manager) RunningJobs

func (m *Manager) RunningJobs() []saferestart.Job

RunningJobs lists the Code Loop jobs whose agents are running, for a safe restart. Waiting and paused jobs are left out: a restart leaves them alone.

func (*Manager) ScheduledRetry

func (m *Manager) ScheduledRetry(target string, number int) (string, error)

ScheduledRetry returns the core task a board Retry on the job fires again when the job is a scheduled run, after checking the job can be retried. It returns "" for any other job, which JobAction retries itself.

func (*Manager) SendJobMessage added in v0.7.8

func (m *Manager) SendJobMessage(ctx context.Context, target string, number int, message InboxMessage, options JobDeliveryOptions) (string, core.JobSnapshot, error)

SendJobMessage delivers a task's or workflow's output to the Code Loop job number of target, by the job's state: a running or waiting job is woken with it, a paused, queued or failed job keeps its state and sees it when it next runs, and a completed job, or one that no longer exists, rejects it. Any run of a schedule names the schedule: its run in flight is woken with the output, and between runs the schedule's next run starts with it. With options.Resume a paused job is resumed with the output instead, and with options.Reopen a completed issue job is retried with it, both through the same resume and retry actions as the dashboard's buttons. It returns the InboxDelivered, InboxQueued, InboxResumed or InboxReopened outcome and the job it reached.

func (*Manager) SetAviaryAgentRunner

func (m *Manager) SetAviaryAgentRunner(run AviaryAgentRunner)

SetAviaryAgentRunner makes engines started from now on run in-process agent definitions through run. Without one such an agent cannot be dispatched.

func (*Manager) SetBrowser

func (m *Manager) SetBrowser(cfg config.BrowserConfig)

SetBrowser records Aviary's browser settings, which browser delivery reads GitHub through. It takes effect on the next Reconcile.

func (*Manager) SetEngineEnabled

func (m *Manager) SetEngineEnabled(enabled bool)

SetEngineEnabled turns starting the engine on or off. With it off the manager still tracks projects and settings, which lets callers exercise the API without reaching GitHub. It is on by default.

func (*Manager) SetGHRunCommand added in v0.7.41

func (m *Manager) SetGHRunCommand(run func(context.Context, ...string) ([]byte, error))

SetGHRunCommand replaces the gh calls of the manager's engine and reads, for tests outside this package.

func (*Manager) SetJobObserver added in v0.7.42

func (m *Manager) SetJobObserver(observe JobObserver)

SetJobObserver sets what learns every job whose status moves to a new reportable event: failed, waiting or paused, or complete. Notifications use it.

func (*Manager) SetLogSource

func (m *Manager) SetLogSource(source LogSource)

SetLogSource sets where project_status reads Code Loop log lines from. Without one it reports none.

func (*Manager) SetMentionRouter

func (m *Manager) SetMentionRouter(route MentionRouter)

SetMentionRouter makes engines started from now on send direct mentions on finished or paused jobs to the Code Loop agent through route, which must not block on the agent's answer.

func (*Manager) SetProjectObserver added in v0.7.40

func (m *Manager) SetProjectObserver(observe ProjectObserver)

SetProjectObserver sets the function every ProjectEvent is sent to. It is called from whichever goroutine made the change, so it must not block.

func (*Manager) SetReportDelivery

func (m *Manager) SetReportDelivery(deliver ReportDelivery)

SetReportDelivery sets how projects that opted in to reports send them through an agent's channels.

func (*Manager) SetScheduleSource added in v0.7.8

func (m *Manager) SetScheduleSource(list ScheduleSource)

SetScheduleSource makes job lists and summaries report each schedule's next run from list.

func (*Manager) SetUsageRecorder

func (m *Manager) SetUsageRecorder(record UsageRecorder)

SetUsageRecorder makes engines started from now on report each agent run's token use, each job run's wall time, and each issue's merged or failed outcome to record, so Code Loop jobs count toward core usage tracking.

func (*Manager) SetWatchFilter added in v0.7.41

func (m *Manager) SetWatchFilter(target string, filter []string) (bool, error)

SetWatchFilter sets or, with an empty filter, clears the filter override of target's runtime watch. It reports whether target has a runtime watch.

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown checkpoints every running job, committing and pushing its work, then stops the engine and every subprocess it started. It is safe to call more than once.

func (*Manager) SiteFetch added in v0.7.31

func (m *Manager) SiteFetch(ctx context.Context, link string) (map[string]any, error)

SiteFetch is project_site_fetch: an HTTP GET of a page on a watched repository's own site, its homepage or GitHub Pages site, or its owner's github.io site, to check what is deployed.

func (*Manager) Snapshot

func (m *Manager) Snapshot(snapshot core.Snapshot)

Snapshot receives the engine's published state.

func (*Manager) Status

func (m *Manager) Status(_ context.Context, logOffset int, targets []string) map[string]any

Status is project_status: identity, targets with issue counts, job counts, the jobs in each board state, delivery and the last check, quota per CLI, each CLI provider once with its models and quota, and recent log lines. Passing logOffset returns only the lines logged since that offset. Passing targets counts board states over only their jobs, as project_job_list does.

func (*Manager) Transcript

func (m *Manager) Transcript(target string, number int) []transcript.Event

Transcript returns a job's transcript events, for callers that render them.

func (*Manager) UnblockRun

func (m *Manager) UnblockRun(target string, number int) (map[string]any, error)

UnblockRun is project_unblock_run: a stuck-job watchdog round now, over every stuck job or the one named.

func (*Manager) WatchedProjects added in v0.7.25

func (m *Manager) WatchedProjects() map[string]string

WatchedProjects maps each project this instance watches to the Aviary agent its scheduled tasks belong to, "" for a runtime watch no agent owns. The Code Loop agent's project task tools are scoped to these projects.

type MentionRouter

type MentionRouter func(ctx context.Context, prompt string) error

MentionRouter sends a prompt to the built-in Code Loop agent.

type MentionSource

type MentionSource interface {
	// RecentComments lists the comments posted or edited on any issue or
	// pull request in repo since the given time, oldest first.
	RecentComments(ctx context.Context, repo string, since time.Time) ([]RecentComment, error)
	// ClosingIssues names the issues pull request repo#number closes, so a
	// mention posted on a pull request reaches the issue it fixes. A number
	// that is not a pull request closes nothing.
	ClosingIssues(ctx context.Context, repo string, number int) ([]int, error)
}

MentionSource is what the poll modes scan for direct @/aviary:ID mentions. They receive no issue_comment webhook deliveries, so without it a mention posted on an issue or its pull request is never seen.

type OpenDiscussion added in v0.7.25

type OpenDiscussion struct {
	Number   int    `json:"number"`
	Title    string `json:"title"`
	Author   string `json:"author"`
	URL      string `json:"url"`
	Category string `json:"category,omitempty"`
	Comments int    `json:"comments"`
	Answered bool   `json:"answered"`
	OwnedBy  string `json:"owned_by,omitempty"`
}

OpenDiscussion is an open Discussion thread as the gh-discuss picker lists it.

type OpenPullRequest added in v0.7.25

type OpenPullRequest struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	Author string `json:"author"`
	URL    string `json:"url"`
	Draft  bool   `json:"draft"`
	// CI is passing, failing, pending, or none; Review is approved,
	// changes_requested, review_required, or none; Mergeable is mergeable,
	// conflicting, or unknown.
	CI        string    `json:"ci"`
	Review    string    `json:"review"`
	Mergeable string    `json:"mergeable"`
	UpdatedAt time.Time `json:"updated_at,omitzero"`
	// OwnedBy names the job already working on the pull request.
	OwnedBy string `json:"owned_by,omitempty"`
}

OpenPullRequest is an open pull request as the safe-merge picker lists it.

type OriginatingWorkState

type OriginatingWorkState = core.OriginatingWorkState

OriginatingWorkState is the state of an issue and its pull requests.

type ProjectEvent added in v0.7.40

type ProjectEvent struct {
	Type   string `json:"type"`
	Target string `json:"target"`
	// Agent is the agent that owns a saved project, empty for a runtime
	// watch no agent owns.
	Agent string `json:"agent,omitempty"`
}

ProjectEvent is one change to a watched project: added to or removed from the watched targets, or its issue count or jobs changed.

type ProjectModel added in v0.7.15

type ProjectModel struct {
	Model     string   `json:"model"`
	Fallbacks []string `json:"fallbacks"`
	Source    string   `json:"source"`
}

ProjectModel is the model a project's jobs run on: the specs in fallback order and where they come from, "project override", "from agent <name>", or "from models.defaults".

func (ProjectModel) String added in v0.7.15

func (p ProjectModel) String() string

String renders the model as project status shows it, such as "claude/opus (project override)".

type ProjectObserver added in v0.7.40

type ProjectObserver func(ProjectEvent)

ProjectObserver receives project events; see SetProjectObserver.

type ProjectStateSource

type ProjectStateSource = core.ProjectStateSource

ProjectStateSource reads a board's state.

type PullRequestWorkState

type PullRequestWorkState = core.PullRequestWorkState

PullRequestWorkState is the state of one pull request working an issue.

type QueueCandidateSource added in v0.7.25

type QueueCandidateSource interface {
	ListOpenPullRequests(ctx context.Context, repo string) ([]OpenPullRequest, error)
	ListOpenDiscussions(ctx context.Context, repo string) ([]OpenDiscussion, error)
}

QueueCandidateSource lists what a project's jobs can be queued for.

type QueueOutcome added in v0.7.25

type QueueOutcome struct {
	Number   int    `json:"number"`
	Key      string `json:"key,omitempty"`
	Queued   bool   `json:"queued"`
	OwnedBy  string `json:"owned_by,omitempty"`
	Reason   string `json:"reason,omitempty"`
	Position int    `json:"position,omitempty"`
}

QueueOutcome is what queueing one number did: Queued with its card's Key, or not, with OwnedBy naming the job that already owns it.

type QueueRequest added in v0.7.25

type QueueRequest struct {
	Target     string
	Repository string
	Skill      string
	Numbers    []int
	Titles     map[int]string
}

QueueRequest asks the engine to queue Numbers on Target's board for Skill, gh-safe-merge for pull requests or gh-discuss for Discussion threads, in that order. Repository is the OWNER/REPO they live in, needed only when Target is not a repository; Titles names them for their cards.

type RecentComment

type RecentComment struct {
	ID int64
	// Kind says which API ID belongs to. The zero value is a conversation
	// comment.
	Kind CommentKind
	// NodeID is the GraphQL node ID, the only handle a review body can be
	// reacted to through.
	NodeID string
	// Number is the issue or pull request the comment was posted on.
	Number int
	Body   string
	Author string
	// CreatedAt is when the comment was first posted, which UpdatedAt stops
	// saying as soon as it is edited.
	CreatedAt time.Time
	UpdatedAt time.Time
}

RecentComment is one comment found by a repository-wide scan of recent issue and pull request comments, or of pull request review comments and review bodies.

type ReportDelivery

type ReportDelivery func(agent, target, text string) error

ReportDelivery sends one report as agent through target, a scheduled-task route such as "channel:Team Slack" or "session:projects".

type ReviewCommentLister

type ReviewCommentLister = core.ReviewCommentLister

ReviewCommentLister lists pull request review comments.

type ReviewMentionSource

type ReviewMentionSource interface {
	// RecentReviewComments lists the inline review comments and submitted
	// review bodies posted or edited on any open pull request in repo since
	// the given time, oldest first.
	RecentReviewComments(ctx context.Context, repo string, since time.Time) ([]RecentComment, error)
}

ReviewMentionSource is what the poll modes scan for direct mentions posted in pull request reviews. Inline review comments and review bodies are separate GitHub APIs from the conversation RecentComments reads, so without it a mention posted in a review is never seen.

type ReviewReactor

type ReviewReactor = core.ReviewReactor

ReviewReactor reacts to pull request review comments.

type ScheduleSource added in v0.7.8

type ScheduleSource func() []domain.ScheduledTask

ScheduleSource lists core's scheduled tasks with their next fire and run history, as the scheduler's ListTasks does.

type SessionAgentOutputRunner

type SessionAgentOutputRunner interface {
	RunSessionWithOutput(context.Context, Issue, AgentSession, func(AgentSession), io.Writer) error
}

SessionAgentOutputRunner runs a coding agent in a resumable session, copying its output.

type SessionAgentRunner

type SessionAgentRunner interface {
	RunSession(context.Context, Issue, AgentSession, func(AgentSession)) error
}

SessionAgentRunner runs a coding agent in a session it can resume.

type SettingsSnapshot

type SettingsSnapshot = core.SettingsSnapshot

SettingsSnapshot is the engine's live settings.

type SettingsUpdate

type SettingsUpdate = core.SettingsUpdate

SettingsUpdate and SettingsSnapshot live in package core so the browser dashboard's settings modal can speak them without importing the root package.

type StackSource

type StackSource = core.StackSource

StackSource reports whether a repository allows stacked pull requests.

type StatusCLI

type StatusCLI struct {
	Name   string   `json:"name"`
	Models []string `json:"models"`
	Quota  string   `json:"quota"`
}

StatusCLI is one CLI provider in project_status: the models its jobs run on, from the provider/model agent specs, and the provider's own quota. A provider/model pair is a model of its provider, not a second provider.

type TargetAgentIdentifier

type TargetAgentIdentifier interface {
	AgentNameFor(target string) string
}

TargetAgentIdentifier picks the agent for a new job on one target.

type UIReporter

type UIReporter = core.UIReporter

UIReporter receives the engine's published state and log lines.

type UsageRecorder

type UsageRecorder func(domain.UsageRecord)

UsageRecorder receives the token use of one agent run, or one record of Code Loop work.

type Watch

type Watch struct {
	Targets []string `json:"targets"`
	// Agent is the Aviary agent the targets run under for the watch. Empty
	// keeps a target's owning agent, or models.defaults for a target no agent
	// owns.
	Agent    string                `json:"agent,omitempty"`
	Settings config.ProjectsConfig `json:"settings,omitzero"`
	// Filters overrides the issue search filter of single targets of the
	// watch, one entry per term group, as a saved project's filter does.
	Filters map[string][]string `json:"filters,omitempty"`
}

Watch is a set of targets watched for the life of the server without being saved to aviary.yaml, as `aviary watch` starts them. Settings overrides the shared projects settings for the whole engine while the watch runs; only its non-zero fields apply.

type WebhookEvent

type WebhookEvent struct {
	Kind        string
	Action      string
	Repository  string
	Ref         string
	Before      string
	After       string
	CommitCount int
	IssueNumber int
	IssueTitle  string
	CommentBody string
	// CommentAuthor is the GitHub login that posted CommentBody, used to
	// gate direct-mention triggers to an allowed set of commenters (issue
	// #294).
	CommentAuthor string
	// CommentID is CommentBody's GitHub comment ID, used to react to the
	// comment that carried a direct mention.
	CommentID int64
	// CommentNodeID is CommentBody's GraphQL node ID. A pull_request_review
	// delivery's review body can only be reacted to through it.
	CommentNodeID string
	// MentionedIssues names same-repository issues referenced by a closed
	// issue or pull request. The run loop uses these references to treat the
	// resulting refresh as a continuation sweep, so unowned work goes through
	// the cooperative handoff instead of looking like a brand-new pickup.
	MentionedIssues []int
	// OnPullRequest reports that an issue_comment delivery's comment was
	// posted on a pull request rather than an issue, and ClosesIssues names
	// the issues that pull request's description closes, so a direct mention
	// posted there reaches the issue it fixes. Review comment
	// and review deliveries are always on a pull request, and IssueNumber
	// names it.
	OnPullRequest bool
	ClosesIssues  []int
	// DiscussionNumber and DiscussionTitle carry the thread a `discussion`
	// delivery names. They are kept separate from the issue fields because a
	// discussion and an issue can share a number, and the issue fields key
	// the follow-up refresh chain.
	DiscussionNumber int
	DiscussionTitle  string
}

WebhookEvent is one GitHub webhook delivery, reduced to what the engine acts on.

type WebhookHandler

type WebhookHandler struct {
	Events      chan<- WebhookEvent
	Secret      string
	WebhookPath string
}

WebhookHandler accepts GitHub webhook deliveries, records useful delivery details, and asks the aviary to refresh its issue list. The payload is not used as the source of issue data: the next authenticated GitHub CLI query remains authoritative.

func (WebhookHandler) ServeHTTP

func (h WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WorkClosureChecker

type WorkClosureChecker = core.WorkClosureChecker

WorkClosureChecker reads an issue's OriginatingWorkState.

Directories

Path Synopsis
Package browser drives the headless Chrome that browser mode reads GitHub through.
Package browser drives the headless Chrome that browser mode reads GitHub through.
Package core holds the types aviary's halves exchange: the issues and comments a source produces, the state a run reads back from GitHub, and the target syntax that names where either comes from.
Package core holds the types aviary's halves exchange: the issues and comments a source produces, the state a run reads back from GitHub, and the target syntax that names where either comes from.
Package ngrok starts and supervises the ngrok tunnel that carries GitHub webhook deliveries to the Code Loop engine.
Package ngrok starts and supervises the ngrok tunnel that carries GitHub webhook deliveries to the Code Loop engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL