api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 20 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 api is the schema every client of the daemon speaks: its version, its headers and the wire types it decodes.

Index

Constants

View Source
const (
	DoctorOK      = "ok"
	DoctorMissing = "missing"
	DoctorInfo    = "info"
)

Doctor marks.

View Source
const (
	AgentPrefix         = "/api/agent/"
	AgentTurnsStart     = "/api/agent/turns/start"
	AgentTurnsByHand    = "/api/agent/turns/by-hand"
	AgentTurnsEnd       = "/api/agent/turns/end"
	AgentSessionsStart  = "/api/agent/sessions/start"
	AgentSessionsStop   = "/api/agent/sessions/stop"
	AgentSessionsPrompt = "/api/agent/sessions/prompt"
	AgentAnswer         = "/api/agent/answer"
)

AgentAPI paths, served on the Unix socket only. The caller's session is the SessionHeader.

View Source
const (
	Header = "X-Loop-API"
	// SessionHeader carries the handle the workspace manager gave the calling
	// agent's process; the daemon resolves it to the loop's session.
	SessionHeader = "X-Loop-Session"
	// ManagerHeader names the manager that gave SessionHeader's handle, when
	// the caller knows it: a hook does, an MCP request does not.
	ManagerHeader = "X-Loop-Manager"
	// MCPKeyHeader carries the per-install secret the MCP endpoint requires.
	MCPKeyHeader = "X-Loop-Key"
)
View Source
const (
	AdminPrefix     = "/api/admin/"
	AdminDryRunTurn = "/api/admin/dry-run-turn"
	AdminDoctor     = "/api/admin/doctor"
	// AdminTurn takes the pull request's URL in the query parameter pr.
	AdminTurn = "/api/admin/turn"
	// AdminProbe sends a probe turn: the loop's self-test of an agent home.
	AdminProbe = "/api/admin/probe"
	// AdminGitAccess records a git access outcome another process saw.
	AdminGitAccess = "/api/admin/git-access"
	// AdminMeter is the metered cost of every scope since the daemon started.
	AdminMeter = "/api/admin/meter"
)

AdminAPI paths: the daemon's answers to diagnostics and dry runs, served on the Unix socket only, like AgentAPI.

View Source
const (
	DraftReply = "reply"
	DraftReact = "react"
)

The kinds of draft the user writes: a reply in the unit's conversation (a comment on a pull request) and a reaction to it.

View Source
const (
	Intakes       = "/api/intakes/{seq}"
	IntakeWithout = "/api/intakes/{seq}/without"
	IntakeCancel  = "/api/intakes/{seq}/cancel"
)

Intake paths. Intakes answers ?after=<n>&wait=<seconds>: the log lines past the n-th, once there are any or the intake ends, waiting at most IntakeWaitMax seconds.

View Source
const (
	IntakeAccepted = "accepted"
	IntakeBriefing = "briefing"
	IntakeStarting = "starting"
	IntakeStarted  = "started"
	IntakeFailed   = "failed"
	IntakeCanceled = "canceled"
)

The states of an intake.

View Source
const (
	// CapabilityCheckouts: a session on a unit runs in a checkout of the
	// unit's own repository.
	CapabilityCheckouts = "checkouts"
	// CapabilityBriefs: the brief queue briefs the plugin's units.
	CapabilityBriefs = "briefs"
	// CapabilityPublishes: the plugin posts approved drafts.
	CapabilityPublishes = "publishes"
	// CapabilityReacts: the plugin posts reactions.
	CapabilityReacts = "reacts"
	// CapabilityItems: the plugin's rows derive items.
	CapabilityItems = "items"
	// CapabilityDetail: the cockpit shows a detail of the plugin's units,
	// which a client opens in place of the unit's link.
	CapabilityDetail = "detail"
)

The capabilities a plugin serves in Plugin.Capabilities.

View Source
const (
	// ViewUnitRow answers a UnitRowQuery with the Row of a unit the read
	// model does not list, its Unit as its source names it; ErrNotFound for
	// a unit the plugin has no row of.
	ViewUnitRow = "unit.row"
	// ViewUnitDetail answers a UnitQuery with the PluginDetail of a unit.
	ViewUnitDetail = "unit.detail"
	// ViewUnitChecks answers a UnitQuery with the unit's []CheckDetail.
	ViewUnitChecks = "unit.checks"
	// ViewTimings answers a TimingsQuery with a TimingsReport.
	ViewTimings = "timings"
)

The views the daemon asks of a unit's plugin, by the name its View serves them under, and what each answers.

View Source
const (
	ProbeOwner = "loop-e2e"
	ProbeRepo  = "probe"
)

ProbeOwner and ProbeRepo name the forge unit of every probe, keyed <owner>/<repo>#<n>: one that exists nowhere, so no inventory holds it and no view has a role for it.

View Source
const (
	ReviewPath     = "/api/review"
	ReviewStepDone = ReviewPath + "/steps/{step}/done"
)

The Review's routes: ReviewPath serves the current Review, ReviewStepDone marks one of its steps done.

View Source
const (
	ViewsPath    = "/api/views"
	TasksPath    = "/api/tasks"
	TaskDetail   = TasksPath + "/{id}"
	TaskVerb     = TaskDetail + "/{verb}"
	CountersPath = "/api/counters"
	DigestPath   = "/api/digest"
)

The tasks' routes: ViewsPath serves the ViewsCatalog, TasksPath lists a view (query parameters view, area, context as "a,b" and since, a Since's String) and takes a TaskCreate, TaskVerb runs a verb, CountersPath serves the counters of the query parameter area (narrowed to the tasks holding each CountersTerm), DigestPath the daily digest of the query parameter day (YYYY-MM-DD).

View Source
const (
	TimelinePath  = TaskDetail + "/timeline"
	RunsPath      = TaskDetail + "/runs"
	ChatPath      = TaskDetail + "/chat"
	AttachPath    = TaskDetail + "/attach"
	GatesPath     = "/api/gates"
	GatePath      = GatesPath + "/{id}/{intent}"
	RunOpen       = "/api/runs/{seq}/open"
	RunEnter      = "/api/runs/{seq}/enter"
	RunTranscript = "/api/runs/{seq}/transcript"
)

A task's timeline, runs and chat, and the gates and runs as resources: TimelinePath serves a task's []TimelineEvent, newest first (query parameters kinds as "a,b", before a Seq and limit), RunsPath its []RunView, ChatPath takes a ChatRequest, AttachPath makes the caller's session, from SessionHeader, a run of the task (it takes an AttachRequest and answers a ByHandResult). GatesPath lists []GateView (query parameter status as "a,b", open when absent), GatePath resolves gate id with intent (a TaskRequest's args carry an answer). RunOpen opens a run's workspace in its manager, RunEnter enters its session, RunTranscript pages its transcript as a TranscriptPage (query parameters from and limit).

View Source
const (
	// AdminTimings takes the days to look back in the query parameter since.
	AdminTimings = "/api/admin/timings"
	// AdminFacts takes the pull request's URL in the query parameter pr.
	AdminFacts = "/api/admin/facts"
)
View Source
const (
	MilestoneReviewWait  = "request_to_my_review"
	MilestoneToApproval  = "opened_to_approved"
	MilestoneToMerge     = "opened_to_merged"
	MilestoneMineToMerge = "mine_opened_to_merged"
	MilestoneInLoop      = "followed_to_unfollowed"
	MilestoneLeadTime    = "first_push_to_merged"
	MilestoneMineLead    = "mine_first_push_to_merged"
)

The keys of TimingsReport.Milestones.

View Source
const (
	WaitingOnMe     = "me"
	WaitingOnOthers = "others"
	WaitingOnLoop   = "loop"
)

The keys of TimingsReport.Waiting: who a followed pull request waited on, by its situation events.

View Source
const (
	TurnStartWait = "sent_to_started"
	TurnBriefWait = "brief_wanted_to_sent"
)

The keys of TimingsReport.Turns beyond the intents: the wait from sent to started, and an automated first turn's wait for its brief, from brief_wanted to the turn's send.

View Source
const (
	UpcomingGate       = "gate"
	UpcomingUnmute     = "unmute"
	UpcomingBriefRetry = "brief_retry"
)
View Source
const (
	TaskActionPrefix    = "task:"
	AttentionDraftForMe = TaskActionPrefix + "delegate:headless"
	AttentionReply      = "reply:save"
	AttentionSendReply  = "reply:send"
)

AttentionAction ids are catalog ids, task:<verb> (task:<verb>:<mode> with the delegate's mode) for a task's verb, answer:option:<id>, answer:yes, answer:no and answer:text for the answer's choices, and reply:save and reply:send for a reply typed in the notification. The actions of an Inbox task's notification: Draft for me delegates it headless, Reply saves the typed text to the Outbox as a reply on its unit and Send reply sends it at once.

View Source
const (
	StoreOK             = "ok"
	StoreBusy           = "busy"
	StoreNeedsMigration = "needs-migration"
	StoreTooNew         = "too-new"
	StoreFailed         = "failed"
)

The states of StoreStatus: StoreOK is open; the others leave the store closed until a command fixes it or, for StoreBusy, the command finishes.

View Source
const Actions = "/api/actions"

Actions is the route of the action specs.

View Source
const AnswerQueued = "answer queued; the agent session is told of it when the agent stops"

ActionResult carries, for an action an intake runs, the intake that accepted it instead of the action's output. AnswerQueued is the output line of an answer that waits for its busy agent to stop.

View Source
const Catalog = "/api/catalog"

Catalog is the route of the served presentation.

View Source
const CountersTerm = "term"

CountersTerm is the query parameter of CountersPath, repeated, that counts only the tasks holding every term, as TaskMatches reads them.

View Source
const Drafts = "/api/drafts"

Drafts lists drafts (query parameters state, a comma list, id, a comma list of draft ids, and task; with none, the Outbox's: those whose gate is open, and those whose gate approved them and whose delivery failed) and, posted a DraftCreate, holds a draft the user wrote. A draft's decision is its gate's, resolved through GatePath; a draft gate's Subject is its Draft.

View Source
const GateKindDraft = "draft"

GateKindDraft is the Kind of a draft's gate.

View Source
const IntakeWaitMax = 25
View Source
const Keys = "/api/keys"

Keys serves the keyboard map of a surface: GET takes the query parameter surface (web, tui or menubar).

View Source
const Plan = "/api/plan"

Plan is the workflows' plan: GET takes a PlanQuery's fields as query parameters, POST a PlanActRequest.

View Source
const PluginAction = "/api/plugins/{id}/actions/{action}"

PluginAction runs an action of a running plugin that names no unit: POST takes a PluginActionRequest and answers the plugin's JSON.

View Source
const PluginAssets = "/plugins/{id}/{path...}"

PluginAssets serves an enabled plugin's WebAssets; 404 while it is disabled.

View Source
const PluginRun = "/api/plugins/{id}/run"

PluginRun runs a command line of a running plugin: POST takes a PluginRunRequest and streams PluginRunChunk lines, one JSON object a line, as the command writes, the last one its exit.

View Source
const PluginView = "/api/plugins/{id}/views/{view}"

PluginView serves one of an enabled plugin's views, its Presenter.View: GET -> the view's content, its query the request's query parameters as a JSON object of strings; POST with the query as the body -> the same.

View Source
const Plugins = "/api/plugins"

Plugins is the route of every compiled-in plugin: GET -> []Plugin.

View Source
const RefusalNotOffered = "not_offered"

RefusalNotOffered is the refusal code of an action the row does not offer.

View Source
const Resolve = "/api/resolve"

Resolve is the unit an address lands in: GET takes the address as the address query parameter and answers a Resolved.

View Source
const Rows = "/api/rows"

Rows takes the query parameters view, person and since, a Since's String.

View Source
const UnitDetail = "/api/units/{provider}/{key}"

UnitDetail is a unit's detail; its checks and actions are under it.

View Source
const Version = "1"

Version is the API this binary speaks, a major only. A client of another major is refused; a change older clients can ignore, such as a new field, keeps it.

Variables

View Source
var ErrSessionHandle = errors.New(SessionHeader + " is missing or not a process handle: this session does not run under one of " + brand.Name + "'s workspace managers, so " + brand.Name + " cannot tell which turn it records")
View Source
var ErrUnknownSession = errors.New(SessionHeader + " names a process no session of " + brand.Name + " took: start the session from " + brand.Name + ", or let its SessionStart hook run")

ErrUnknownSession is a handle no session of the loop took.

View Source
var Operations = []Operation{
	{"GET", "/api/health"},
	{"GET", Rows},
	{"GET", Catalog},
	{"GET", Resolve},
	{"GET", UnitDetail},
	{"GET", UnitDetail + "/checks"},
	{"POST", "/api/jobs/{name}"},
	{"POST", UnitDetail + "/{action}"},
	{"GET", Actions},
	{"GET", Keys},
	{"GET", "/api/events"},
	{"GET", "/api/activity"},
	{"POST", "/api/pause"},
	{"POST", "/api/app"},
	{"POST", "/api/workspaces/remove-clean"},
	{"GET", Intakes},
	{"POST", IntakeWithout},
	{"POST", IntakeCancel},
	{"GET", Plan},
	{"POST", Plan},
	{"GET", Plugins},
	{"GET", PluginAssets},
	{"GET", PluginView},
	{"POST", PluginView},
	{"POST", PluginAction},
	{"POST", PluginRun},
	{"GET", ViewsPath},
	{"GET", TasksPath},
	{"POST", TasksPath},
	{"GET", TaskDetail},
	{"POST", TaskVerb},
	{"GET", TimelinePath},
	{"GET", RunsPath},
	{"POST", ChatPath},
	{"POST", AttachPath},
	{"GET", GatesPath},
	{"POST", GatePath},
	{"POST", RunOpen},
	{"POST", RunEnter},
	{"GET", RunTranscript},
	{"GET", CountersPath},
	{"GET", Drafts},
	{"POST", Drafts},
	{"GET", DigestPath},
	{"GET", ReviewPath},
	{"POST", ReviewStepDone},

	{"POST", AgentTurnsStart},
	{"POST", AgentTurnsByHand},
	{"POST", AgentTurnsEnd},
	{"POST", AgentSessionsStart},
	{"POST", AgentSessionsStop},
	{"POST", AgentSessionsPrompt},
	{"GET", AgentAnswer},

	{"POST", AdminDryRunTurn},
	{"GET", AdminDoctor},
	{"GET", AdminTurn},
	{"POST", AdminProbe},
	{"POST", AdminGitAccess},
	{"GET", AdminTimings},
	{"GET", AdminFacts},
	{"GET", AdminMeter},
}

Operations is every route the daemon serves, UserAPI, AgentAPI and AdminAPI; the daemon routes each exactly once and no other.

Functions

func BucketOf

func BucketOf(buckets []Bucket, now, t time.Time) string

Bucket is the id of the first bucket whose Within is above now - t, the one with Within "" catching the rest; "" when no bucket takes t.

func BuiltinWhy added in v0.2.0

func BuiltinWhy(id string) string

BuiltinWhy is the refusal code of a built-in action disabled by its actions.toml why: "<id>.why".

func CompareUnits

func CompareUnits(a, b unit.Unit) int

CompareUnits orders units by provider, then key.

func Fold added in v0.2.0

func Fold(s string) string

Fold lowers s and drops its accents, a decomposed "é" (e and U+0301) included, the way the filters compare text.

func Major

func Major(v string) string

Major is the major of a version, "0" for a missing one.

func NotificationID

func NotificationID(cat Category, task string, token string) string

NotificationID is "<category>|<task-id>|<token>".

func PluginActionPath added in v0.3.0

func PluginActionPath(id, action string) string

PluginActionPath is the path of plugin id's action.

func PluginCan added in v0.2.0

func PluginCan(ps []Plugin, id unit.ProviderID, c string) bool

PluginCan says whether the plugin of provider id is enabled and serves capability c.

func PluginRunPath added in v0.3.0

func PluginRunPath(id string) string

PluginRunPath is the path of plugin id's command lines.

func PluginViewPath added in v0.3.0

func PluginViewPath(id unit.ProviderID, view string) string

PluginViewPath is the route of plugin id's view.

func Refuse added in v0.3.0

func Refuse(status int, format string, args ...any) error

Refuse is the refusal msg answered with status.

func RefuseCase added in v0.2.0

func RefuseCase(i int) string

RefuseCase is the refusal code of an intent's action disabled by its [[action.refuse]] case i: "action.refuse[<i>]".

func RefuseCaseIndex added in v0.2.0

func RefuseCaseIndex(code string) (int, bool)

RefuseCaseIndex is the case a RefuseCase code names.

func ReviewStepPath

func ReviewStepPath(step string) string

ReviewStepPath is the path that marks step done.

func SessionHandle

func SessionHandle(v string) (string, error)

SessionHandle validates the value of SessionHeader.

func TaskMatches added in v0.3.0

func TaskMatches(e TaskView, terms []string) bool

TaskMatches says whether every term is in one of e's Texts, ignoring case and accents.

func TaskPath added in v0.3.0

func TaskPath(id string, rest ...string) string

TaskPath is the path of task id, followed by the segments of rest.

func UnitPath

func UnitPath(u unit.Unit, rest ...string) string

UnitPath is the path of u's detail, followed by the segments of rest.

Types

type ActionRequest

type ActionRequest struct {
	Until      string `json:"until"`
	UntilState bool   `json:"until_state"`
	Guidance   string `json:"guidance"`
	AgentHome  string `json:"agent_home,omitempty"`
	Force      bool   `json:"force,omitempty"`
	// Basis is the action state's basis the client saw; the daemon refuses
	// the action when the row no longer rests on it.
	Basis string `json:"basis,omitempty"`
	// Inputs are the intent's declared inputs, by name.
	Inputs map[string]any `json:"inputs,omitempty"`
	// OptionID, Yes, No and Source answer a question; Guidance is the
	// answer's text, a note to an option, yes or no. Source is cockpit,
	// notification, tui or terminal.
	OptionID string `json:"option_id,omitempty"`
	Yes      bool   `json:"yes,omitempty"`
	No       bool   `json:"no,omitempty"`
	Source   string `json:"source,omitempty"`
	// NoBrief starts a review, address or run without waiting for the
	// brief.
	NoBrief bool `json:"no_brief,omitempty"`
	// Items and Task tie what the action's turn drafts to the item ids of the unit and the task it
	// was asked from.
	Items []string `json:"items,omitempty"`
	Task  string   `json:"task,omitempty"`
	// Manager is the workspace manager that creates the turn's worktree, ""
	// for the configured ones; Parent is the caller's worktree, the new
	// one's parent where its manager keeps parents.
	Manager string `json:"manager,omitempty"`
	Parent  string `json:"parent,omitempty"`
}

type ActionResult

type ActionResult struct {
	OK     bool     `json:"ok"`
	Output []string `json:"output,omitempty"`
	Intake *Intake  `json:"intake,omitempty"`
	// Seq is the turn an intent started headless, answered 202; 0 otherwise.
	Seq int64 `json:"seq,omitempty"`
}

type ActionSpec

type ActionSpec struct {
	ID       string     `json:"id"`
	Label    string     `json:"label"`
	Summary  string     `json:"summary,omitempty"` // what pressing it does, from the profile
	Group    string     `json:"group"`             // start | turn | control | workspace | brief | intake; draft and plan for theirs
	Key      string     `json:"key,omitempty"`     // TUI key
	Surfaces []string   `json:"surfaces"`          // row, detail, tui, menubar, notification, cli, explore
	Input    *InputSpec `json:"input,omitempty"`
	Intake   bool       `json:"intake,omitempty"`
	Toggle   string     `json:"toggle,omitempty"` // paired id sharing the key: hold<->release
	Source   string     `json:"source"`           // "builtin" or the manifest path
	Scope    string     `json:"scope,omitempty"`  // "unit" (default), "item", "draft" or "run"
	Verb     string     `json:"verb,omitempty"`   // task verb it fulfills: "next", "waiting", "delegate", "done", "dismiss", "approve", "snooze"; scope draft also "edit", "retry"
	Plugin   string     `json:"plugin,omitempty"` // provider id, from the intent's Def.Provider; "" is core
}

ActionSpec is an action the daemon may offer on a row, as GET /api/actions serves it.

type ActionState

type ActionState struct {
	ID      string `json:"id"`
	Enabled bool   `json:"enabled"`
	// Reason is why a disabled action is off: the profile's why.
	Reason string `json:"reason,omitempty"`
	// Refusal names the profile text Reason is, which a client recognizes
	// a refusal by: BuiltinWhy or RefuseCase; "" for another reason.
	Refusal string `json:"refusal,omitempty"`
	// Note is what an enabled action would do on this row.
	Note    string `json:"note,omitempty"`
	Label   string `json:"label,omitempty"`
	Primary bool   `json:"primary,omitempty"`
	Confirm string `json:"confirm,omitempty"`
	Basis   string `json:"basis,omitempty"`
	// Warning is shown under an enabled action.
	Warning string `json:"warning,omitempty"`
	// Intent is the intent an intake action runs as when it is not the
	// action's own, such as run_now's on a held round; "" when none resolves.
	Intent string `json:"intent,omitempty"`
}

ActionState is one action as offered on a row now.

type ActionsResponse

type ActionsResponse struct {
	Version string       `json:"version"`
	Specs   []ActionSpec `json:"specs"`
	// Plan are the actions a plan item may offer.
	Plan []ActionSpec `json:"plan"`
}

ActionsResponse is the answer of GET /api/actions; a row's specs_version names the Version its actions follow.

type ActivityItem

type ActivityItem struct {
	Event Event `json:"event"`
	// Label is the event's unit as people read it; "" for none.
	Label  string `json:"label,omitempty"`
	Title  string `json:"title"`
	URL    string `json:"url"`
	Author string `json:"author"`
	State  string `json:"state"`
	Mine   bool   `json:"mine"`
}

type AppStatus

type AppStatus struct {
	State         string `json:"state"`
	Notifications string `json:"notifications"`
}

AppStatus is what the menu bar app reports about itself.

type AskView added in v0.3.0

type AskView struct {
	Item      string   `json:"item"`
	Summary   string   `json:"summary"`
	Asker     string   `json:"asker,omitempty"`
	Permalink string   `json:"permalink,omitempty"`
	Quotes    []string `json:"quotes,omitempty"`
}

AskView is an item a task serves, as its asker put it, with the source messages it quotes.

type AttachRequest added in v0.3.0

type AttachRequest struct {
	Cwd          string `json:"cwd"`
	Pane         string `json:"pane,omitempty"`
	AgentSession string `json:"agent_session,omitempty"`
	Home         string `json:"home,omitempty"`
	Agent        string `json:"agent,omitempty"`
}

AttachRequest is what AttachPath reads of the calling session's environment besides SessionHeader: its directory, pane, agent session, agent home and agent.

type Attention

type Attention struct {
	ID       string            `json:"id"`
	Category string            `json:"category"`
	Title    string            `json:"title"`
	Subtitle string            `json:"subtitle"`
	Body     string            `json:"body"`
	Image    string            `json:"image,omitempty"`
	Actions  []AttentionAction `json:"actions"`
}

Attention is a notification as the daemon decides it; ID is stable for as long as what it notifies lasts.

type AttentionAction

type AttentionAction struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	TextInput bool   `json:"text_input,omitempty"`
	// Placeholder and Button word a text input: the hint in its field and the button that sends it.
	Placeholder string `json:"placeholder,omitempty"`
	Button      string `json:"button,omitempty"`
	// Basis is the row state's basis the action was offered on.
	Basis string `json:"basis,omitempty"`
}

type Brief

type Brief struct {
	Goal          string   `json:"goal"`
	Context       string   `json:"context"`
	Kind          string   `json:"kind"`
	Size          string   `json:"size"`
	Risk          string   `json:"risk"`
	RiskWhy       string   `json:"risk_why"`
	OpenQuestions []string `json:"open_questions"`
	Tags          []string `json:"tags,omitempty"`
	// Extra are the brief intent's extra fields, by name; ExtraVersions the
	// version of each the brief holds.
	Extra         map[string]any    `json:"extra,omitempty"`
	ExtraVersions map[string]string `json:"extra_versions,omitempty"`
}

type BriefStatus

type BriefStatus struct {
	Ready       int       `json:"ready"`
	Pending     int       `json:"pending"`
	Failed      int       `json:"failed"`
	LastError   string    `json:"last_error,omitempty"`
	PausedUntil time.Time `json:"paused_until,omitzero"`
}

type BriefSummary

type BriefSummary struct {
	Kind          string   `json:"kind"`
	Size          string   `json:"size"`
	Risk          string   `json:"risk"`
	Goal          string   `json:"goal"`
	OpenQuestions int      `json:"open_questions"`
	Tags          []string `json:"tags,omitempty"`
	// Extra are the brief intent's extra fields, by name.
	Extra map[string]any `json:"extra,omitempty"`
}

type BriefTimings

type BriefTimings struct {
	Call   Quantiles `json:"call"`
	Failed int       `json:"failed"`
	// Reused counts the runs that carried the brief in use over.
	Reused  int     `json:"reused"`
	CostUSD float64 `json:"cost_usd"`
	Outages int     `json:"outages"`
	// Unrecorded counts the runs started before recording began, which the
	// figures leave out.
	Unrecorded int `json:"unrecorded"`
}

BriefTimings are the brief runs of the window: the call time of the ok ones, the failed and the reused ones, their cost and the breaker's openings.

type BriefView

type BriefView struct {
	State string    `json:"state"`
	Brief *Brief    `json:"brief,omitempty"`
	Model string    `json:"model,omitempty"`
	At    time.Time `json:"at,omitzero"`
	Error string    `json:"error,omitempty"`
	// Stale marks a brief that is due again: the pull request moved on.
	Stale bool `json:"stale"`
}

type BriefsHealth

type BriefsHealth struct {
	Unavailable string    `json:"unavailable,omitempty"`
	Open        bool      `json:"open"`
	Since       time.Time `json:"since,omitzero"`
	Error       string    `json:"error,omitempty"`
	Next        time.Time `json:"next,omitzero"`
}

BriefsHealth is the brief breaker: Open while briefs are unavailable, since Since for Error, with the next trial at Next. Unavailable says why the daemon runs no brief at all while brief.enabled is set.

type Bucket

type Bucket struct {
	ID     string `json:"id"` // the value the lens groups and filters by ("today", "week", "due")
	Label  string `json:"label"`
	Within string `json:"within"` // Go duration; the first bucket whose Within covers now - value wins; "" catches the rest
}

type ByHandRequest

type ByHandRequest struct {
	Intent string `json:"intent"`
	URL    string `json:"url,omitempty"`
	// Inputs are the intent's declared inputs, by name.
	Inputs       map[string]any `json:"inputs,omitempty"`
	Agent        string         `json:"agent,omitempty"`
	Guidance     string         `json:"guidance,omitempty"`
	Cwd          string         `json:"cwd"`
	Pane         string         `json:"pane,omitempty"`
	AgentSession string         `json:"agent_session,omitempty"`
	Home         string         `json:"home,omitempty"`
}

ByHandRequest is a turn the user starts by hand from the session that calls, described by that session's environment.

type ByHandResult

type ByHandResult struct {
	Text string `json:"text"`
	// Notes are what the loop did around the turn, for the caller's standard
	// error.
	Notes []string `json:"notes,omitempty"`
}

type Candidate

type Candidate struct {
	Unit           unit.Unit `json:"unit"`
	Label          string    `json:"label"`
	URL            string    `json:"url"`
	Title          string    `json:"title"`
	Author         string    `json:"author"`
	State          string    `json:"state"`
	IsDraft        bool      `json:"draft"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Additions      int       `json:"additions"`
	Deletions      int       `json:"deletions"`
	ChangedFiles   int       `json:"changed_files"`
	HeadBranch     string    `json:"head"`
	BaseBranch     string    `json:"base"`
	ReviewDecision string    `json:"review_decision"`
	ReviewRequests []string  `json:"review_requests"` // logins and team:org/slug
	ChecksState    string    `json:"checks"`
	Comments       int       `json:"comments"`
	// MyReview is the viewer's latest review state, "" when none.
	MyReview       string     `json:"my_review"`
	MyReviewOnHead bool       `json:"my_review_on_head"`
	Brief          *BriefView `json:"brief,omitempty"`
	// Actions are what the pull request offers now, as its row would.
	Actions []ActionState `json:"actions"`
}

Candidate is a pull request Explore found, with what deciding whether to help on it needs.

type CardView

type CardView = card.Snapshot

CardView is a unit's stored card on a task's detail.

type CatalogResponse

type CatalogResponse struct {
	Version    string          `json:"version"` // changes when any list changes; rows do not carry it
	Views      []ViewSpec      `json:"views"`
	Facets     []FacetSpec     `json:"facets"`
	Situations []SituationSpec `json:"situations"`
	// Events are the words of the plugins' event kinds.
	Events []EventSpec `json:"events,omitempty"`
	// Details are the words of the fields of the plugins' unit details.
	Details []DetailSpec `json:"details,omitempty"`
}

func (CatalogResponse) KindLabel

func (c CatalogResponse) KindLabel(r Row) string

KindLabel is the label of a row's kind, the kind itself when the catalog has none.

func (CatalogResponse) Situation

func (c CatalogResponse) Situation(provider string, k Kind) (SituationSpec, bool)

Situation is the spec of a provider's kind; ok is false for an unknown one.

func (CatalogResponse) ViewsOn

func (c CatalogResponse) ViewsOn(surface string) []ViewSpec

ViewsOn are the views a surface shows, in order.

type Category

type Category string

Category is the first part of a notification id: Q<record-id>, INBOX, OUTBOX, HELD, DIGEST or NOTE.

const (
	CategoryInbox  Category = "INBOX"
	CategoryOutbox Category = "OUTBOX"
	// CategoryHeld's token is the local day, so it is posted once a day.
	CategoryHeld Category = "HELD"
	// CategoryDigest's task is "-" and its token the day.
	CategoryDigest Category = "DIGEST"
	CategoryNote   Category = "NOTE"
)

func ParseNotificationID

func ParseNotificationID(id string) (cat Category, task string, ok bool)

ParseNotificationID reads an id NotificationID wrote.

func QuestionCategory

func QuestionCategory(record int64) Category

QuestionCategory is the category of the question of turn record record.

func (Category) Record

func (c Category) Record() (int64, bool)

Record is the turn record a question category names; ok is false for any other category.

type Change

type Change struct {
	Type    string      `json:"type"` // "changed" or "notify"
	Epoch   string      `json:"epoch"`
	Rev     uint64      `json:"rev"`
	Units   []unit.Unit `json:"units,omitempty"`
	All     bool        `json:"all,omitempty"`
	Health  bool        `json:"health,omitempty"`
	Notices []Notice    `json:"notices,omitempty"`
	// Counters are the Area "" counters, on every "changed" change after a TopicTasks or TopicDrafts note.
	Counters *Counters `json:"counters,omitempty"`
}

Change says the rows moved: the units whose row changed or left since the previous change, or All when too much moved to list. A "notify" change carries the notices a workflow raised for the user.

func (*Change) Merge

func (into *Change) Merge(c Change)

Merge folds c into the change, which then says what both said; a change of another epoch makes it All.

type ChangeFailure

type ChangeFailure struct {
	Merged  int `json:"merged"`
	Briefed int `json:"briefed"`
	Failed  int `json:"failed"`
	Tagged  int `json:"tagged"`
	// Recent counts the briefed merges younger than Days, left out of
	// Briefed until a fix had the time to come.
	Recent     int    `json:"recent"`
	Days       int    `json:"days"`
	Definition string `json:"definition"`
}

ChangeFailure is the share of the window's merges a later fix or revert changed again: Failed of Briefed, the merges at least Days old whose brief listed their changed files; Recent are younger ones, left out. Tagged counts the merges whose own brief tags them change:fix or change:revert.

type ChatRequest added in v0.3.0

type ChatRequest struct {
	Text   string `json:"text"`
	Intent string `json:"intent,omitempty"`
}

ChatRequest is a message to a task's agent; Intent picks the intent of the turn it starts when no session is live, the profile's chat intent when "".

type CheckDetail

type CheckDetail struct {
	Name    string   `json:"name"`
	URL     string   `json:"url,omitempty"`
	Summary string   `json:"summary,omitempty"`
	Steps   []string `json:"steps,omitempty"`
}

type CheckFacts

type CheckFacts struct {
	State   string   `json:"state"`
	Failing []string `json:"failing,omitempty"`
}

type ClosedSession

type ClosedSession struct {
	Session string    `json:"session"`
	At      time.Time `json:"at"`
	Reason  string    `json:"reason"`
	Resume  string    `json:"resume,omitempty"`
}

ClosedSession is a session closed with the line that resumes it.

type Counters

type Counters struct {
	Area     string         `json:"area"`
	Views    map[string]int `json:"views"`
	Areas    map[string]int `json:"areas"`
	Contexts map[string]int `json:"contexts"`
	Badge    int            `json:"badge"`
}

type Detail

type Detail struct {
	Row    Row        `json:"row"`
	Events []Event    `json:"events"`
	Brief  *BriefView `json:"brief,omitempty"`
	// ProfileChain names the review profile layers a round here reads.
	ProfileChain string    `json:"profile_chain"`
	Turn         *TurnView `json:"turn,omitempty"`
	// Card and Items are the unit card's (#unit-card).
	Card  *card.Snapshot `json:"card,omitempty"`
	Items []items.Item   `json:"items"`
}

type DetailSpec added in v0.3.0

type DetailSpec struct {
	Provider string `json:"provider"`
	Field    string `json:"field"`
	Label    string `json:"label"`
	Title    string `json:"title,omitempty"`
}

DetailSpec is how a field of a plugin's unit detail shows: the field of the detail, else of the row's payload override, that holds its value.

type Digest

type Digest struct {
	Day    string   `json:"day"`
	Title  string   `json:"title"`
	Body   string   `json:"body"`
	Counts Counters `json:"counts"`
	Tasks  []string `json:"tasks"`
}

type DoctorCheck

type DoctorCheck struct {
	Mark string `json:"mark"`
	Name string `json:"name"`
	Info string `json:"info,omitempty"`
	Fix  string `json:"fix,omitempty"`
}

DoctorCheck is one line of `doctor`; Fix is printed for a missing check.

type DoctorQuery

type DoctorQuery struct {
	Repo string `json:"repo,omitempty"`
	PR   string `json:"pr,omitempty"`
}

DoctorQuery narrows the state `profile show` reads to one repository or, with PR, one pull request.

type DoctorReport

type DoctorReport struct {
	Checks []DoctorCheck `json:"checks"`
	// BundledChanged are the intents whose bundled guide changed since the
	// queried repository's last round.
	BundledChanged []string `json:"bundled_changed,omitempty"`
	// Reconcile is the start-up reconcile's report; nil while it runs.
	Reconcile *ReconcileReport `json:"reconcile,omitempty"`
	// Workflows are the checks of the workflows the daemon runs.
	Workflows []DoctorCheck `json:"workflows,omitempty"`
}

DoctorReport is doctor's checks that read the loop's state.

type Draft

type Draft struct {
	ID    int64    `json:"id"`
	Unit  string   `json:"unit"` // "<provider>/<key>"
	Items []string `json:"items"`
	Task  string   `json:"task,omitempty"`
	Kind  string   `json:"kind"`
	// Purpose is what the draft is for, Delivery how it is posted (message,
	// reaction or comment) and Effects what posting it applies.
	Purpose  string   `json:"purpose"`
	Delivery string   `json:"delivery"`
	Effects  []string `json:"effects"`
	Target   string   `json:"target"`
	// Where names the conversation or person the draft posts to; "" when its publisher could not tell.
	Where    string `json:"where"`
	Text     string `json:"text"`
	Reaction string `json:"reaction"`
	Original string `json:"original"`
	// Replaced is the text a sent edit replaced.
	Replaced string      `json:"replaced,omitempty"`
	Edited   bool        `json:"edited"`
	Origin   DraftOrigin `json:"origin"`
	// State is where its delivery stands: held while its gate is open, queued, sending, sent, failed or dropped.
	State     string `json:"state"`
	Error     string `json:"error"`
	Reason    string `json:"reason"`
	Permalink string `json:"permalink"`
	// Gate is the draft's gate, 0 for none; Deadline is when its window resolves it, nil for none; Intents are
	// its open gate's intents by the status each resolves it to (approved, rejected), the first of each.
	Gate     int64             `json:"gate,omitempty"`
	Deadline *time.Time        `json:"deadline"`
	Intents  map[string]string `json:"intents,omitempty"`
	// Actions are the draft actions of the catalog as they stand on the draft: its delivery's, edit and retry.
	Actions []ActionState `json:"actions"`
	// Rev is the stored draft's version; approve and retry send the one they showed.
	Rev       int64     `json:"rev"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	// Label, Title and Link present the unit as its row does; with no row, Label is the unit's own.
	Label string `json:"label,omitempty"`
	Title string `json:"title,omitempty"`
	Link  string `json:"link,omitempty"`
	// Names are the display names of the people Text mentions, by mention key ("slack:U0123"), as the
	// unit's items know them; the draft routes fill them and the item details, the Outbox tasks do not.
	Names map[string]string `json:"names,omitempty"`
	// ItemDetails are the items the draft is about, with their summaries.
	ItemDetails []ItemView `json:"item_details,omitempty"`
}

type DraftCreate

type DraftCreate struct {
	Unit     unit.Unit `json:"unit"`
	Task     string    `json:"task,omitempty"`
	Items    []string  `json:"items,omitempty"`
	Kind     string    `json:"kind,omitempty"`
	Text     string    `json:"text,omitempty"`
	Reaction string    `json:"reaction,omitempty"`
	// Target is the message a reply answers or a reaction goes on, when it is
	// not the unit's own.
	Target string `json:"target,omitempty"`
	Send   bool   `json:"send,omitempty"`
	Source string `json:"source"`
}

DraftCreate is a draft the user writes on Unit, for Task and its Items when set: Kind DraftReply with Text, or DraftReact with Reaction. It waits in the Outbox for approval, unless Send approves it at once to go out through the same publisher. Source is cockpit, notification, tui or terminal.

type DraftOrigin

type DraftOrigin struct {
	Kind     string `json:"kind"`
	TurnSeq  int64  `json:"turn_seq"`
	Intent   string `json:"intent"`
	Workflow string `json:"workflow"`
	Rule     string `json:"rule"`
	// Unit is the label of the proposing turn's unit when it is not the
	// draft's, "" when it is.
	Unit string `json:"unit,omitempty"`
}

type DraftsResponse

type DraftsResponse struct {
	Drafts []Draft `json:"drafts"`
}

type DryRunTurn

type DryRunTurn struct {
	ID     string `json:"id"`
	Prompt string `json:"prompt"`
	// Why is the why section the instructions rendered; empty without one.
	Why string `json:"why,omitempty"`
}

DryRunTurn is the stored dry-run turn the command line runs the agent on.

type DryRunTurnRequest

type DryRunTurnRequest struct {
	PR  string        `json:"pr"`
	Why *workflow.Why `json:"why,omitempty"`
}

DryRunTurnRequest asks for the review turn of a `profile try`.

type Event

type Event struct {
	Unit  unit.Unit `json:"unit"`
	Kind  string    `json:"kind"`
	Key   string    `json:"key"`
	Actor string    `json:"actor"`
	At    time.Time `json:"at"`
	Data  string    `json:"data"`
}

type EventSpec added in v0.3.0

type EventSpec struct {
	Provider string `json:"provider"`
	Kind     string `json:"kind"`
	Label    string `json:"label"`
	Loop     bool   `json:"loop,omitempty"`
	// Data is how its data shows: "" as it is, "none", "first_field",
	// "short_sha" or "requested".
	Data string `json:"data,omitempty"`
}

EventSpec is how a plugin's event kind shows on a timeline; Loop says it is the loop's doing.

type ExploreRequest

type ExploreRequest struct {
	Query string `json:"query"`
}

type ExploreResult

type ExploreResult struct {
	Query      string      `json:"query"` // what GitHub was asked
	Read       string      `json:"read"`  // how the input was read
	Empty      string      `json:"empty,omitempty"`
	Total      int         `json:"total"`
	Candidates []Candidate `json:"candidates"`
	Cost       int         `json:"cost"`
	RateLimit  RateLimit   `json:"rate_limit"`
	Recent     []string    `json:"recent"`
}

type Facet

type Facet struct {
	ID     string   `json:"id"`
	Label  string   `json:"label"`
	Field  string   `json:"field"`
	Values []string `json:"values,omitempty"`
}

Facet: Field is "row.*", "item.*" or "<provider>.*".

type FacetSpec

type FacetSpec struct {
	ID       string            `json:"id"` // "repo", "author", "kind", ...
	Label    string            `json:"label"`
	Provider string            `json:"provider"` // "" applies to every row
	Group    bool              `json:"group"`
	Sort     string            `json:"sort,omitempty"` // "", "rank", "text", "time" (RFC 3339 values)
	Rank     []string          `json:"rank,omitempty"`
	Labels   map[string]string `json:"labels,omitempty"` // value -> shown text
	Empty    string            `json:"empty,omitempty"`
	Match    string            `json:"match,omitempty"` // "exact" (default), "suffix" (repo), "prefix" (tag), "team"
	Menu     bool              `json:"menu"`
	Buckets  []Bucket          `json:"buckets,omitempty"` // Sort "time" only: the client buckets now - value
	// Strip says each row's strip is colored by the facet's first value,
	// its rank the strip's legend.
	Strip bool `json:"strip,omitempty"`
}

type Fact

type Fact struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Facts

type Facts struct {
	Owner       string   `json:"owner"`
	Repo        string   `json:"repo"`
	Author      string   `json:"author"`
	Association string   `json:"association"`
	Base        string   `json:"base"`
	Teams       []string `json:"teams,omitempty"`
	Labels      []string `json:"labels,omitempty"`
	Kind        string   `json:"kind,omitempty"`
	Size        string   `json:"size,omitempty"`
	Risk        string   `json:"risk,omitempty"`
	Goal        string   `json:"goal,omitempty"`
	Context     string   `json:"context,omitempty"`
	RiskWhy     string   `json:"risk_why,omitempty"`
	Tags        []string `json:"tags,omitempty"`
	Files       []string `json:"files,omitempty"`
	HasBrief    bool     `json:"has_brief"`
}

Facts are what a pull request's guide is matched against: GitHub's read, the requested teams and, with a brief, its kind, size, risk, tags and files, with the goal, context and risk reason its turn text shows.

type Gain

type Gain struct {
	MemoryBytes int64 `json:"memory_bytes"`
	DiskBytes   int64 `json:"disk_bytes"`
}

type GateView added in v0.3.0

type GateView struct {
	ID       int64           `json:"id"`
	Task     string          `json:"task,omitempty"`
	Unit     string          `json:"unit,omitempty"`
	Kind     string          `json:"kind"`
	Name     string          `json:"name,omitempty"`
	Status   string          `json:"status"`
	Text     string          `json:"text,omitempty"`
	Intents  []IntentView    `json:"intents"`
	Deadline time.Time       `json:"deadline,omitzero"`
	Default  string          `json:"default,omitempty"`
	Delivery string          `json:"delivery,omitempty"`
	Subject  json.RawMessage `json:"subject,omitempty"`
}

GateView is a gate as clients offer it: Task and Unit what it is on ("" when none), Text its words from gates.toml, Intents what a person may resolve it with, in order, Default the intent its Deadline resolves it with, Delivery a draft gate's delivery state (held, queued, sending, sent, failed, dropped), Subject its subject as its kind serves it: a draft gate's is its Draft.

func DraftGate added in v0.3.0

func DraftGate(d Draft) GateView

DraftGate is d as the gate it waits on serves it: its subject d, its delivery d's state.

type GitAccess

type GitAccess struct {
	Host   string            `json:"host"`
	Last   GitAccessOutcome  `json:"last"`
	LastOK *GitAccessOutcome `json:"last_ok,omitempty"`
}

GitAccess is the latest git network operation the daemon ran against a host and its latest success; LastOK is nil when none succeeded yet.

type GitAccessOutcome

type GitAccessOutcome struct {
	At    time.Time `json:"at"`
	Op    string    `json:"op"`
	Error string    `json:"error,omitempty"`
}

GitAccessOutcome is one git network operation: when, which (such as "fetch of acme/widget#7") and its error, "" when it succeeded.

type GitAccessRecord

type GitAccessRecord struct {
	Host string `json:"host"`
	GitAccessOutcome
}

GitAccessRecord is an outcome another process saw against Host, such as doctor --git's ls-remote, for the daemon to keep with its own.

type Health

type Health struct {
	Version string `json:"version"`
	// Build names the cockpit the daemon serves; a page that loaded another
	// reloads.
	Build     string       `json:"build"`
	Jobs      []JobStatus  `json:"jobs"`
	Warnings  []string     `json:"warnings"`
	RateLimit RateLimit    `json:"rate_limit"`
	SlowSync  bool         `json:"slow_sync"`
	Viewer    string       `json:"viewer"`
	Paused    bool         `json:"paused"`
	PausedAt  time.Time    `json:"paused_at,omitzero"`
	App       *AppStatus   `json:"app,omitempty"`
	Brief     *BriefStatus `json:"brief,omitempty"`
	// Briefs is the brief breaker; nil when briefs are off.
	Briefs *BriefsHealth `json:"briefs,omitempty"`
	// Notifier is whether the menu bar follows the daemon's events.
	Notifier bool `json:"notifier"`
	// StalledReviewHours is stalled.review, for a client that judges a pull
	// request the inventory does not hold.
	StalledReviewHours float64 `json:"stalled_review_hours"`
	// WorkspaceManagers name the workspace managers the daemon runs on, in
	// their configured order, such as "Claude Desktop" and "Orca".
	WorkspaceManagers []string `json:"workspace_managers,omitempty"`
	// GitAccess is, per remote host, how the daemon's own git network
	// operations went, sorted by host.
	GitAccess []GitAccess `json:"git_access,omitempty"`
	// Store is the store's schema version and state; nil from a daemon that
	// predates it.
	Store *StoreStatus `json:"store,omitempty"`
	// Plugins are the plugins the daemon runs, by id, and how each answers.
	Plugins []PluginHealth `json:"plugins,omitempty"`
}

type HomeFinding

type HomeFinding struct {
	Home    string `json:"home"`
	Entry   string `json:"entry"`
	Problem string `json:"problem"`
	Fix     string `json:"fix,omitempty"`
}

HomeFinding is one entry an agent home lacks or holds wrong; Fix is the command that repairs it, "" when none does.

func (HomeFinding) Warning

func (f HomeFinding) Warning() string

Warning is the finding as a line of Health.Warnings.

type Info

type Info struct {
	Port  int    `json:"port"`
	Token string `json:"token"`
}

Info is the cockpit address the daemon writes for the command line.

type InputSpec

type InputSpec struct {
	Kind        string `json:"kind"` // text | duration | answer
	Required    bool   `json:"required,omitempty"`
	Label       string `json:"label,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`
	Default     string `json:"default,omitempty"`
	UntilState  bool   `json:"until_state,omitempty"`
	Max         int    `json:"max,omitempty"`
}

type Intake

type Intake struct {
	Seq       int64     `json:"seq"`
	PR        string    `json:"pr"`
	Intent    string    `json:"intent"`
	Source    string    `json:"source"`
	State     string    `json:"state"`
	Brief     string    `json:"brief,omitempty"`
	Note      string    `json:"note,omitempty"`
	Attempt   int       `json:"attempt,omitempty"`
	LastError string    `json:"last_error,omitempty"`
	Next      time.Time `json:"next,omitzero"`
	Error     string    `json:"error,omitempty"`
	Joined    bool      `json:"joined,omitempty"`
	Log       []string  `json:"log,omitempty"`
	LogLen    int       `json:"log_len"`
}

Intake is a turn a user asked for, waiting for its pull request's brief or started. Log holds the lines past the asked index and LogLen counts every line; Attempt and LastError are the brief attempt it waits on and the failure of the one before.

func (Intake) Open

func (i Intake) Open() bool

Open tells an intake that has not ended.

func (Intake) Waiting

func (i Intake) Waiting() bool

Waiting tells an intake that waits for the brief.

type IntentView added in v0.3.0

type IntentView struct {
	ID     string `json:"id"`
	Label  string `json:"label"`
	Answer bool   `json:"answer,omitempty"`
}

IntentView is an intent a gate offers; Answer says it takes text, as a question's answer.

type ItemApplied

type ItemApplied struct {
	Op      items.Op   `json:"op"`
	Item    items.Item `json:"item"`
	Changed bool       `json:"changed"`
}

type ItemProposal

type ItemProposal struct {
	ID         int64            `json:"id"`
	Unit       unit.Unit        `json:"unit"`
	Item       string           `json:"item"`
	Op         items.Op         `json:"op"`
	Provenance items.Provenance `json:"provenance"`
	Reason     string           `json:"reason"`
	State      string           `json:"state"`
	At         time.Time        `json:"at"`
}

type ItemRefused

type ItemRefused struct {
	Index  int      `json:"index"` // position in the ops passed
	Op     items.Op `json:"op"`
	Reason string   `json:"reason"`
}

type ItemView

type ItemView struct {
	Unit    unit.Unit `json:"unit"`
	ID      string    `json:"id"`
	Summary string    `json:"summary"`
	State   string    `json:"state"`
	Kind    string    `json:"kind"`
}

type ItemsResult

type ItemsResult struct {
	Applied  []ItemApplied  `json:"applied"`
	Proposed []ItemProposal `json:"proposed"`
	Refused  []ItemRefused  `json:"refused"`
}

ItemsResult is what the items ledger did with a turn record's ops.

type JobStatus

type JobStatus struct {
	Name    string        `json:"name"`
	Every   time.Duration `json:"every"`
	LastRun time.Time     `json:"last_run"`
	LastOK  time.Time     `json:"last_ok"`
	LastErr string        `json:"last_error"`
	Running bool          `json:"running"`
}

type Kept

type Kept struct {
	Named
	Reason    string `json:"reason"`
	Detail    string `json:"detail,omitempty"`
	Source    string `json:"source,omitempty"`
	Forceable bool   `json:"forceable,omitempty"`
}

type KeyBinding

type KeyBinding struct {
	Key     string `json:"key"`
	Action  string `json:"action"`
	Surface string `json:"surface,omitempty"`
}

KeyBinding: Surface is web, tui or menubar.

type KeyView

type KeyView struct {
	Key     string `json:"key"`
	Action  string `json:"action"`
	Context string `json:"context"`
	Owner   string `json:"owner"`
	Help    string `json:"help"`
	// Summary is what an action's key does, from its spec or, for a core
	// verb's key, the verb's summary; "" for any other core key.
	Summary string `json:"summary,omitempty"`
}

KeyView is one key of a surface. Owner is "core", a plugin id or "intent:<name>"; Action is a core action or an action spec's id.

type KeysResponse

type KeysResponse struct {
	Bindings []KeyView `json:"bindings"`
}

KeysResponse is the answer of GET /api/keys: the core bindings of the surface, then every served action key.

type Kind

type Kind string

Kind is a row's provider-scoped situation; its labels come from CatalogResponse.Situations.

type Load

type Load struct {
	Since time.Time   `json:"since"`
	Stats []MeterStat `json:"stats"`
	// CLIOps are the workspace manager's operations that spawned its CLI,
	// per op.
	CLIOps []MeterStat `json:"cli_ops,omitempty"`
	// Fallbacks is how many calls went to the CLI because the manager's
	// runtime drifted; nil when the manager does not count them.
	Fallbacks *int64 `json:"fallbacks,omitempty"`
}

Load is the daemon's cost since Since, per resource (Op is empty).

type Loading added in v0.3.0

type Loading struct {
	Plugin string `json:"plugin"`
	Reason string `json:"reason"`
}

Loading is a plugin that has not yet imported its data and reported every unit since the daemon started, and why, in the plugin's words.

type MenubarSection struct {
	Label string `json:"label"`
	View  string `json:"view"`
}

type Message

type Message struct {
	ID        int64           `json:"id"`
	Unit      unit.Unit       `json:"unit"`
	Kind      string          `json:"kind"`
	Text      string          `json:"text"`
	Options   []record.Option `json:"options,omitempty"`
	Recommend string          `json:"recommend,omitempty"`
	Confirm   bool            `json:"confirm,omitempty"`
	Origin    string          `json:"origin"`
	CreatedAt time.Time       `json:"created_at"`
	// Answers are the user's answers to the message, oldest first, each with when the agent read it.
	Answers []TurnAnswer `json:"answers,omitempty"`
}

Message is the subject of a question, post or proposal gate, as GateView.Subject serves it: what was asked, with the user's answers to it.

type MeterReport

type MeterReport struct {
	Since  time.Time    `json:"since"`
	At     time.Time    `json:"at"`
	Load   Load         `json:"load"`
	Scopes []MeterScope `json:"scopes"`
	Recent *MeterWindow `json:"recent,omitempty"`
}

MeterReport is every scope's metered cost since the daemon started, sorted by name, and the same for the last minutes in Recent.

type MeterScope

type MeterScope struct {
	Name     string      `json:"name"`
	Runs     int64       `json:"runs"`
	WallMS   int64       `json:"wall_ms"`
	Stats    []MeterStat `json:"stats"`
	Last     []MeterStat `json:"last,omitempty"`
	LastAt   time.Time   `json:"last_at,omitzero"`
	LastWall int64       `json:"last_wall_ms,omitempty"`
}

MeterScope is the cost of one scope since the daemon started. For a job or a loop that has phases, Stats holds the scope and its phases together and each phase is listed under its own "<scope>/<phase>" name with its own samples only.

type MeterStat

type MeterStat struct {
	Res         string `json:"res"`
	Op          string `json:"op,omitempty"`
	Calls       int64  `json:"calls"`
	Spawns      int64  `json:"spawns,omitempty"`
	Errors      int64  `json:"errors,omitempty"`
	NotModified int64  `json:"not_modified,omitempty"`
	Points      int64  `json:"points,omitempty"`
	Bytes       int64  `json:"bytes,omitempty"`
	Rows        int64  `json:"rows,omitempty"`
	DurMS       int64  `json:"dur_ms,omitempty"`
	MaxMS       int64  `json:"max_ms,omitempty"`
}

MeterStat is the metered cost of one resource, or of one operation of it when Op is set.

type MeterWindow

type MeterWindow struct {
	Since  time.Time    `json:"since"`
	Scopes []MeterScope `json:"scopes"`
}

MeterWindow is what each scope spent since Since, a recent minute, with MeterScope's roll-up of phases; Last and its fields are left out.

type Named added in v0.3.0

type Named struct {
	Unit  unit.Unit `json:"unit"`
	Label string    `json:"label"`
}

Named is a unit with its label.

type Notice

type Notice struct {
	ID       string    `json:"id"`
	Workflow string    `json:"workflow"`
	Unit     unit.Unit `json:"unit"`
	Label    string    `json:"label,omitempty"` // Unit as a person reads it
	Text     string    `json:"text"`
}

Notice is a notification a workflow's notify.self step raised; ID is unique per raise.

type Notification

type Notification struct {
	ID    string `json:"id"`
	On    string `json:"on"`
	Title string `json:"title"`
	Body  string `json:"body"`
}

Notification: On is "item:<kind>" or "row:<kind>"; Body a text/template over the row or item.

type ObserveMode added in v0.2.0

type ObserveMode bool

ObserveMode is a plan item's observe flag: its workflow only plans, and a person applies the item by hand.

type Operation

type Operation struct{ Method, Path string }

Operation is one route of the daemon's API.

func (Operation) Pattern

func (o Operation) Pattern() string

Pattern is the operation as a net/http ServeMux pattern.

type Override

type Override struct {
	Hold         bool   `json:"hold"`
	Adopted      bool   `json:"adopted"`
	Tracked      bool   `json:"tracked"`
	NextGuidance string `json:"next_guidance"`
}

Override is what the user set on a unit; the zero Override leaves the wire.

func (Override) IsZero

func (o Override) IsZero() bool

IsZero reports an override that sets nothing.

type PRTimes

type PRTimes struct {
	PR           string    `json:"pr"`
	Title        string    `json:"title,omitempty"`
	Author       string    `json:"author,omitempty"`
	Opened       time.Time `json:"opened,omitzero"`
	Followed     time.Time `json:"followed,omitzero"`
	FirstRequest time.Time `json:"first_request,omitzero"`
	FirstReview  time.Time `json:"first_review,omitzero"`
	Approved     time.Time `json:"approved,omitzero"`
	Merged       time.Time `json:"merged,omitzero"`
	Turns        int       `json:"turns"`
	Briefs       int       `json:"briefs"`
}

PRTimes are a pull request's milestones, zero when it has not reached one, with its turns and brief runs in the window.

type PauseRequest

type PauseRequest struct {
	Paused bool     `json:"paused"`
	Repos  []string `json:"repos,omitempty"` // owner/repo
	PRs    []string `json:"prs,omitempty"`   // owner/repo#n
}

PauseRequest pauses or resumes the repositories in Repos and the pull requests in PRs; naming neither pauses or resumes everything.

type PlanActRequest

type PlanActRequest struct {
	IDs      []string `json:"ids"`
	Action   string   `json:"action"`
	Guidance string   `json:"guidance,omitempty"`
}

type PlanItem

type PlanItem struct {
	ID       string        `json:"id"`
	Workflow string        `json:"workflow"`
	Decision string        `json:"decision"`
	Reason   string        `json:"reason,omitempty"`
	Default  string        `json:"default,omitempty"`
	Observe  ObserveMode   `json:"observe"`
	Error    string        `json:"error,omitempty"`
	Unit     unit.Unit     `json:"unit"`
	Label    string        `json:"label"`           // Unit as a person reads it
	Title    string        `json:"title,omitempty"` // Unit's row title
	Link     string        `json:"link,omitempty"`  // Unit's row link
	Steps    []string      `json:"steps"`
	Deadline time.Time     `json:"deadline,omitzero"`
	Gain     Gain          `json:"gain"`
	Why      Why           `json:"why"`
	Attempts int           `json:"attempts,omitempty"`
	Actions  []ActionState `json:"actions"` // built by internal/catalog only
}

PlanItem is one item of the workflows' plan.

func (PlanItem) UnitLabel added in v0.2.0

func (it PlanItem) UnitLabel() string

UnitLabel is the item's unit as a person reads it.

type PlanQuery

type PlanQuery struct {
	Workflow string `json:"workflow,omitempty"`
	Provider string `json:"provider,omitempty"`
	Trigger  string `json:"trigger,omitempty"`
	// Closed asks for the sessions closed in the last day with the stored
	// plan.
	Closed bool `json:"closed,omitempty"`
	// Unit, provider:key, asks what every workflow decides for that unit
	// now; the other fields are then ignored.
	Unit string `json:"unit,omitempty"`
}

type PlanResponse

type PlanResponse struct {
	Items  []PlanItem      `json:"items"`
	Errors []string        `json:"errors"`
	Closed []ClosedSession `json:"closed,omitempty"`
	// Unit is the unit a Unit query explained, as its provider lists it.
	Unit      string         `json:"unit,omitempty"`
	Label     string         `json:"label,omitempty"` // Unit as a person reads it
	Title     string         `json:"title,omitempty"` // Unit's row title
	Workflows []UnitWorkflow `json:"workflows,omitempty"`
}

type Plugin

type Plugin struct {
	ID      unit.ProviderID `json:"id"`
	Name    string          `json:"name"` // the service as a person reads it, such as "GitHub"
	Enabled bool            `json:"enabled"`
	// Reacts: the plugin's publisher posts reactions (drafts of kind react); only when enabled.
	Reacts bool      `json:"reacts,omitempty"`
	UI     *PluginUI `json:"ui,omitempty"` // only when enabled
	// Capabilities are what the plugin can do, so a client asks what a
	// provider does, never which it is: checkouts, briefs, publishes, reacts,
	// items; only when enabled.
	Capabilities []string `json:"capabilities,omitempty"`
}

func (Plugin) Can added in v0.2.0

func (p Plugin) Can(c string) bool

Can says whether the plugin is enabled and serves capability c.

type PluginActionArgs added in v0.3.0

type PluginActionArgs struct {
	Request ActionRequest  `json:"request"`
	Unmuted *Row           `json:"unmuted,omitempty"`
	Inputs  map[string]any `json:"inputs,omitempty"`
}

PluginActionArgs are the Args of an action the daemon sends a unit's plugin: the person's request, the unit's row without the user's mute and pending round, and, for an intent's prepare, the call's inputs so far.

type PluginActionRequest added in v0.3.0

type PluginActionRequest struct {
	Action string          `json:"-"`
	Actor  string          `json:"-"`
	Args   json.RawMessage `json:"args,omitempty"`
}

PluginActionRequest is an action of a plugin and its arguments, whose shape the plugin owns; the route sets Action, and Actor from the request's session header.

type PluginActionResult added in v0.3.0

type PluginActionResult struct {
	Output []string       `json:"output,omitempty"`
	Inputs map[string]any `json:"inputs,omitempty"`
}

PluginActionResult is what a plugin's Action answers the daemon: the lines it reports and, for a prepare, the call's inputs.

type PluginDetail added in v0.3.0

type PluginDetail struct {
	Events []Event    `json:"events"`
	Brief  *BriefView `json:"brief,omitempty"`
}

PluginDetail is what a unit's plugin adds to its detail: the timeline and the brief.

type PluginError added in v0.3.0

type PluginError struct {
	Status int
	Msg    string
}

PluginError is a plugin's refusal of a request, with the HTTP status the daemon answers it with.

func (*PluginError) Error added in v0.3.0

func (e *PluginError) Error() string

type PluginHealth added in v0.3.0

type PluginHealth struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Reason string `json:"reason,omitempty"`
}

PluginHealth is a plugin the daemon runs: its status, one of loading, serving, degraded or down, and why in the plugin's words.

type PluginRunChunk added in v0.3.0

type PluginRunChunk struct {
	Stdout string `json:"stdout,omitempty"`
	Stderr string `json:"stderr,omitempty"`
	Exit   *int   `json:"exit,omitempty"`
	Error  string `json:"error,omitempty"`
}

PluginRunChunk is one line of a plugin command's stream: what it wrote to its standard output or error, or how it ended.

type PluginRunRequest added in v0.3.0

type PluginRunRequest struct {
	Args []string `json:"args"`
}

PluginRunRequest is a command line of a plugin: the words after its id.

type PluginUI

type PluginUI struct {
	Facets        []Facet        `json:"facets,omitempty"`        // qualifiers over row and item facts
	Views         []SavedView    `json:"views,omitempty"`         // listed under the plugin in navigation
	Notifications []Notification `json:"notifications,omitempty"` // templates keyed by item kind or row kind
	Keys          []KeyBinding   `json:"keys,omitempty"`          // checked with keys.Check when the catalog loads
	// Key is the chord that jumps to the plugin's views, checked with
	// keys.CheckView; "" for none.
	Key     string           `json:"key,omitempty"`
	Web     *WebView         `json:"web,omitempty"` // tier c
	Menubar []MenubarSection `json:"menubar,omitempty"`
}

type ProbeRequest

type ProbeRequest struct {
	// WorkspaceID is the workspace's id in its manager, or its worktree path.
	WorkspaceID string `json:"workspace_id"`
	// Home and Model are the agent's; "" is its default.
	Home  string `json:"home,omitempty"`
	Model string `json:"model,omitempty"`
}

type ProbeResult

type ProbeResult struct {
	PR      string `json:"pr"`
	Turn    string `json:"turn"`
	Session string `json:"session"`
}

ProbeResult names the probe's pull request, the id of its turn and the session the turn was sent to.

type PromptRequest

type PromptRequest struct {
	Prompt string `json:"prompt"`
}

PromptRequest is the prompt the caller's session took.

type PropSpec added in v0.3.0

type PropSpec struct {
	Name    string   `json:"name"`
	Type    string   `json:"type"`
	Values  []string `json:"values,omitempty"`
	Writers []string `json:"writers,omitempty"`
	Role    string   `json:"role,omitempty"`
}

PropSpec is a task property of tasks.toml: its type, an enum's values, who may write it, and the role of the loop's that acts on it ("" for none): area, contexts, star or deadline.

type Quantiles

type Quantiles struct {
	Count int   `json:"count"`
	P50MS int64 `json:"p50_ms"`
	P90MS int64 `json:"p90_ms"`
}

Quantiles are a duration's nearest-rank median and 90th percentile over Count samples.

type QuestionView

type QuestionView struct {
	RecordID    int64           `json:"record_id"`
	State       string          `json:"state"`
	Kind        string          `json:"kind"`
	Text        string          `json:"text"`
	Options     []record.Option `json:"options,omitempty"`
	Recommend   string          `json:"recommend,omitempty"`
	Publishes   bool            `json:"publishes,omitempty"`
	Verdict     string          `json:"verdict,omitempty"`
	Blocking    int             `json:"blocking"`
	NonBlocking int             `json:"non_blocking"`
	LastMessage string          `json:"last_message,omitempty"`
}

QuestionView is a turn that waits on the user: asked, failed or unrecorded, with its last record's question and outcome.

type RateLimit

type RateLimit struct {
	Cost      int       `json:"cost"`
	Remaining int       `json:"remaining"`
	Limit     int       `json:"limit"`
	ResetAt   time.Time `json:"reset_at"`
}

type ReconcileReport

type ReconcileReport struct {
	// Unrecorded are the pull requests whose turn ended without a record.
	Unrecorded []unit.Unit `json:"unrecorded"`
	// Closed are the pull requests whose asked turn my review closed.
	Closed       []unit.Unit `json:"closed"`
	GoneSessions []string    `json:"gone_sessions"`
	// Rewritten counts the view items the sinks were brought back to.
	Rewritten int       `json:"rewritten"`
	At        time.Time `json:"at"`
}

ReconcileReport is what the daemon found and repaired when it started, before it served UserAPI.

type RecordView added in v0.3.0

type RecordView struct {
	Kind string          `json:"kind"`
	At   time.Time       `json:"at"`
	Data json.RawMessage `json:"data"`
}

RecordView is a record of a declared kind, such as a brief, with its data as its schema holds it.

type RemoveCleanRequest added in v0.3.0

type RemoveCleanRequest struct {
	View string `json:"view"`
}

RemoveCleanRequest names the view whose tasks' clean workspaces to remove.

type RemoveCleanResult added in v0.3.0

type RemoveCleanResult struct {
	Removed []Named `json:"removed"`
	Kept    []Kept  `json:"kept"`
}

type Resolved added in v0.3.0

type Resolved struct {
	Unit  unit.Unit `json:"unit"`
	Found bool      `json:"found"`
}

Resolved is the unit an address lands in; Found is false when no plugin reads the address.

type Review

type Review struct {
	ID        string       `json:"id"`
	Steps     []ReviewStep `json:"steps"`
	StartedAt time.Time    `json:"started_at"`
	Done      bool         `json:"done"`
}

Review is the Review. ID is empty when nothing was left to review as it started.

type ReviewStep

type ReviewStep struct {
	ID    string            `json:"id"`
	Label string            `json:"label"`
	View  string            `json:"view"`
	Query map[string]string `json:"query"`
	Count int               `json:"count"`
	Done  bool              `json:"done"`
}

ReviewStep is a step of the Review: the tasks of Query (GET /api/tasks with these parameters), their count, and whether the step is done. Step ids: inbox, outbox, waiting, projects, someday, focus.

type Row

type Row struct {
	Unit unit.Unit `json:"unit"`
	// Link and Label are the server's presentation of the unit, such as
	// its pull request's URL and "owner/repo#12".
	Link    string              `json:"link"`
	Label   string              `json:"label"`
	Title   string              `json:"title"`
	Kind    Kind                `json:"kind"`
	Summary Summary             `json:"summary"`
	Views   []string            `json:"views"`
	Facets  map[string][]string `json:"facets"` // facet id -> values; Values[0] is the group and sort key
	// Actions are what the row offers now, in the order of the specs.
	Actions []ActionState `json:"actions"`
	// SpecsVersion is the version of GET /api/actions the actions follow.
	SpecsVersion string `json:"specs_version"`
	// Question is the open question or stop of the turn the situation
	// comes from.
	Question *QuestionView   `json:"question,omitempty"`
	Items    []RowItem       `json:"items,omitempty"`
	Payload  json.RawMessage `json:"payload,omitempty"`
	// Stale says the row is its plugin's last report, which the plugin no
	// longer stands behind: it is down.
	Stale bool `json:"stale,omitempty"`
}

Row is one unit's row: the generic part every surface reads, the served facet values, and the provider's payload, opaque to the core.

func (Row) In

func (r Row) In(view string) bool

In tells whether the row is in plugin view view; a closed row is in none.

type RowFacts

type RowFacts struct {
	CreatedAt    time.Time  `json:"created_at,omitzero"`
	ChangedFiles int        `json:"changed_files"`
	Checks       CheckFacts `json:"checks"`
	Turns        TurnFacts  `json:"turns"`
	// Next is sorted by At and holds only future instants.
	Next []Upcoming `json:"next,omitempty"`
}

RowFacts are a row's numbers for the backlog panels.

type RowItem

type RowItem struct {
	ID        string    `json:"id"`
	Kind      string    `json:"kind"` // request, question, decision, todo
	Summary   string    `json:"summary"`
	State     string    `json:"state"` // open, resolved
	WaitingOn []string  `json:"waiting_on"`
	Since     time.Time `json:"since"`
}

type RowsPage

type RowsPage struct {
	Epoch    string      `json:"epoch"`
	Rev      uint64      `json:"rev"`
	Full     bool        `json:"full"`
	Rows     []Row       `json:"rows"`
	Removed  []unit.Unit `json:"removed"`
	Counters *Counters   `json:"counters,omitempty"`
	// Loading are the plugins whose rows are not all here yet.
	Loading []Loading `json:"loading,omitempty"`
}

RowsPage is a view's rows at Rev: every row when Full, else the rows that changed since the asked revision and the units that left the view.

type RunView added in v0.3.0

type RunView struct {
	Seq          int64    `json:"seq"`
	Intent       string   `json:"intent"`
	State        string   `json:"state"`
	Manager      string   `json:"manager,omitempty"`
	Workspace    string   `json:"workspace,omitempty"`
	Worktree     string   `json:"worktree,omitempty"`
	Session      string   `json:"session,omitempty"`
	SessionState string   `json:"session_state,omitempty"`
	Resume       string   `json:"resume,omitempty"`
	Actions      []string `json:"actions,omitempty"`
}

RunView is a run of a task: the turn Seq of Intent in State, where it ran, its session and that session's state, the command that resumes it, and the run actions it offers (open, enter, transcript).

type RunnerState added in v0.2.0

type RunnerState struct {
	Runner  string `json:"runner"`
	Enabled bool   `json:"enabled"`
	Reason  string `json:"reason,omitempty"`
}

RunnerState is a runner a delegate runs on; a session is disabled when the unit has nowhere to run one.

type SavedView

type SavedView struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	View  string `json:"view"`
	Group string `json:"group,omitempty"`
}

SavedView: View is a ViewSpec id served by the generic rows (rows or custom).

type SearchFilter added in v0.3.0

type SearchFilter struct {
	Term   string `json:"term,omitempty"`
	Window int    `json:"window,omitempty"`
	Label  string `json:"label"`
}

SearchFilter toggles Term, or keeps Window days of recent activity.

type SearchPreset added in v0.3.0

type SearchPreset struct {
	Query string `json:"query"`
	Label string `json:"label"`
}

type SearchSort added in v0.3.0

type SearchSort struct {
	Sort  string `json:"sort"`
	Label string `json:"label"`
	Shown string `json:"shown,omitempty"`
}

type SearchSpec added in v0.3.0

type SearchSpec struct {
	DefaultSort string            `json:"default_sort,omitempty"`
	Presets     []SearchPreset    `json:"presets,omitempty"`
	Filters     []SearchFilter    `json:"filters,omitempty"`
	Sorts       []SearchSort      `json:"sorts,omitempty"`
	Decisions   map[string]string `json:"decisions,omitempty"`
	NoDecision  string            `json:"no_decision,omitempty"`
}

SearchSpec is a custom view's search: the queries it runs at a press, the terms it toggles, the orders it offers and how a result's decision reads.

type SessionStartRequest

type SessionStartRequest struct {
	Pane         string `json:"pane,omitempty"`
	WorktreeID   string `json:"worktree_id,omitempty"`
	AgentSession string `json:"agent_session,omitempty"`
	Source       string `json:"source,omitempty"`
	Cwd          string `json:"cwd,omitempty"`
	Home         string `json:"home,omitempty"`
	// Agent is the hook's agent and Transcript the session's transcript
	// file, "" when the agent's payload names none.
	Agent      string `json:"agent,omitempty"`
	Transcript string `json:"transcript,omitempty"`
}

type Since

type Since struct {
	Epoch string
	Rev   uint64
}

Since is a client's position in the rows: the epoch and revision it last merged. The zero Since asks for every row.

func ParseSince

func ParseSince(raw string) (Since, error)

ParseSince reads a since parameter; "" and "0" are the zero Since.

func (Since) String

func (s Since) String() string

String is s as the since parameter and the SSE id, "<epoch>:<rev>"; "" for the zero Since.

type SituationSpec

type SituationSpec struct {
	Provider string `json:"provider"`
	Kind     Kind   `json:"kind"`
	Label    string `json:"label"`
	Rank     int    `json:"rank"`
}

type SourceHealth

type SourceHealth struct {
	Provider unit.ProviderID `json:"provider"`
	Warnings []string        `json:"warnings"`
	Detail   json.RawMessage `json:"detail,omitempty"`
}

type StateSpec added in v0.3.0

type StateSpec struct {
	Name     string `json:"name"`
	Label    string `json:"label"`
	Category string `json:"category"`
}

StateSpec is a state of tasks.toml and the category Go reads of it.

type StopAnswer

type StopAnswer struct {
	Block  bool   `json:"block"`
	Reason string `json:"reason,omitempty"`
}

type StopRequest

type StopRequest struct {
	AgentSession string `json:"agent_session,omitempty"`
	PromptID     string `json:"prompt_id,omitempty"`
	LastMessage  string `json:"last_message,omitempty"`
	// Agent and Transcript are as in SessionStartRequest.
	Agent      string `json:"agent,omitempty"`
	Transcript string `json:"transcript,omitempty"`
}

type StoreStatus added in v0.2.0

type StoreStatus struct {
	// Version is the store's schema version and Reads the one this release
	// creates and migrates to.
	Version uint32 `json:"version"`
	Reads   uint32 `json:"reads"`
	// State is one of the Store* states.
	State   string `json:"state"`
	Message string `json:"message,omitempty"`
	Fix     string `json:"fix,omitempty"`
	// LastBackup is the newest copy of the store in the backups directory.
	LastBackup   string    `json:"last_backup,omitempty"`
	LastBackupAt time.Time `json:"last_backup_at,omitzero"`
}

StoreStatus is the store as the daemon found it. A daemon whose store is not open answers only its health, with State saying why and Fix the command that gets past it.

type Summary

type Summary struct {
	WaitsOn   string    `json:"waits_on"` // "me", a login, "loop", "nobody", ...
	Since     time.Time `json:"since"`
	Stalled   bool      `json:"stalled"`
	Closed    bool      `json:"closed"` // replaces Kind == "done" in Row.In
	OpenItems int       `json:"open_items"`
	Reason    string    `json:"reason"` // one sentence: why it waits
	Line      string    `json:"line"`   // the short status every client shows (menu bar, TUI list)
}

type TagCount

type TagCount struct {
	Value string `json:"value"`
	Count int    `json:"count"`
}

type TaskCreate added in v0.3.0

type TaskCreate struct {
	Title     string            `json:"title"`
	Brief     string            `json:"brief,omitempty"`
	Props     map[string]string `json:"props,omitempty"`
	Placement string            `json:"placement,omitempty"`
	Unit      *unit.Unit        `json:"unit,omitempty"`
}

TaskCreate creates a task: a Title alone captures it. Brief is its brief's markdown, Props its properties as their text, Placement a hint of where its work runs, such as a repository, and Unit the unit it is about.

type TaskRequest added in v0.3.0

type TaskRequest struct {
	Args   map[string]string `json:"args,omitempty"`
	Source string            `json:"source"`
}

TaskRequest args: waiting {on, resurface}; schedule {until (RFC3339 or YYYY-MM-DD), on_activity "true"}; project {id | title (creates one)}; context {set "a,b"}; area {set}; answer: as ActionRequest fields; delegate {guidance, mode "headless" | "session"}; reply {text | reaction, kind "reply" | "react", send "now"}.

type TaskResult added in v0.3.0

type TaskResult struct {
	Task  TaskView `json:"task"`
	Lines []string `json:"lines,omitempty"`
}

type TaskView added in v0.3.0

type TaskView struct {
	ID         string      `json:"id"`
	State      string      `json:"state"`
	Category   string      `json:"category,omitempty"`
	Title      string      `json:"title"`
	Notes      string      `json:"notes,omitempty"`
	Changed    bool        `json:"changed,omitempty"`
	Units      []unit.Unit `json:"units"`
	UnitLabels []string    `json:"unit_labels,omitempty"` // Units as a person reads them, in order
	Cards      []CardView  `json:"cards,omitempty"`       // detail only
	Verbs      []VerbState `json:"verbs"`
	// Actions are the intents that serve the task's own unit, such as start.
	Actions   []ActionState `json:"actions,omitempty"`
	Attention *Attention    `json:"attention,omitempty"`
	Created   time.Time     `json:"created"`
	Updated   time.Time     `json:"updated"`

	// A project's: whether it takes its children one at a time, and its review.
	Sequential  bool      `json:"sequential,omitempty"`
	ReviewEvery string    `json:"review_every,omitempty"` // a Go duration
	ReviewedAt  time.Time `json:"reviewed_at,omitzero"`
	ReviewDue   bool      `json:"review_due,omitempty"`

	// Props are the task's properties by name, each in its type's JSON: a string, a number, an RFC 3339 time,
	// a Go duration string, a list of strings, or a list of people for an actor.
	Props map[string]json.RawMessage `json:"props,omitempty"`
	// OwedBy is who owes the task's next step, as the profile's owed_by says: "me" or a person's key.
	OwedBy string `json:"owed_by,omitempty"`
	// Askers are who waits on you through the task, by key: the requesters of its open asks to you.
	Askers []string `json:"askers,omitempty"`
	// ExtractionLag is how long the oldest message of its links has waited to be extracted, a Go duration;
	// empty when none waits.
	ExtractionLag string `json:"extraction_lag,omitempty"`
	// Asks are the items the task holds, detail only.
	Asks  []AskView   `json:"asks,omitempty"`
	Gates []GateView  `json:"gates,omitempty"` // the open ones
	Runs  []RunView   `json:"runs,omitempty"`  // detail only
	Brief *RecordView `json:"brief,omitempty"`
	Wake  *WakeView   `json:"wake,omitempty"`
	// Parent is the parent task's id; Children are its children's, in sibling order.
	Parent   string   `json:"parent,omitempty"`
	Children []string `json:"children,omitempty"`
}

func (TaskView) DraftOf added in v0.3.0

func (e TaskView) DraftOf() (Draft, bool)

DraftOf is the draft of e's first draft gate, its subject; false when e has none.

func (TaskView) MessageOf added in v0.3.0

func (e TaskView) MessageOf() (Message, GateView, bool)

MessageOf is the message of e's first open question, post or proposal gate, and that gate.

func (TaskView) PropList added in v0.3.0

func (e TaskView) PropList(name string) []string

PropList is the property name's list of strings; nil when unset or of another type.

func (TaskView) PropText added in v0.3.0

func (e TaskView) PropText(name string) string

PropText is the property name's text: a string, an enum or a duration; "" when unset or of another type.

func (TaskView) PropTime added in v0.3.0

func (e TaskView) PropTime(name string) time.Time

PropTime is the property name's time; zero when unset or of another type.

func (TaskView) Texts added in v0.3.0

func (e TaskView) Texts() []string

Texts are what a filter's free words search in a task: its title, notes, state, the text and the lists of text of its properties, its units, who owes it, its asks, its cards' people, its draft and its message. The cockpit's taskHaystack lists the same texts.

func (TaskView) UnitLabel added in v0.3.0

func (e TaskView) UnitLabel(i int) string

UnitLabel is the i-th unit as a person reads it.

type TaskViewSpec added in v0.3.0

type TaskViewSpec struct {
	ID           string `json:"id"`
	Label        string `json:"label"`
	Over         string `json:"over,omitempty"`
	Group        string `json:"group,omitempty"`
	Key          string `json:"key,omitempty"`
	Badge        bool   `json:"badge,omitempty"`
	HideDisabled bool   `json:"hide_disabled,omitempty"`
	RemoveClean  bool   `json:"remove_clean,omitempty"`
}

TaskViewSpec is a view of views.toml: Over is what it lists (tasks or gates), Group the fact it groups by, Key the key that jumps to it, Badge whether the badge counts it, HideDisabled whether it hides the tasks of a disabled plugin, RemoveClean whether it offers to remove its tasks' clean workspaces.

type TasksPage added in v0.3.0

type TasksPage struct {
	Epoch    string     `json:"epoch"`
	Rev      uint64     `json:"rev"`
	Full     bool       `json:"full"`
	Tasks    []TaskView `json:"tasks"`
	Gates    []GateView `json:"gates,omitempty"`
	Removed  []string   `json:"removed"`
	Counters Counters   `json:"counters"`
	// Loading are the plugins whose units are not all reported yet.
	Loading []Loading `json:"loading,omitempty"`
}

TasksPage is a page of a view; a view over gates lists Gates and no Tasks.

type TimelineEvent added in v0.3.0

type TimelineEvent struct {
	Seq   int64           `json:"seq"`
	Kind  string          `json:"kind"`
	Sub   string          `json:"sub,omitempty"`
	Actor string          `json:"actor,omitempty"`
	At    time.Time       `json:"at"`
	Unit  string          `json:"unit,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
}

TimelineEvent is one event of a task's timeline: Seq its stable position, which pages it, and Unit the unit it happened on, "" for the task itself.

type TimingsQuery added in v0.3.0

type TimingsQuery struct {
	Days int `json:"days"`
}

TimingsQuery asks for the timings of the Days days before now.

type TimingsReport

type TimingsReport struct {
	Since         time.Time `json:"since"`
	RecordedSince time.Time `json:"recorded_since,omitzero"`
	// Viewer is the login the report counts as mine, "" when the daemon
	// does not know it yet.
	Viewer        string                 `json:"viewer,omitempty"`
	Milestones    map[string]Quantiles   `json:"milestones"`
	Waiting       map[string]WaitShare   `json:"waiting"`
	ChangeFailure ChangeFailure          `json:"change_failure"`
	Briefs        BriefTimings           `json:"briefs"`
	Intakes       Quantiles              `json:"intakes"`
	Turns         map[string]Quantiles   `json:"turns"`
	Tokens        map[string]TokenCounts `json:"tokens"`
	Tags          map[string][]TagCount  `json:"tags,omitempty"`
	Dropped       []string               `json:"dropped,omitempty"`
	PRs           []PRTimes              `json:"prs"`
	TurnList      []TurnTimes            `json:"turn_list"`
}

TimingsReport is what the loop recorded in the window since Since; RecordedSince is when recording began. Milestones are pull request durations that start and end in the window; Turns are the durations of the turns that ended in it by intent, plus TurnStartWait.

type TokenCounts

type TokenCounts struct {
	Input      int64 `json:"input"`
	Output     int64 `json:"output"`
	CacheRead  int64 `json:"cache_read"`
	CacheWrite int64 `json:"cache_write"`
}

type TranscriptLine added in v0.3.0

type TranscriptLine struct {
	Role string    `json:"role"`
	Text string    `json:"text"`
	At   time.Time `json:"at,omitzero"`
}

TranscriptLine is one message of a run's agent transcript: who wrote it (user or assistant) and its text.

type TranscriptPage added in v0.3.0

type TranscriptPage struct {
	Lines []TranscriptLine `json:"lines"`
	Total int              `json:"total"`
}

TranscriptPage is what RunTranscript serves: the transcript's lines from the asked one, oldest first, and how many lines it holds in all.

type Turn

type Turn struct {
	Seq        int64     `json:"seq"`
	Intent     string    `json:"intent"`
	ID         string    `json:"id"`
	Trigger    string    `json:"trigger"`
	Guidance   string    `json:"guidance"`
	Head       string    `json:"head"`
	SentTo     string    `json:"sent_to"`
	Session    string    `json:"session"`
	State      string    `json:"state"`
	SentAt     time.Time `json:"sent_at"`
	StartedAt  time.Time `json:"started_at,omitzero"`
	EndedAt    time.Time `json:"ended_at,omitzero"`
	ResumeOf   int64     `json:"resume_of,omitempty"`
	ReplacedBy int64     `json:"replaced_by,omitempty"`
	Before     string    `json:"before,omitempty"`
	// Agent is the agent that ran the turn, BriefRun the brief run its
	// instructions carried and AgentSession the agent session that started it.
	Agent        string `json:"agent,omitempty"`
	BriefRun     int64  `json:"brief_run,omitempty"`
	AgentSession string `json:"agent_session,omitempty"`
	// Runner is "" for a session turn; Workflow the workflow that started it;
	// Role the role its intent held.
	Runner   string `json:"runner,omitempty"`
	Workflow string `json:"workflow,omitempty"`
	Role     string `json:"role,omitempty"`
}

type TurnAnswer

type TurnAnswer struct {
	ID       int64     `json:"id"`
	TurnSeq  int64     `json:"turn_seq"`
	Text     string    `json:"text"`
	OptionID string    `json:"option_id,omitempty"`
	Yes      bool      `json:"yes"`
	No       bool      `json:"no,omitempty"`
	Source   string    `json:"source"`
	Route    string    `json:"route"`
	Session  string    `json:"session,omitempty"`
	At       time.Time `json:"at"`
	// Message is the Inbox message answered, 0 for none; Posted says the agent posted it. Gate is the gate the
	// answer resolved, 0 for one given with no gate open.
	Message int64 `json:"message_id,omitempty"`
	Gate    int64 `json:"gate_id,omitempty"`
	Posted  bool  `json:"posted,omitempty"`
	// NoticedAt is when the session was told of the answer, ReadAt when the agent read it; each absent until then.
	NoticedAt *time.Time `json:"noticed_at,omitempty"`
	ReadAt    *time.Time `json:"read_at,omitempty"`
}

type TurnBook

type TurnBook struct {
	Unit  Named       `json:"unit"`
	Turns []TurnShown `json:"turns"`
}

TurnBook is a pull request's book as `turn show` prints it.

type TurnEndRequest

type TurnEndRequest struct {
	Turn string `json:"turn"`
	// PR is the pull request the command line names, "" for none.
	PR           string          `json:"pr,omitempty"`
	Record       json.RawMessage `json:"record"`
	AgentSession string          `json:"agent_session,omitempty"`
	// WrittenAt is when the record's file was last written; zero when the
	// record came from no file.
	WrittenAt time.Time `json:"written_at,omitzero"`
}

type TurnEnded

type TurnEnded struct {
	PR    string `json:"pr"`
	State string `json:"state"`
	Added bool   `json:"added"`
	// Note tells the agent its record changes nothing.
	Note   string       `json:"note,omitempty"`
	Ledger *ItemsResult `json:"ledger,omitempty"`
}

type TurnFacts

type TurnFacts struct {
	Count      int     `json:"count"`
	Open       int     `json:"open"`
	LastIntent string  `json:"last_intent,omitempty"`
	Tokens     int64   `json:"tokens"`
	CostUSD    float64 `json:"cost_usd"`
}

TurnFacts counts every turn of the pull request; Open is those sent, started or asked, and CostUSD counts an unreported cost as 0.

type TurnRecord

type TurnRecord struct {
	ID           int64         `json:"id"`
	TurnSeq      int64         `json:"turn_seq"`
	Session      string        `json:"session"`
	AgentSession string        `json:"agent_session"`
	Head         string        `json:"head"`
	Hash         string        `json:"hash"`
	At           time.Time     `json:"at"`
	Acked        bool          `json:"acked"`
	Record       record.Record `json:"record"`
}

type TurnShown

type TurnShown struct {
	Turn         turn.Turn     `json:"turn"`
	Instructions string        `json:"instructions,omitempty"`
	Records      []turn.Record `json:"records"`
	Answers      []turn.Answer `json:"answers"`
}

TurnShown is one turn with its stored instructions and its events: the records and the answers it got.

type TurnStartRequest

type TurnStartRequest struct {
	Turn   string `json:"turn"`
	Intent string `json:"intent"`
}

type TurnText

type TurnText struct {
	Text string `json:"text"`
}

TurnText is a turn's stored instructions, or the answers the caller reads with turn answer.

type TurnTimes

type TurnTimes struct {
	PR           string    `json:"pr"`
	Seq          int64     `json:"seq"`
	Intent       string    `json:"intent"`
	Trigger      string    `json:"trigger"`
	State        string    `json:"state"`
	Agent        string    `json:"agent,omitempty"`
	Sent         time.Time `json:"sent"`
	Started      time.Time `json:"started,omitzero"`
	Ended        time.Time `json:"ended,omitzero"`
	DurationMS   int64     `json:"duration_ms,omitempty"`
	OutputTokens int64     `json:"output_tokens,omitempty"`
}

TurnTimes is one turn of the window, for --turns.

type TurnView

type TurnView struct {
	Turn        Turn         `json:"turn"`
	Records     []TurnRecord `json:"records"`
	Answers     []TurnAnswer `json:"answers"`
	LastMessage string       `json:"last_message,omitempty"`
}

TurnView is the pull request's newest turn with its records and answers.

type UnitQuery added in v0.3.0

type UnitQuery struct {
	Unit unit.Unit `json:"unit"`
}

UnitQuery names the unit a view is of.

type UnitRowQuery added in v0.3.0

type UnitRowQuery struct {
	Unit    unit.Unit      `json:"unit"`
	Action  string         `json:"action,omitempty"`
	Inputs  map[string]any `json:"inputs,omitempty"`
	Unmuted bool           `json:"unmuted,omitempty"`
	Kept    bool           `json:"kept,omitempty"`
}

UnitRowQuery asks for a unit's row; Action and Inputs are the action a request asks for, Unmuted derives it without the user's mute and pending round, and Kept asks only for a unit the plugin keeps, reading nothing from its source.

type UnitWorkflow

type UnitWorkflow struct {
	Workflow string `json:"workflow"`
	Trigger  string `json:"trigger"`
	Outcome  string `json:"outcome"`
	Reason   string `json:"reason,omitempty"`
	Facts    []Fact `json:"facts,omitempty"`
}

UnitWorkflow is a workflow of the explained unit's provider that gives the unit no item: Outcome is "not_matched", "matched", "waits" or "error", Facts the facts its `when` read.

type Upcoming

type Upcoming struct {
	At   time.Time `json:"at"`
	What string    `json:"what"`
}

Upcoming is a future instant of the row: What is gate, unmute or brief_retry.

type VerbSpec added in v0.3.0

type VerbSpec struct {
	Verb    string `json:"verb"`
	Handler string `json:"handler,omitempty"`
	Label   string `json:"label"`
	Summary string `json:"summary,omitempty"`
	Input   string `json:"input,omitempty"` // the question a verb that asks for a value puts first
	// Send is what a reply of a verb whose handler is reply does by default: "now" sends it, "draft" holds it
	// for approval; every client's reply composer starts on it.
	Send string   `json:"send,omitempty"`
	Key  string   `json:"key"`
	From []string `json:"from,omitempty"`
	To   string   `json:"to,omitempty"`
}

VerbSpec is a verb a task offers: Handler is what it runs besides its move, as the profile names it ("" for none), From the states it moves a task from (every state when empty), To the state it moves it to ("" for none).

type VerbState

type VerbState struct {
	Verb    string `json:"verb"`
	Enabled bool   `json:"enabled"`
	Reason  string `json:"reason,omitempty"`
	// Runners are, on an enabled delegate, the runners of the action it runs: headless, session or both.
	Runners []RunnerState `json:"runners,omitempty"`
}

type ViewSpec

type ViewSpec struct {
	ID       string   `json:"id"` // "needs-me", ...; unique across providers
	Label    string   `json:"label"`
	Provider string   `json:"provider"` // "" for a core view
	Rows     bool     `json:"rows"`     // a list of rows filtered by Row.Views; false: a custom view the client knows (plan, dash, explore, recent)
	Order    int      `json:"order"`
	Surfaces []string `json:"surfaces"` // "web", "tui", "menubar"
	// Unit names the view's rows, such as "Pull request"; "" for a view whose rows mix providers.
	Unit string `json:"unit,omitempty"`
	// UnitSort is the facet the unit column sorts by, such as "repo"; "" sorts by "repo".
	UnitSort string `json:"unit_sort,omitempty"`
	// Search is a custom view's search; nil for none.
	Search *SearchSpec `json:"search,omitempty"`
}

type ViewsCatalog added in v0.3.0

type ViewsCatalog struct {
	Views    []TaskViewSpec `json:"views"` // core views in spec 9.1 order, review only once registered
	Areas    []string       `json:"areas"`
	Contexts []string       `json:"contexts"`
	Verbs    []VerbSpec     `json:"verbs"` // key from internal/keys
	// Review are the ids of the views the review walks, in order.
	Review []string `json:"review,omitempty"`
	// States are the profile's states in their declared order; Props its task properties.
	States []StateSpec `json:"states,omitempty"`
	Props  []PropSpec  `json:"props,omitempty"`
}

func (ViewsCatalog) HandlerOf added in v0.3.0

func (c ViewsCatalog) HandlerOf(verb string) string

HandlerOf is the handler verb runs in c: its profile handler, else its own name, as the tasks service binds it.

func (ViewsCatalog) PropOf added in v0.3.0

func (c ViewsCatalog) PropOf(role string) (PropSpec, bool)

PropOf is the property of c that takes role; false when none does.

func (ViewsCatalog) Starred added in v0.3.0

func (c ViewsCatalog) Starred(e TaskView) bool

Starred says whether e holds the starred value, the first, of the property c's star role acts on.

func (ViewsCatalog) VerbOf added in v0.3.0

func (c ViewsCatalog) VerbOf(handler string) (string, bool)

VerbOf is the verb of c that runs handler: the first whose handler it is, or with no handler, whose name it is, as the tasks service binds a kind's own verbs; false when none does.

type WaitShare

type WaitShare struct {
	TotalMS int64     `json:"total_ms"`
	OpenMS  int64     `json:"open_ms"`
	PRs     int       `json:"prs"`
	Spans   Quantiles `json:"spans"`
}

WaitShare is the time followed pull requests spent waiting on one party in the window: the total, and the spans between situation changes. OpenMS is the part of the total in spans still open at the report's time, which Spans leaves out.

type WakeView added in v0.3.0

type WakeView struct {
	Until  time.Time `json:"until,omitzero"`
	When   string    `json:"when,omitempty"`
	Return string    `json:"return,omitempty"`
}

WakeView is a task's wake: until a time, or When, a condition, holds; Return is the state it goes back to.

type WebView

type WebView struct {
	Module string   `json:"module"`
	Views  []string `json:"views"`
}

WebView: Module is served at /plugins/<id>/<Module>.

type Why

type Why struct {
	Trigger string `json:"trigger"`
	Event   string `json:"event,omitempty"`
	Matched []Fact `json:"matched"`
}

type Workspace

type Workspace struct {
	// Manager owns the workspace; ID is its id there.
	Manager     string   `json:"manager,omitempty"`
	ID          string   `json:"id"`
	DisplayName string   `json:"display_name"`
	Status      string   `json:"status"`
	IsReview    bool     `json:"is_review"`
	AgentStates []string `json:"agent_states"`
	Comment     string   `json:"comment"`
	// IsMain is the repository's main checkout on the pull request's branch,
	// which the loop never removes.
	IsMain bool `json:"is_main"`
}

Directories

Path Synopsis
Package client is the Go client of the daemon's API, over its Unix socket.
Package client is the Go client of the daemon's API, over its Unix socket.

Jump to

Keyboard shortcuts

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