Documentation
¶
Overview ¶
Package daemon is the resident process behind the serve command: it runs the collector and the sweep on a schedule and serves the API on a Unix socket and on a token-guarded localhost port.
Index ¶
- Constants
- Variables
- func BadRequest(msg string) error
- func BriefMissing(ctx context.Context) string
- func CheckInputs(reg *dintent.Registry, d dintent.Def, in map[string]any, ...) (map[string]any, error)
- func LockFile(path string, busy error) (unlock func(), err error)
- func NotOffered(action string, u unit.Unit) string
- func OmniboxVocabulary(l *intentload.Loaded) omnibox.Vocabulary
- func ReadInfo(path string) (api.Info, error)
- func StoreWarning(st api.StoreStatus) string
- func SyncUnits(tasks coretasks.Reader, ledger *coreitems.Ledger) func(context.Context) ([]unit.Unit, error)
- type Actions
- type AgentDrafts
- func (a *AgentDrafts) Propose(ctx context.Context, session string, p api.AgentDraftProposal) (api.AgentDraft, error)
- func (a *AgentDrafts) Read(ctx context.Context, session string, id int64) (api.AgentDraft, error)
- func (a *AgentDrafts) Update(ctx context.Context, session string, u api.AgentDraftUpdate) (api.AgentDraft, error)
- func (a *AgentDrafts) Withdraw(ctx context.Context, session string, w api.AgentDraftWithdrawal) (api.AgentDraft, error)
- type AgentOutbox
- type AgentProposer
- type AheadPreparer
- type AheadReader
- type AppState
- type BlockReader
- type BriefAttempts
- type BriefHealth
- type BriefQueue
- type Budget
- type Call
- type CardsJob
- type Collector
- type Deps
- type Drafts
- type EventLog
- type Explained
- type Explainer
- type GitAccessLog
- type Headless
- type IngestJob
- type ItemsLedger
- type Keeper
- type Metas
- type Notices
- type OmniboxAsker
- type Overrides
- type Pauses
- type Placer
- type Plan
- type PluginJob
- type PluginRuntime
- type Presenter
- type PresenterHost
- type RecordWriter
- type Records
- type Refusal
- type RunHost
- type Server
- func (s *Server) AuthHandler() http.Handler
- func (s *Server) BriefReady(ctx context.Context, u unit.Unit) (intake.Readiness, error)
- func (s *Server) Decide(ctx context.Context, g gate.Gate) error
- func (s *Server) Deliver(ctx context.Context, g gate.Gate) error
- func (s *Server) Handler() http.Handler
- func (s *Server) LinkState(ctx context.Context, u unit.Unit) (signals map[string]bool, situation string, moved time.Time, ok bool, err error)
- func (s *Server) Once(g gate.Gate) bool
- func (s *Server) OpenIntakes(ctx context.Context) ([]intake.Intake, error)
- func (s *Server) PrepareTurn(ctx context.Context, intent string, u unit.Unit, guidance string, ...) (map[string]any, error)
- func (s *Server) RecheckHomes(ctx context.Context)
- func (s *Server) Release(ctx context.Context, g gate.Gate) error
- func (s *Server) RuleSent(ctx context.Context, d draft.Draft) error
- func (s *Server) Run(ctx context.Context) error
- func (s *Server) RunJob(name string) bool
- func (s *Server) SocketHandler() http.Handler
- func (s *Server) Unblock(ctx context.Context, g gate.Gate) error
- func (s *Server) Wait()
- func (s *Server) WakeJob(name string, at time.Time) bool
- type Skips
- type StoreWait
- type SweepFunc
- type Sweeper
- type Unblocker
- type Wakes
Constants ¶
const HomesMaxAge = 10 * time.Minute
HomesMaxAge is how old the last check of the agent homes may be before a health read starts another in the background.
const (
ReadModelCheckEnv = "LOOP_READMODEL_CHECK"
)
const ReconcileWait = 30 * time.Second
ReconcileWait is how long UserAPI waits for the start-up reconcile before it serves anyway.
const RecordFileSlack = 2 * time.Second
RecordFileSlack is how much older than its turn's start a record file may be.
const ShutdownGrace = 5 * time.Second
ShutdownGrace is how long the daemon waits for open requests to finish when it stops.
Variables ¶
var ( // ErrNoAgentSession refuses a call that names no session. ErrNoAgentSession = errors.New("the call names no agent session") // ErrNoDraftUnit refuses a proposal that names no unit from a session with no turn. ErrNoDraftUnit = errors.New("unit: required, this session has no turn whose unit the draft would post on") )
var ErrAlreadyRunning = errors.New("daemon already running")
Functions ¶
func BadRequest ¶
BadRequest is an error the daemon answers with 400.
func BriefMissing ¶
BriefMissing is why the turn an intake starts under ctx goes without a brief; "" when it has one or ctx is no intake's.
func CheckInputs ¶
func CheckInputs(reg *dintent.Registry, d dintent.Def, in map[string]any, surface, source string, automated bool) (map[string]any, error)
CheckInputs validates a request's inputs against the intent's definition and normalizes them to their types; surface is where the request comes from, "" for a client that sends no inputs.
func LockFile ¶
LockFile takes an exclusive flock on path without waiting; busy is the error when another process holds it.
func NotOffered ¶
NotOffered is the conflict of an action the row does not offer.
func OmniboxVocabulary ¶ added in v0.4.0
func OmniboxVocabulary(l *intentload.Loaded) omnibox.Vocabulary
OmniboxVocabulary is l's omnibox verbs, compared case and accents aside: what the omnibox runs, typed or proposed by the agent.
func StoreWarning ¶ added in v0.2.0
func StoreWarning(st api.StoreStatus) string
StoreWarning is st as one line: the message and the command to run.
Types ¶
type Actions ¶
type Actions interface {
Open(ctx context.Context, u unit.Unit, c Call) error // Focus the workspace, else the PR in the browser
Adopt(ctx context.Context, u unit.Unit, c Call) error
// Intent runs a round of the named intent; Call.Inputs holds the
// request's inputs and those its prepare filled.
Intent(ctx context.Context, name string, u unit.Unit, c Call) error
Run(ctx context.Context, u unit.Unit, c Call) error // sends the held round now; never counts against the cap
// Remove deletes the local workspace of a merged or closed pull request,
// or answers a Refusal when it would lose work.
Remove(ctx context.Context, u unit.Unit, c Call) error
}
Actions are the operations with side effects outside the store. The daemon runs each one but Open under its loop mutex.
type AgentDrafts ¶ added in v0.5.0
type AgentDrafts struct {
Outbox AgentOutbox
// Unit is the unit of session's turns; ok is false for a session with none.
Unit func(ctx context.Context, session string) (u unit.Unit, ok bool, err error)
Proposer AgentProposer
}
AgentDrafts are an agent session's calls on drafts, which the agent route and the MCP draft tools share. The session is the caller's authenticated one, never one a request names.
func (*AgentDrafts) Propose ¶ added in v0.5.0
func (a *AgentDrafts) Propose(ctx context.Context, session string, p api.AgentDraftProposal) (api.AgentDraft, error)
Propose proposes p for session and reads back the draft it made.
func (*AgentDrafts) Read ¶ added in v0.5.0
func (a *AgentDrafts) Read(ctx context.Context, session string, id int64) (api.AgentDraft, error)
Read is draft id as session reads it.
func (*AgentDrafts) Update ¶ added in v0.5.0
func (a *AgentDrafts) Update(ctx context.Context, session string, u api.AgentDraftUpdate) (api.AgentDraft, error)
Update revises draft u.ID at u.Rev for session.
func (*AgentDrafts) Withdraw ¶ added in v0.5.0
func (a *AgentDrafts) Withdraw(ctx context.Context, session string, w api.AgentDraftWithdrawal) (api.AgentDraft, error)
Withdraw withdraws draft w.ID at w.Rev for session; no reason is draft.WithdrawSuperseded.
type AgentOutbox ¶ added in v0.5.0
type AgentOutbox interface {
AgentRead(ctx context.Context, c outbox.Caller, id draft.ID) (draft.Draft, []draft.Revision, error)
AgentAmend(ctx context.Context, c outbox.Caller, id draft.ID, a outbox.Amendment) (draft.Draft, error)
AgentWithdraw(ctx context.Context, c outbox.Caller, id draft.ID, rev int64, reason string) (draft.Draft, error)
}
AgentOutbox is the outbox's API for an agent's calls on drafts.
type AgentProposer ¶ added in v0.5.0
type AgentProposer func(ctx context.Context, session string, u unit.Unit, p api.AgentDraftProposal) (draft.ID, error)
AgentProposer proposes session's draft p on u through u's plugin, the host path its draft tool takes.
type AheadPreparer ¶ added in v0.3.0
type AheadPreparer interface {
PrepareAhead(ctx context.Context, name string, u unit.Unit, c Call) error
}
AheadPreparer is Actions that readies, before an intent's round takes the loop mutex, what the round needs and may take long to get, such as a clone of its repository.
type AheadReader ¶
type AheadReader interface {
ReadAhead(ctx context.Context, u unit.Unit, full bool) context.Context
}
AheadReader is Actions that reads, before an action takes the loop mutex, what the action asks GitHub, so that it asks nothing while holding it; full also reads the pull request in full.
type AppState ¶
type AppState struct {
// contains filtered or unexported fields
}
AppState holds the app's last report; nil until the app reports.
type BlockReader ¶ added in v0.3.0
type BlockReader interface {
StartBlockKey(ctx context.Context, u unit.Unit) (key string, ok bool, err error)
}
BlockReader is Actions that names the start block holding a unit's round: the subject of the trust gate it waits on.
type BriefAttempts ¶ added in v0.3.0
type BriefAttempts interface {
// Attempt is the brief attempt a first turn of u waits on.
Attempt(ctx context.Context, u unit.Unit) (int, error)
}
BriefAttempts are the brief attempts the intakes wait on.
type BriefHealth ¶
type BriefHealth interface {
Status(ctx context.Context) (brief.Status, error)
// Breaker is the brief breaker; open is false while briefs run.
Breaker() (open bool, since time.Time, lastErr string, next time.Time)
}
BriefHealth is the brief queue as health reads it.
type BriefQueue ¶
type BriefQueue interface {
Run(ctx context.Context) (string, error)
// Touched wakes the queue for units whose brief inputs changed.
Touched(units []unit.Unit)
// Due is signaled when followed units are due a background brief.
Due() <-chan struct{}
// Forget drops a unit's brief, so the next run makes it again.
Forget(ctx context.Context, u unit.Unit) error
}
BriefQueue is the brief queue the daemon runs as a job.
type Budget ¶
type Budget interface {
// Low says the budget refuses background reads.
Low() bool
// RateLimit is the budget as a client shows it.
RateLimit() api.RateLimit
}
Budget is the forge's rate-limited budget.
type Call ¶
type Call struct {
Guidance string
// AgentHome is the caller's agent home; empty means the one the
// project's settings name.
AgentHome string
// Out receives what the action reports, sent back to the caller.
Out io.Writer
// WorkspaceID is the workspace remove acts on; "" is the one its unit
// is linked to.
WorkspaceID string
// Force lets remove past the workspace manager's terminal check.
Force bool
// Inputs are the intent's inputs, normalized to their types.
Inputs map[string]any
// Items are the unit's item ids and Task the task task the action was asked from; the turn's
// drafts are tied to them.
Items []string
Task string
// Manager and Parent are the request's: the workspace manager of the
// worktree the turn creates and the caller's worktree.
Manager, Parent string
// Block is the start block a trust gate names, which TrustAndRun and
// Unblock refuse to act past once another block replaced it; "" acts on
// the unit's block.
Block string
}
Call is what a delegated action gets besides the pull request.
type CardsJob ¶
type CardsJob interface {
// Changed must not block: the read model's publish waits on it.
Changed(c api.Change)
Run(ctx context.Context, rows cards.Rows)
}
CardsJob keeps the cards and derived items current with the rows.
type Collector ¶
Collector is the sources' slow job, which rebuilds what their ingestion keeps cheap; skipped holds truncation and warnings, which surface in health without failing the job.
type Deps ¶
type Deps struct {
// Units parses the keys of the unit routes; the providers it knows are
// the daemon's.
Units *unit.Registry
// Ingest are the sources' ingestion jobs.
Ingest []IngestJob
// Loading are the plugins that have not loaded since the daemon
// started, with why, by id; nil has none.
Loading func() map[string]string
// PluginHealth is how each plugin the daemon runs answers; nil runs
// none.
PluginHealth func(context.Context) []api.PluginHealth
// RowProviders build the read model's providers with the daemon's row
// deps, one per source.
RowProviders []func(readmodel.RowDeps) readmodel.Provider
// The store, one field per role; a nil role answers as a daemon with
// no store does.
Events EventLog
Overrides Overrides
Meta Metas
Records Records
// GitAccess keeps how git network operations went per host; nil keeps
// them in Store.
GitAccess *GitAccessLog
Meter *meter.Registry // nil counts nothing
// Fallbacks is how many workspace manager calls went to its CLI because
// its runtime drifted; nil when it does not count them.
Fallbacks func() int64
Pauses Pauses // nil reads as not paused and refuses a pause
// Collector runs the slow job; nil registers no fast and slow jobs.
Collector Collector
// Track reads a unit about to be tracked through its source, wrapping a
// failed read in port.ErrNotFound or port.ErrGitHub when it can tell
// which; the read's Save admits and follows it. Nil tracks nothing.
Track func(ctx context.Context, u unit.Unit) (port.TrackRead, error)
// Follows says whether a provider's source keeps its own follows: track
// and untrack of its units go to Track and Untrack. Nil follows none.
Follows func(unit.ProviderID) bool
Untrack func(ctx context.Context, u unit.Unit) error
// Resolve is the unit an address a person gives lands in, such as a
// Slack message ref; ok is false when no plugin reads it. Nil reads none.
Resolve func(ctx context.Context, address string) (u unit.Unit, ok bool, err error)
// PluginAction runs an action of plugin id that names no unit; nil
// runs none.
PluginAction func(ctx context.Context, id string, req api.PluginActionRequest) (json.RawMessage, error)
// PluginRun runs a command line of running plugin id, writing as it
// goes; nil runs none.
PluginRun func(ctx context.Context, id string, args []string, stdout, stderr io.Writer) (exit int, err error)
Sweep Sweeper // nil registers no sweep job
Actions Actions // nil answers 503 to delegated actions
// Intents is the registry as the profile defines it now, read on every
// rows rebuild and action; nil serves the bundled intents.
Intents func() *intentload.Loaded
// Plan is the workflows' plan; nil answers 503 to the plan routes.
Plan Plan
// Plans are the automatic rounds the open plan gates hold, which the rows
// show; nil shows none.
Plans readmodel.Plans
Changes *change.Log // nil notes nothing
// Snapshot pins the read model's loads to one read transaction; nil
// loads without one.
Snapshot readmodel.Snapshotter
// Brief, BriefStatus and BriefAttempts are the brief queue's roles; nil
// when brief.enabled is false.
Brief BriefQueue
BriefStatus BriefHealth
BriefAttempts BriefAttempts
Usage *coreusage.Service // nil registers no usage job
// Retain drops the store's rows past their retention and says what it
// dropped; nil registers no retain job.
Retain func(ctx context.Context) (summary string, err error)
// Budget is the forge's budget; nil reads as unknown.
Budget Budget
// Turns, Sessions and Views are the turn and view use cases and the
// sessions turns are typed into; nil answers 503 from the routes that
// need them.
Turns *turns.Service
Sessions turns.Sessions
Views *coreviews.Service
// RunHost opens a run's workspace and enters its session; Transcripts
// pages its agent transcript. nil offers neither.
RunHost RunHost
Transcripts turns.Transcripts
// Agents are the agents' states as the workspace snapshot last read
// them, never a call to the manager; nil reads as unknown, so a started
// turn's session is never told waiting.
Agents readmodel.Agents
// Activity reads what the loop spent on each provider's units for their
// rows; nil shows none.
Activity readmodel.Activities
// TurnByHand runs a turn the user asked for in the handle's session, ""
// outside Orca; nil answers 503 to AgentAPI's by-hand turns.
TurnByHand func(ctx context.Context, r api.ByHandRequest, handle string) (api.ByHandResult, error)
// Intakes keeps the turns users ask for: review, address and run are
// accepted at once and start once the first turn's brief is ready. nil
// runs them at once and answers when they end.
Intakes intake.Store
// IntakeBriefs tells an intake whether its brief is ready; nil starts
// every intake without one, as with briefs off.
IntakeBriefs intake.Briefs
// ByHandRef is the pull request a turn by hand is about; with Intakes
// it takes the turn through an intake, nil runs it at once.
ByHandRef func(ctx context.Context, r api.ByHandRequest, handle string) (unit.Unit, error)
// cannot run them; "" when it can or they are off.
BriefsUnavailable string
// Facts reads what a pull request's guide is matched against, for
// profile show <pr-url>; nil answers 503.
Facts func(ctx context.Context, u unit.Unit) (api.Facts, error)
// UnitEnded says whether u has ended as its plugin says, which a step gate's card reads to show the open
// units it is about first; nil keeps the task's order.
UnitEnded func(ctx context.Context, u unit.Unit) (bool, error)
// SessionWait is how long a turn by hand waits for its brief; 0 is
// brief.SessionWait.
SessionWait time.Duration
// AfterFunc arms the timer that ends a turn by hand's session wait and
// returns its stop; nil is time.AfterFunc.
AfterFunc func(d time.Duration, f func()) (stop func() bool)
// LoopMu serializes every loop write: sweep, review, take over, address, run.
// Shared across restarts of the server in one process; nil makes one.
LoopMu *lock.Mutex
// App is the menu bar's status, shared across restarts of the server
// like LoopMu; nil makes one.
App *AppState
Cfg config.Config
// Identity is who the viewer is in the forge, as its plugin's
// Presenter.Identity says; nil knows nobody.
Identity func(ctx context.Context) (src.Identity, error)
// Forge is the plugin of the units the daemon's viewer, intakes, brief
// queue, timings and budget serve; they serve nothing while it is
// disabled.
Forge unit.ProviderID
// Repo is the repository of a unit, owner/name; "" none, and nil
// knows none.
Repo func(ctx context.Context, u unit.Unit) (string, error)
// Background tags a job's context as background work, below the user's
// reserve of the forge's budget; nil tags nothing.
Background func(ctx context.Context) context.Context
// Presenters build each compiled-in plugin's presenter, by provider,
// with what the daemon serves it.
Presenters map[unit.ProviderID]func(PresenterHost) Presenter
// PluginPresenter is a running plugin's presenter; nil runs none.
PluginPresenter func(unit.ProviderID) (Presenter, bool)
Now func() time.Time
Version string
Log func(format string, args ...any)
StateDir string
Socket string
LockPath string
InfoPath string
// Restart is the command that restarts the daemon, which a refused
// client of another API major is told to run.
Restart string
// Store is the open store's version and last backup, for the health.
Store *api.StoreStatus
// ConfigWarning is the health warning about config.toml drifting from the
// running config, "" for none; nil never warns.
ConfigWarning func() config.Warning
// EffectWarnings are the turn effects that went unapplied after their
// turn went out; nil lists none.
EffectWarnings func() []string
// WorkspaceManager names the workspace managers in messages, such as
// "Claude Desktop or Orca".
WorkspaceManager string
// WorkspaceManagers name the enabled managers for the health answer, as
// displayed; ManagerNames are their registry names, and a hook naming
// another one is refused.
WorkspaceManagers []string
ManagerNames []string
// NotifierStart is the command that starts the menu bar; "" when this
// daemon expects none, and then its absence is no warning.
NotifierStart string
// Notices are what the workflows raise for the user, streamed to the
// event subscribers as they come; nil raises none.
Notices Notices
// MCP serves agents' MCP sessions on 127.0.0.1:MCPPort; nil listens on
// no MCP port.
MCP http.Handler
// ReadText words what an agent's turn answer command reads, as task_read does, read of gate id or of every
// unread answer when 0; nil prints the answers and the chat bare.
ReadText func(ctx context.Context, got messages.TaskRead, id int64) string
MCPPort int
// Startup reconciles the store and the views; Run holds
// UserAPI until it returns. nil serves at once with no report.
Startup func(ctx context.Context) (api.ReconcileReport, error)
// Homes checks the agent homes; Run checks them at start, the slow job,
// doctor, a session home no check covered and a health read of a result
// older than HomesMaxAge check them again, and health reads the last
// result. nil reports none.
Homes func(ctx context.Context) ([]api.HomeFinding, error)
// DryRunTurn stores the review turn of a profile try; nil answers 503.
DryRunTurn func(ctx context.Context, r api.DryRunTurnRequest) (api.DryRunTurn, error)
// Doctor runs doctor's checks that read the loop's state; nil runs none
// but the reconcile's.
Doctor func(ctx context.Context, q api.DoctorQuery) (api.DoctorReport, error)
// Plugins are every compiled-in plugin; PluginEnabled nil: all enabled.
Plugins []api.Plugin
PluginEnabled func(unit.ProviderID) bool
// Runtimes are the enabled plugins' streams, jobs and health.
Runtimes []PluginRuntime
// Items is the items ledger; nil answers 503 to the items routes.
Items ItemsLedger
// Cards are the units' stored cards; nil serves none.
Cards card.Store
// CardsJob is told each published row change; nil runs none.
CardsJob CardsJob
// Tasks is the tasks service; nil answers 503 to the tasks routes and runs no Sync. Messages are the
// Inbox messages, whose tasks' verbs it registers on Tasks.
Tasks *coretasks.Service
Messages *messages.Service
// Row is what a task's row shows of its facts: TaskView.OwedBy, Askers and ExtractionLag; nil leaves them
// empty.
Row func(ctx context.Context, t task.Task) (catalog.Row, error)
// Timeline reads a task's timeline; nil answers 503 to its route. TaskRecords are the records units
// keep, a task's brief among them; nil serves no Brief.
Timeline timeline.Reader
TaskRecords timeline.Records
// Gates resolves the decisions waiting on the user and GateReader lists them; nil answers 503 to the gate
// routes and serves no TaskView.Gates.
Gates *gates.Service
GateReader gates.Reader
// RecordWriter keeps the brief a created task carries; nil refuses a create with a brief. Placements
// keep where a created task's work runs; nil refuses a create with a placement.
RecordWriter RecordWriter
Placements placement.Overrides
// Drafts are the outbox's drafts the notifications read; nil: no draft notifies.
Drafts Drafts
// ConfigSet sets key path of the config file to v and applies the keys that apply live; nil: the
// daemon changes no configuration.
ConfigSet func(path []string, v any) error
// Skips are the workflows the user stopped on one unit; nil refuses a skip and lists none.
Skips Skips
// TasksMe resolves the user's identity over the enabled plugins and sets it on Tasks, saying whether it grew;
// the Sync worker calls it before each batch until it succeeds. nil: Tasks' identity stands.
TasksMe func(ctx context.Context) (grew bool, err error)
// TaskUnits are the units a full Sync covers: those with an open item or a live task; nil: none.
TaskUnits func(ctx context.Context) ([]unit.Unit, error)
// Wakes match the tasks' wakes after each tasks sync; nil matches none.
Wakes Wakes
// Outbox keeps the drafts; nil answers 503 to the draft routes. SendDrafts runs its sender, which
// publishes the approved drafts.
Outbox *outbox.Service
SendDrafts bool
// AgentDrafts serve an agent session's calls on drafts; nil answers 503 to api.AgentDrafts.
AgentDrafts *AgentDrafts
// Headless starts headless turns; nil answers 503 to the act route.
Headless Headless
// OmniboxAsk runs the omnibox's read-only agent call; nil answers 503 to the ask route.
OmniboxAsk OmniboxAsker
// Placer says where a session on a unit of a provider other than GitHub runs; nil offers the
// session mode unchecked.
Placer Placer
}
type EventLog ¶
type EventLog interface {
RecentActivity(ctx context.Context, limit int) ([]port.Activity, error)
RecordEvent(ctx context.Context, ev port.Event) error
}
EventLog reads and records the loop's events.
type Explained ¶
type Explained struct {
Unit unit.Unit
Items []workflow.Item
Workflows []api.UnitWorkflow
Errors []string
}
Explained is a unit's decisions: its items, and a line per workflow that gives none.
type Explainer ¶
Explainer is an optional capability of Plan: what every workflow of a unit's provider decides for that unit now, those that give no item included.
type GitAccessLog ¶
type GitAccessLog struct {
Store Metas
// contains filtered or unexported fields
}
GitAccessLog keeps, per host, the latest git network operation and the latest success, in the store's meta table.
func (*GitAccessLog) Record ¶
func (l *GitAccessLog) Record(ctx context.Context, r api.GitAccessRecord) error
type Headless ¶
Headless starts headless turns; Start returns once the turn is stored, and its call runs on.
type IngestJob ¶
type IngestJob struct {
ID unit.ProviderID
Job ingest.Job
}
IngestJob is a source's ingestion job; the daemon runs it as the job "ingest:<ID>".
type ItemsLedger ¶
ItemsLedger is the items ledger as the unit card reads it.
type Keeper ¶ added in v0.3.0
Keeper is a compiled-in plugin's bookkeeping on each new snapshot of the rows: the writes its rows imply, such as a mute whose situation changed.
type Metas ¶
type Metas interface {
Meta(ctx context.Context, key string) (string, error)
MetaPrefixed(ctx context.Context, prefix string) (map[string]string, error)
SetMeta(ctx context.Context, key, value string) error
}
Metas keeps the daemon's small values by key.
type Notices ¶
type Notices interface {
// Follow calls fn with each notice raised until stop is called.
Follow(fn func(api.Notice)) (stop func())
}
Notices are the notifications the workflows raise for the user.
type OmniboxAsker ¶ added in v0.4.0
type OmniboxAsker interface {
Ask(ctx context.Context, in omnibox.AskRequest, snap omnibox.Snapshot) (omnibox.AskReply, error)
}
OmniboxAsker runs the omnibox's read-only agent call over a snapshot of the read model.
type Overrides ¶
type Overrides interface {
Override(ctx context.Context, u unit.Unit) (map[string]string, error)
// SetOverride writes set in one transaction only while ifMatch holds;
// a value "" clears one.
SetOverride(ctx context.Context, u unit.Unit, set, ifMatch map[string]string) (written bool, err error)
// Held are the units of provider p the user holds.
Held(ctx context.Context, p unit.ProviderID) ([]unit.Unit, error)
}
Overrides are the host's overrides of units, by name (port.Overrides).
type Pauses ¶
type Pauses interface {
Pause(ctx context.Context) (round.Pause, error)
SetPause(ctx context.Context, p round.Pause) error
}
Pauses keeps the pause of every workflow that does not observe and of board moves.
type Plan ¶
type Plan interface {
// Evaluate is what the workflows of trigger t would decide now; it
// writes nothing and notes nothing.
Evaluate(ctx context.Context, t workflow.TriggerKind) (automation.Plan, error)
// Items are the stored plan's items f selects.
Items(ctx context.Context, f automation.Filter) ([]workflow.Item, error)
// Act carries the user's action on item id; the caller holds the loop
// lock.
Act(ctx context.Context, id string, a workflow.Action, guidance string) (workflow.Item, error)
// Drop discards u's pending items without marking them handled.
Drop(ctx context.Context, u unit.Unit, why string) error
// Release is the consequence of the resolved plan gate g on the item it
// names; the caller holds the loop lock.
Release(ctx context.Context, g gate.Gate) error
}
Plan is the workflows' plan and the user's actions on it.
type PluginJob ¶
type PluginJob struct {
Name string
Every time.Duration
Timeout time.Duration // a run's limit; 0 is pluginTimeout
// Retry is the first backoff after a failed run, doubling up to Every; 0 backs off from Every.
Retry time.Duration
// Run is one run; next is when the job next has work, zero to wait for Every or a wake.
Run func(ctx context.Context) (summary, skipped string, next time.Time, err error)
}
PluginJob is a plugin's daemon job, named as the plugin names it.
type PluginRuntime ¶
type PluginRuntime struct {
ID unit.ProviderID
// Run is a long-running stream, run until the daemon stops and started
// again streamRestart after it returns.
Run func(ctx context.Context) error
Jobs []PluginJob
Health func(ctx context.Context) (api.SourceHealth, error)
// WebAssets are served under /plugins/<id>/.
WebAssets fs.FS
}
PluginRuntime is what an enabled plugin runs in the daemon; a nil field is absent.
type Presenter ¶ added in v0.3.0
type Presenter interface {
Action(ctx context.Context, req src.ActionRequest) (json.RawMessage, error)
View(ctx context.Context, req src.ViewRequest) (json.RawMessage, error)
}
Presenter is a plugin's source logic as the daemon reaches it: the actions a person runs on its units and its views. A running plugin's client is one; so is a compiled-in module's.
type PresenterHost ¶ added in v0.3.0
type PresenterHost struct {
Model *readmodel.Model
// Settings are the rows' settings now; BriefOn says the brief queue runs.
Settings func() readmodel.RowSettings
BriefOn bool
// Intakes are the open intakes by unit, the oldest first.
Intakes func(ctx context.Context) (map[unit.Unit][]intake.Intake, error)
// Books are the units' turn books; nil when the daemon keeps no turns.
Books func(ctx context.Context, units ...unit.Unit) (map[unit.Unit]turn.Book, error)
// Viewer is who the viewer is in the forge, cached.
Viewer func(ctx context.Context) (src.Identity, error)
// Units are the daemon's codecs.
Units *unit.Registry
Now func() time.Time
Logf func(format string, args ...any)
}
PresenterHost is what the daemon serves a compiled-in plugin's presenter beside the broker: the rows as the read model derives them.
type RecordWriter ¶ added in v0.3.0
type RecordWriter interface {
PutRecord(ctx context.Context, u unit.Unit, kind string, w task.Writer, data []byte, at time.Time) error
}
RecordWriter keeps a unit's record of a kind, written by w; a new one replaces the unit's last of that kind.
type Records ¶
type Records interface {
Turn(ctx context.Context, id string) (port.SentText, bool, error)
// Brief is u's stored brief; ok is false for none.
Brief(ctx context.Context, u unit.Unit) (b intake.StoredBrief, ok bool, err error)
// UnitlessEvents are the events of no source's unit, oldest first.
UnitlessEvents(ctx context.Context) ([]port.Event, error)
}
Records reads what turns and briefs left behind.
type Refusal ¶
type Refusal struct {
Reason, Detail string
// Source names the tool whose message Detail is, "" for the loop's own.
Source string
Forceable bool
}
Refusal is an action that would do harm, with the reason and its detail. Forceable marks a refusal that asking again with force would get past.
type RunHost ¶ added in v0.3.0
type RunHost interface {
// Focus brings the workspace on screen in the manager's app.
Focus(ctx context.Context, manager, workspaceID string) error
// Wake gives the dormant session of u a live process again in its
// manager, launched as a turn of intent on u would be.
Wake(ctx context.Context, u unit.Unit, intent string, sess turn.Session) error
}
RunHost reaches a run's workspace and session in their workspace manager.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AuthHandler ¶
AuthHandler is Handler behind the token check, for the TCP port, which serves no AgentAPI and no AdminAPI.
func (*Server) BriefReady ¶
BriefReady is the brief queue's answer for a round the sweep is about to propose or send on the pull request.
func (*Server) Decide ¶ added in v0.3.0
Decide is a resolved proposal gate's consequence: a verb a gate held runs, once approved, as the person through the verb path a person's request takes, its bridge and reply included; any other proposal is the messages'.
func (*Server) Deliver ¶ added in v0.3.0
Deliver is a resolved question or post gate's consequence: the messages deliver its answer, under the loop lock with the gate's unit read ahead, as an answer typed or resumed expects.
func (*Server) LinkState ¶ added in v0.3.0
func (s *Server) LinkState(ctx context.Context, u unit.Unit) (signals map[string]bool, situation string, moved time.Time, ok bool, err error)
LinkState is what the read model holds of unit u for the facts of the tasks that link it: its link signals, its situation, and when it last moved, the start of its situation under the host's overlays; ok is false for a unit no provider serves a row of.
func (*Server) Once ¶ added in v0.3.0
Once says a gate's consequence runs at most once: a round the daily cap held, and a verb a gate held, act in the user's name and leave nothing a second run reads.
func (*Server) OpenIntakes ¶
OpenIntakes lists the open intakes but the session ones nobody asks for; none when the daemon keeps no intakes.
func (*Server) PrepareTurn ¶ added in v0.6.0
func (s *Server) PrepareTurn(ctx context.Context, intent string, u unit.Unit, guidance string, inputs map[string]any) (map[string]any, error)
PrepareTurn is inputs with what the prepare of intent's role filled on u, the same an action or a turn by hand of it runs; inputs as given when it has none. A refusal, or a plugin that is off, wraps src.ErrUnfit and a plugin out of reach src.ErrUnavailable, each keeping the daemon's error, so an action answers it with the status a prepare's refusal has.
func (*Server) RecheckHomes ¶
RecheckHomes checks the agent homes now; concurrent calls share one check.
func (*Server) Release ¶ added in v0.3.0
Release is a resolved plan gate's consequence: the plan carries it onto the item the gate names, under the loop lock; an approved gate of a round the daily cap held runs that round by hand.
func (*Server) RuleSent ¶ added in v0.5.0
RuleSent tells the user that a rule of theirs posted d, once it is sent; the composition root runs it after each send.
func (*Server) SocketHandler ¶ added in v0.3.0
SocketHandler is Handler with the runtime's profiles under /debug/pprof/, for the socket alone: the person who owns the socket reads them, never the token-guarded port.
func (*Server) Unblock ¶ added in v0.3.0
Unblock is a resolved trust gate's consequence on the start block of its unit's round: an approval trusts the folder and runs the round, any other resolution lifts the block until a new trigger.
type Skips ¶ added in v0.4.0
type Skips interface {
Skip(ctx context.Context, workflow string, u unit.Unit) error
Unskip(ctx context.Context, workflow string, u unit.Unit) error
Of(ctx context.Context, u unit.Unit) ([]string, error)
}
Skips are the workflows the user stopped on one unit; *skips.Service satisfies it.
type StoreWait ¶ added in v0.2.0
type StoreWait struct {
Version string
StateDir string
Socket string
LockPath string
InfoPath string
// HTTPPort is the cockpit's configured port; 0 reuses the earlier one.
HTTPPort int
// Status is the store's state, read on each request.
Status func() api.StoreStatus
// Ready is asked every Every; true ends the wait.
Ready func() bool
Every time.Duration
}
StoreWait is the daemon while it cannot open its store: it answers its health with the store's state, refuses every other request with that state's message and fix, and returns once Ready says the store may open. It holds the daemon's lock and socket meanwhile, so clients reach it, not a second daemon.
type SweepFunc ¶
SweepFunc is a Sweeper with no deadline that reads no snapshot and runs whole under the loop lock.
func (SweepFunc) Seen ¶
func (SweepFunc) Seen() port.Generation
type Sweeper ¶
type Sweeper interface {
// Sweep plans without loop and takes loop only to act on the plan.
Sweep(ctx context.Context, loop sync.Locker) (summary, skipped string, err error)
// Due is the earliest instant a decision of the last sweep changes with
// no input changing: conflict window end, start block day, cap rollover
// with a capped step, a review turn reaching the 30-day cutoff. Zero
// when none.
Due() time.Time
// Seen is the change log generation the last sweep's workspace snapshot
// read was current at; zero when it read none.
Seen() port.Generation
}
Sweeper is the sweep job's port.
type Unblocker ¶
type Unblocker interface {
// TrustAndRun trusts the folder the round's start block names, in the
// agent home the round ran with or, unknown, in every agent home the
// loop knows, lifts the block and sends the round now.
TrustAndRun(ctx context.Context, u unit.Unit, c Call) error
// Unblock marks the trigger of the round a start block holds handled,
// so the round waits for a new one; the caller records the block lifted.
Unblock(ctx context.Context, u unit.Unit, c Call) error
}
Unblocker is Actions that lifts the start block of a round.
Source Files
¶
- actions.go
- admin.go
- agent.go
- agent_drafts.go
- api.go
- attention_tasks.go
- briefs.go
- builtins.go
- cards.go
- catalog.go
- chat.go
- checks.go
- daemon.go
- digest.go
- draft_card.go
- drafts.go
- facts.go
- gate_actions.go
- gates.go
- gitaccess.go
- headless.go
- health_plugins.go
- home.go
- intake.go
- intents.go
- items.go
- jobs.go
- keys.go
- lock_unix.go
- messages.go
- meter.go
- offers.go
- omnibox.go
- omnibox_ask.go
- omnibox_run.go
- outbox.go
- outbox_view.go
- owner_unix.go
- perms.go
- plan.go
- plan_target.go
- plan_unit.go
- plugin_actions.go
- pluginassets.go
- plugins.go
- ports.go
- presenters.go
- probe.go
- question_actions.go
- queues.go
- refs.go
- reply.go
- resolve.go
- review.go
- rows.go
- runs.go
- search.go
- situationlog.go
- sse.go
- storewait.go
- strings.go
- taskcreate.go
- tasks.go
- tasks_match.go
- taskview_merged.go
- taskview_related.go
- timeline.go
- timings.go
- unitactions.go
- units.go
- window.go
- wire.go
- workflows.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agentdraftstest is a fake of the outbox's agent API, which keeps drafts in memory and answers by their state as the outbox does: a session reaches a draft on its units or proposed from one of them; it revises or withdraws one of those of turn or session origin, held or failed, at the draft's rev, at least 1, stamped with its session.
|
Package agentdraftstest is a fake of the outbox's agent API, which keeps drafts in memory and answers by their state as the outbox does: a session reaches a draft on its units or proposed from one of them; it revises or withdraws one of those of turn or session origin, held or failed, at the draft's rev, at least 1, stamped with its session. |