Documentation
¶
Overview ¶
Package webapi is the dashboard's JSON API and static UI server. It serves reads over each account's reviews, repositories, usage and queue, and over the running configuration, its setup and connections. It serves re-runs, cancels, reindexes and turning repositories on or off, with their audit log. It also serves the server-sent event stream that keeps the UI live. kritika serve runs it. internal/auth decides who a request acts as.
Index ¶
- type APIToken
- type Accepted
- type AccountDetail
- type AccountFinding
- type AccountSummary
- type Actions
- type AdminAccount
- type AdminUser
- type AgentPart
- type AgentRun
- type Analytics
- type AnalyticsPoint
- type AnalyticsTotals
- type AppInstallation
- type Attention
- type AuditAction
- type AuditEvent
- type ChatGPTProviderUsage
- type Confidence
- type Config
- type Connection
- type ContextChunk
- type ContextPack
- type CreateTokenRequest
- type CreatedToken
- type CredentialsSet
- type DependencyDrift
- type EgressRefusal
- type ErrorBody
- type ErrorCode
- type Event
- type Finding
- type FindingCounts
- type FindingExport
- type FindingGroup
- type FindingSummary
- type Followup
- type IndexChunk
- type IndexChunks
- type IndexContents
- type IndexFile
- type IndexJob
- type IndexRun
- type IndexState
- type InstanceJob
- type InstancePull
- type InstanceQueue
- type InstanceSetting
- type Job
- type JobActions
- func (a JobActions) Cancel(ctx context.Context, tx pgx.Tx, reviewID string) error
- func (a JobActions) Reindex(ctx context.Context, tx pgx.Tx, accountID, repositoryID string) (int64, error)
- func (a JobActions) Rerun(ctx context.Context, tx pgx.Tx, accountID, repositoryID string, number int) (int64, error)
- type JobArgs
- type JobCause
- type Label
- type Me
- type Message
- type Meta
- type ModelSlots
- type MonthUsage
- type Page
- type Pull
- type PullDetail
- type PullRef
- type RegisterResult
- type RepoActivity
- type RepoConfig
- type RepoDetail
- type RepoFile
- type RepoSettings
- type Repository
- type Response
- type Resync
- type Review
- type ReviewBrief
- type ReviewDetail
- type ReviewDiff
- type ReviewInfo
- type ReviewRaw
- type ReviewRef
- type Rule
- type RuleKind
- type RuleSource
- type RunnerRun
- type Server
- type SetupStatus
- type SeverityCounts
- type Stage
- type Summary
- type TimelineStep
- type TokenCounts
- type TokenStatus
- type ToolCall
- type ToolDef
- type ToolExecution
- type ToolResult
- type ToolUsage
- type Transcript
- type Turn
- type TurnOnRequest
- type Usage
- type UsagePoint
- type UsageRow
- type UsageSeries
- type User
- type UserAccess
- type UserSettings
- type UserSignIn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIToken ¶
type APIToken struct {
ID string `json:"id"`
Name string `json:"name"`
Owner *User `json:"owner"`
AllAccounts bool `json:"allAccounts"`
Accounts []string `json:"accounts"`
Status TokenStatus `json:"status"`
CreatedAt time.Time `json:"createdAt"`
ExpiresAt *time.Time `json:"expiresAt"`
LastUsedAt *time.Time `json:"lastUsedAt"`
}
APIToken is a personal access token as its owner or an admin lists it, never its value. Accounts are the configured accounts that it reads unless AllAccounts. Owner is set in an admin's list alone.
type Accepted ¶
type Accepted struct {
JobID int64 `json:"jobId,omitzero"`
}
Accepted is an action queued. JobID is the queued job, when there is one.
type AccountDetail ¶
type AccountDetail struct {
Slug string `json:"slug"`
Connection Connection `json:"connection"`
Models configfile.Models `json:"models"`
Limits configfile.Limits `json:"limits"`
// Filters are the conditions that decide which pull requests are
// reviewed.
Filters configfile.Filters `json:"filters"`
Usage MonthUsage `json:"usage"`
// LastPolledAt is when kritika last polled the account for pull
// requests, null when it never has: what stands in for a webhook that
// does not arrive.
LastPolledAt *time.Time `json:"lastPolledAt"`
}
AccountDetail is one account's configuration and usage, and the connection serving it.
type AccountFinding ¶
type AccountFinding struct {
Finding
ReviewID string `json:"reviewId"`
Pull PullRef `json:"pull"`
FirstSeenAt time.Time `json:"firstSeenAt"`
LastSeenAt time.Time `json:"lastSeenAt"`
}
AccountFinding is one finding of a pull request, however many of its reviews reported it, as the latest of them did.
type AccountSummary ¶
type AccountSummary struct {
ChatGPTEnabled bool `json:"chatgptEnabled,omitzero"`
Slug string `json:"slug"`
Connection string `json:"connection"`
Repositories int `json:"repositories"`
Reviews7d int `json:"reviews7d"`
Usage MonthUsage `json:"usage"`
Attention Attention `json:"attention"`
LastWebhookAt *time.Time `json:"lastWebhookAt"`
LastUnsignedWebhookAt *time.Time `json:"lastUnsignedWebhookAt"`
LastPolledAt *time.Time `json:"lastPolledAt"`
}
AccountSummary is one row of the account list. Connection names the connection serving it. Attention and the three times are the account's health: what wants a look, when the connection's webhook last delivered, verified and unsigned, and when the account was last polled, each null for never.
type Actions ¶
type Actions interface {
// Rerun queues a manual review of the pull request's current head,
// jobs.ErrNoHead when none is known, jobs.ErrRerunQueued when one is
// already queued or running.
Rerun(ctx context.Context, tx pgx.Tx, accountID, repositoryID string, number int) (int64, error)
// Cancel asks a running review to stop. It returns jobs.ErrNotCancelable
// when the review is not running.
Cancel(ctx context.Context, tx pgx.Tx, reviewID string) error
// Reindex queues a full reindex of the repository. It returns
// jobs.ErrRepositoryNotFound when the repository no longer exists
// (findRepo already resolved it in the same transaction, so this is
// defense in depth). It returns jobs.ErrReindexQueued when a forced
// reindex is already queued or running.
Reindex(ctx context.Context, tx pgx.Tx, accountID, repositoryID string) (int64, error)
}
Actions queues the work that an admin can ask for from the dashboard. It queues each in the caller's account transaction, so the job and its audit row commit together.
type AdminAccount ¶
type AdminAccount struct {
AccountSummary
Live bool `json:"live"`
Conflict string `json:"conflict,omitempty"`
}
AdminAccount is one account as an admin sees it: Live is false for an entry of the instance spec that no connection serves, which Conflict explains.
type AdminUser ¶
type AdminUser struct {
User
SignIns []UserSignIn `json:"signIns"`
Access *UserAccess `json:"access"`
Sessions int `json:"sessions"`
FirstSeenAt time.Time `json:"firstSeenAt"`
LastSignInAt *time.Time `json:"lastSignInAt"`
}
AdminUser is a user who signed in, as an admin lists them. Access is what their newest session that the configuration still honors lets them read, nil without one. Sessions counts those sessions.
type AgentPart ¶
type AgentPart struct {
ReusedFrom string `json:"reusedFrom,omitzero"`
Agent string `json:"agent,omitzero"`
Full bool `json:"full,omitzero"`
Paths []string `json:"paths"`
Stop string `json:"stop"`
ForcedBy string `json:"forcedBy,omitzero"`
Error string `json:"error"`
Steps int `json:"steps"`
CostUSD float64 `json:"costUsd,omitzero"`
}
AgentPart is one part of a split review: its files, why its agent stopped, with the error it ended on, its steps, and what its model calls cost, 0 once they are swept. Reviewer is the reviewer that it was for in a review with several. Full says that it reviewed the whole change of a review that built on the last one.
type AgentRun ¶
type AgentRun struct {
StopReason string `json:"stopReason"`
// ForcedBy is the limit that made the loop tell the agent to submit:
// steps, tokens or time. It is absent when the loop never did, and for a
// split review, whose parts each say.
ForcedBy string `json:"forcedBy,omitzero"`
Steps int `json:"steps"`
ToolCalls map[string]int `json:"toolCalls"`
Timeline []TimelineStep `json:"timeline"`
Sources []string `json:"sources"`
SkillsOffered []string `json:"skillsOffered"`
SkillsOpened []string `json:"skillsOpened"`
CommandsOffered []string `json:"commandsOffered"`
CommandsRun []string `json:"commandsRun"`
Usage Usage `json:"usage"`
CostUSD float64 `json:"costUsd"`
UnpricedSteps int64 `json:"unpricedSteps,omitzero"`
Model string `json:"model"`
Error string `json:"error"`
CreatedAt time.Time `json:"createdAt"`
Result json.RawMessage `json:"result"`
// CarriedReviewID is the review whose conversation the agent carried
// on, nil when it started afresh.
CarriedReviewID *string `json:"carriedReviewId"`
// Parts are how the parts of a split review ended, in part order. It is
// empty when the review was not split.
Parts []AgentPart `json:"parts"`
}
AgentRun is a review's tool loop. Result is the submitted review JSON, null unless the agent submitted. SkillsOffered are the repository skills that the agent can read, SkillsOpened the ones it did read. CommandsOffered and CommandsRun are the same for the run tool's commands.
type Analytics ¶
type Analytics struct {
Group store.AnalyticsGroup `json:"group"`
From time.Time `json:"from"`
To time.Time `json:"to"`
Current AnalyticsTotals `json:"current"`
Previous AnalyticsTotals `json:"previous"`
Series []AnalyticsPoint `json:"series"`
Repositories []RepoActivity `json:"repositories"`
Refusals []EgressRefusal `json:"refusals"`
}
Analytics is the account's reviews in [From, To), against the window of the same length before it, bucketed by Group. It also holds the repositories with the most reviews and the hosts that the gateway refused its runs, the most refused first.
type AnalyticsPoint ¶
type AnalyticsPoint struct {
Key string `json:"key"`
Reviews int `json:"reviews"`
Failed int `json:"failed"`
Tokens int64 `json:"tokens"`
MedianReviewMs *int64 `json:"medianReviewMs"`
Findings SeverityCounts `json:"findings"`
CostUSD float64 `json:"costUsd"`
}
AnalyticsPoint is one bucket of the series, keyed by its first date.
type AnalyticsTotals ¶
type AnalyticsTotals struct {
PullRequests int `json:"pullRequests"`
Reviews int `json:"reviews"`
Failed int `json:"failed"`
Findings SeverityCounts `json:"findings"`
// Categories counts the same findings by category, every category
// present.
Categories map[review.Category]int `json:"categories"`
Addressed int `json:"addressed"`
ReactionsUp int `json:"reactionsUp"`
ReactionsDown int `json:"reactionsDown"`
Tokens int64 `json:"tokens"`
CostUSD float64 `json:"costUsd"`
UnpricedCalls int64 `json:"unpricedCalls,omitzero"`
MedianReviewMs *int64 `json:"medianReviewMs"`
MedianMergeMs *int64 `json:"medianMergeMs"`
}
AnalyticsTotals is what the account's reviews came to over a window: completed reviews and the pull requests they reviewed, failed reviews, and the findings first reported in it and how many were addressed since. It also holds the reactions to those posted inline, spend, the median time a completed review took, and the median time from opening to merging.
type AppInstallation ¶
type AppInstallation struct {
ID int64 `json:"id"`
Account string `json:"account"`
AccountType string `json:"accountType"`
// AllRepositories is whether it covers every repository of the
// account rather than those selected.
AllRepositories bool `json:"allRepositories"`
Suspended bool `json:"suspended"`
Served bool `json:"served"`
URL string `json:"url,omitempty"`
}
AppInstallation is one account that a connection's GitHub App is installed on. Served is whether the connection lists the account: kritika reviews nothing on one it does not, and an admin can uninstall the App there.
type Attention ¶
type Attention struct {
Failed int `json:"failed"`
Capped int `json:"capped"`
P0 int `json:"p0"`
Paused int `json:"paused"`
}
Attention counts the account's open pull requests that want a look, by why: their newest review failed, hit a cap or found a P0, or their automatic reviews are paused. One can count under several.
type AuditAction ¶
type AuditAction string
AuditAction names what an audit event records.
const ( AuditAppUninstall AuditAction = "app.uninstall" AuditReviewRerun AuditAction = "review.rerun" AuditReviewCancel AuditAction = "review.cancel" AuditRepoReindex AuditAction = "repo.reindex" AuditRepoTurnOn AuditAction = "repo.turn_on" AuditRepoTurnOff AuditAction = "repo.turn_off" AuditUserSignOut AuditAction = "user.sign_out" AuditTokenCreate AuditAction = "token.create" AuditTokenRevoke AuditAction = "token.revoke" )
Audited actions.
type AuditEvent ¶
type AuditEvent struct {
ID string `json:"id"`
At time.Time `json:"at"`
Actor *User `json:"actor"`
Account string `json:"account"`
Action AuditAction `json:"action"`
Target string `json:"target"`
Detail json.RawMessage `json:"detail"`
}
AuditEvent is one audit log entry. Actor is null once the user is deleted. Account is the account's slug, "" when the event names none or no connection serves the account now. Detail never holds a secret.
type ChatGPTProviderUsage ¶
type ChatGPTProviderUsage struct {
Provider string `json:"provider"`
Connected bool `json:"connected"`
Allowances []chatgpt.Allowance `json:"allowances"`
}
ChatGPTProviderUsage is a configured provider's connection and quota data.
type Confidence ¶
type Confidence struct {
Score int `json:"score"`
Threshold int `json:"threshold"`
Passed bool `json:"passed"`
Reason string `json:"reason"`
// Risk is how much a mistake in the change costs: low, medium, high or
// critical.
Risk review.Risk `json:"risk"`
Model string `json:"model"`
}
Confidence is the score a second model gave a reviewed pull request, out of 5, against the threshold its repository set.
type Config ¶
type Config struct {
Store *store.Store
Current *configfile.Current
// Auth signs the dashboard in and stands behind every route. It is
// required, as Store and Current are.
Auth *auth.Handler
// Actions queues re-runs, cancels and reindexes. A nil value disables
// them.
Actions Actions
// Version is the build's version, shown by /api/v1/meta.
Version string
// UI is the built dashboard, served under the base path. A nil value
// serves no UI.
UI fs.FS
// WebURL is the dashboard's external URL, which is required. Its path is
// the base path that every route is served under.
WebURL *url.URL
// Logger defaults to slog.Default().
Logger *slog.Logger
// Now defaults to time.Now.
Now func() time.Time
// Env is this process's environment as the configuration read it, shown
// to admins. Secrets show only whether they are set.
Env []config.EnvVar
// GitHubAPI is the GitHub API that the connections' Apps call, "" for
// api.github.com. Tests point it at a server of their own.
GitHubAPI string
}
Config wires a Server.
type Connection ¶
type Connection struct {
Name string `json:"name"`
Forge configfile.Forge `json:"forge"`
Host string `json:"host,omitzero"`
Accounts []string `json:"accounts"`
Credentials CredentialsSet `json:"credentials"`
HookPath string `json:"hookPath"`
// LastWebhookAt is when a webhook for the connection last passed
// signature verification, to the minute. It is null when none ever did,
// and kritika only polls it.
LastWebhookAt *time.Time `json:"lastWebhookAt"`
// LastUnsignedWebhookAt is when one last arrived with no signature, to
// the minute, which a GitHub App with no webhook secret sends. It is null
// when none did.
LastUnsignedWebhookAt *time.Time `json:"lastUnsignedWebhookAt"`
}
Connection is one GitHub App, Forgejo integration, GitLab service account or Gitea bot user and the accounts it serves. HookPath is where its webhook arrives, under the dashboard's URL. Host is the Forgejo, GitLab or Gitea instance it talks to, empty for GitHub.
type ContextChunk ¶
type ContextChunk struct {
Stage string `json:"stage"`
Path string `json:"path"`
Language string `json:"language"`
Symbol string `json:"symbol"`
Kind string `json:"kind"`
Scope string `json:"scope"`
StartLine int `json:"startLine"`
EndLine int `json:"endLine"`
Ref string `json:"ref"`
Text string `json:"text"`
}
ContextChunk is one context chunk with its text.
type ContextPack ¶
type ContextPack struct {
HeadSHA string `json:"headSha"`
BaseSHA string `json:"baseSha"`
PatchID string `json:"patchId"`
ChangedPaths []string `json:"changedPaths"`
DeltaPaths []string `json:"deltaPaths"`
PriorHeadSHA *string `json:"priorHeadSha"`
Stages []Stage `json:"stages"`
RepoNotes []string `json:"repoNotes"`
// RuleIDs are the ids of the rules the review was given to check: the
// ones that apply to the paths it changed and to the pull request.
RuleIDs []string `json:"ruleIds"`
RepoFiles []RepoFile `json:"repoFiles"`
CreatedAt time.Time `json:"createdAt"`
}
ContextPack is what a review's Job gathered, without diff bodies, stage texts or file contents.
type CreateTokenRequest ¶
type CreateTokenRequest struct {
Name string `json:"name"`
Accounts []string `json:"accounts"`
ExpiresInDays int `json:"expiresInDays"`
}
CreateTokenRequest creates a token named Name that reads Accounts, the slugs of accounts that its creator reads. When it names none, the token reads everything that they read. The token lasts for ExpiresInDays days: 7, 30, 90 or 365, 0 for never.
type CreatedToken ¶
CreatedToken is a token just created, with its value, which no later read shows again.
type CredentialsSet ¶
type CredentialsSet struct {
// ClientID is a GitHub App's. Audience and RunnerAudience are a Forgejo
// integration's, the second the read-only one that runners fetch as. A
// GitHub App and a Forgejo integration both have a PrivateKey. Token and
// RunnerToken are a GitLab service account's or a Gitea bot user's, the
// second read-only.
ClientID bool `json:"clientId,omitzero"`
PrivateKey bool `json:"privateKey,omitzero"`
Audience bool `json:"audience,omitzero"`
RunnerAudience bool `json:"runnerAudience,omitzero"`
Token bool `json:"token,omitzero"`
RunnerToken bool `json:"runnerToken,omitzero"`
WebhookSecret bool `json:"webhookSecret"`
}
CredentialsSet says which of a connection's secrets resolve to a value. The values themselves are never exposed.
type DependencyDrift ¶
type DependencyDrift struct {
Repository string `json:"repository"`
// Path is the file that moves the dependency and Dependency the line,
// with its version blanked, that names it there.
Path string `json:"path"`
Dependency string `json:"dependency"`
Bumps int `json:"bumps"`
// Levels is how many risk levels the updates were rated at.
Levels int `json:"levels"`
Risks map[review.Risk]int `json:"risks"`
Reaches map[review.Reach]int `json:"reaches"`
LastAt time.Time `json:"lastAt"`
LastRisk review.Risk `json:"lastRisk"`
LastReach review.Reach `json:"lastReach"`
LastStep review.Step `json:"lastStep"`
}
DependencyDrift is how one dependency's updates were rated over the window, from the newest scored review of each pull request that moved it: the risk the judge gave each update before any hold, where the change moved that version alone, and the reach it gave the dependency, counted, with the last update's rating, whose risk is "" where the change did more. A dependency rated at more levels than one drifted.
type EgressRefusal ¶
type EgressRefusal struct {
// Repository is the full name, "" for runs without one.
Repository string `json:"repository"`
// Account is set in the instance's list, where a row can be any readable
// account's.
Account string `json:"account,omitzero"`
Host string `json:"host"`
// Count is the refusals and Runs the distinct runs they came from.
Count int64 `json:"count"`
Runs int64 `json:"runs"`
// Reasons counts the refusals by reason.
Reasons map[string]int64 `json:"reasons"`
LastSeenAt time.Time `json:"lastSeenAt"`
}
EgressRefusal is how often the gateway refused one host over the window, to the runs of one repository, by reason. The host is what the agent asked for, a name steered by the content under review: text, not a link. A run belongs to one repository, so Runs add up across a host's rows.
type ErrorCode ¶
type ErrorCode string
ErrorCode is the machine-readable part of an API error.
const ( CodeNotFound ErrorCode = "not_found" CodeBadRequest ErrorCode = "bad_request" CodeInvalidCursor ErrorCode = "invalid_cursor" CodeAmbiguous ErrorCode = "ambiguous" CodeInternal ErrorCode = "internal" CodeForbidden ErrorCode = "forbidden" CodeNoHead ErrorCode = "no_head" CodeNotCancelable ErrorCode = "not_cancelable" CodeAlreadyQueued ErrorCode = "already_queued" // CodeForgeError is the forge failing or refusing a call that an admin // asked for. The message is the forge's. CodeForgeError ErrorCode = "forge_error" // CodeInstallationServed refuses to uninstall an App from an account // its connection serves. CodeInstallationServed ErrorCode = "installation_served" // CodeNotAnApp refuses an installation route for a connection that is // no GitHub App. CodeNotAnApp ErrorCode = "not_an_app" )
Error codes the API returns.
type Event ¶
type Event struct {
Kind store.EventKind `json:"kind"`
Account string `json:"account"`
ID string `json:"id"`
ReviewID *string `json:"reviewId"`
}
Event is one server-sent event's data: a row of Kind changed in the account with this slug.
type Finding ¶
type Finding struct {
ID string `json:"id"`
Path string `json:"path"`
Line int `json:"line"`
EndLine int `json:"endLine"`
Severity review.Severity `json:"severity"`
Category review.Category `json:"category"`
Title string `json:"title"`
Explanation string `json:"explanation"`
SuggestedFix string `json:"suggestedFix"`
Replacement string `json:"replacement"`
AgentPrompt string `json:"agentPrompt"`
Fingerprint string `json:"fingerprint"`
PostedInline bool `json:"postedInline"`
ForgeCommentID *int64 `json:"forgeCommentId"`
CreatedAt time.Time `json:"createdAt"`
// ReactionsUp and ReactionsDown count the 👍 and 👎 on its inline
// comment, as the poller last read them.
ReactionsUp int `json:"reactionsUp"`
ReactionsDown int `json:"reactionsDown"`
// Rules are the ids of the review rules it enforces.
Rules []string `json:"rules"`
// Reviewers are the reviewers that raised it, empty for the default
// reviewer alone.
Agents []string `json:"agents"`
// Status is what became of it on its pull request: whether a later
// review no longer reported it, or it was dismissed, with
// DismissReason the reason given and DismissSource what dismissed it.
Status store.FindingStatus `json:"status"`
DismissReason string `json:"dismissReason"`
DismissSource store.DismissalSource `json:"dismissSource"`
}
Finding is one finding in full.
type FindingCounts ¶
type FindingCounts struct {
Findings int `json:"findings"`
Addressed int `json:"addressed"`
Dismissed int `json:"dismissed"`
Downvoted int `json:"downvoted"`
}
FindingCounts is how many findings there are, and how many of those were addressed, dismissed, or drew a 👎 on their comment.
type FindingExport ¶
type FindingExport struct {
Items []AccountFinding `json:"items"`
Truncated bool `json:"truncated"`
}
FindingExport is the findings that the list's filters keep, newest first, as an export serves them as JSON. Truncated says that the filters keep more than it holds.
type FindingGroup ¶
type FindingGroup struct {
Key string `json:"key"`
Repository string `json:"repository"`
FindingCounts
}
FindingGroup is the findings that share a key, counted. The key is a category, a rule id, an agent's name, "default" for the default pass, or a directory of Repository. A directory key is one below the path filter, with a trailing slash. For a file in no directory below the path filter, the key is the path filter itself ("" for none).
type FindingSummary ¶
type FindingSummary struct {
FindingCounts
Categories []FindingGroup `json:"categories"`
Rules []FindingGroup `json:"rules"`
Agents []FindingGroup `json:"agents"`
Directories []FindingGroup `json:"directories"`
}
FindingSummary is the findings the list's filters keep, counted, and the most common categories, rules, agents and directories among them, the most common first.
type Followup ¶
type Followup struct {
ID string `json:"id"`
CommentID int64 `json:"commentId"`
Repository string `json:"repository"`
Number int `json:"number"`
// PullURL is the pull request on the forge, where its comments are.
PullURL string `json:"pullUrl"`
Author string `json:"author"`
Inline bool `json:"inline"`
Path string `json:"path"`
Line int `json:"line"`
Status store.FollowupStatus `json:"status"`
Reason string `json:"reason"`
ReplyCommentID *int64 `json:"replyCommentId"`
Model string `json:"model"`
CreatedAt time.Time `json:"createdAt"`
}
Followup is one @-mention of the bot and what came of it.
type IndexChunk ¶
type IndexChunk struct {
StartLine int `json:"startLine"`
EndLine int `json:"endLine"`
Language string `json:"language"`
Symbol string `json:"symbol"`
Kind string `json:"kind"`
Scope string `json:"scope"`
Text string `json:"text,omitzero"`
}
IndexChunk is one chunk of an indexed file. Text is served to admins only: it is the default branch's code, more than a review shows a reader of the account.
type IndexChunks ¶
type IndexChunks struct {
Path string `json:"path"`
Items []IndexChunk `json:"items"`
Truncated bool `json:"truncated"`
}
IndexChunks are the chunks of one indexed file, up to a bound. Truncated says that the file holds more.
type IndexContents ¶
type IndexContents struct {
Indexed bool `json:"indexed"`
Commit string `json:"commit"`
EmbedModel string `json:"embedModel"`
EmbedDims int `json:"embedDims"`
BuiltAt *time.Time `json:"builtAt"`
FinishedAt *time.Time `json:"finishedAt"`
Chunks int `json:"chunks"`
Files int `json:"files"`
// Current is false when another embedder than the applied one built
// the generation: similar-code lookups skip it until it is rebuilt.
Current bool `json:"current"`
}
IndexContents is what a repository's active index generation holds. It has null fields and zero counts when the repository has none.
type IndexFile ¶
type IndexFile struct {
Path string `json:"path"`
Language string `json:"language"`
Chunks int `json:"chunks"`
}
IndexFile is one file an index generation holds.
type IndexJob ¶
type IndexJob struct {
ID int64 `json:"id"`
State rivertype.JobState `json:"state"`
Trigger string `json:"trigger"`
Full bool `json:"full"`
Attempt int `json:"attempt"`
CreatedAt time.Time `json:"createdAt"`
AttemptedAt *time.Time `json:"attemptedAt"`
}
IndexJob is an index job queued or running.
type IndexRun ¶
type IndexRun struct {
ID string `json:"id"`
Repository string `json:"repository"`
CommitSHA string `json:"commitSha"`
BaseSHA string `json:"baseSha"`
EmbedModel string `json:"embedModel"`
Mode string `json:"mode"`
Status store.IndexRunStatus `json:"status"`
Trigger string `json:"trigger"`
ChunkCount int `json:"chunkCount"`
Error string `json:"error"`
CreatedAt time.Time `json:"createdAt"`
FinishedAt *time.Time `json:"finishedAt"`
}
IndexRun is one index generation or step.
type IndexState ¶
type IndexState struct {
ActiveCommit string `json:"activeCommit"`
ActiveAt *time.Time `json:"activeAt"`
LastRunStatus store.IndexRunStatus `json:"lastRunStatus"`
LastRunAt *time.Time `json:"lastRunAt"`
// Job is the repository's index job queued or running, the running one
// when there are several. It is null when there is none.
Job *IndexJob `json:"job"`
// Backlog is the repository's place, from 1, among the account's
// repositories that wait for the onboarding feeder to queue their first
// index. The feeder keeps only a few of these indexes queued or running
// at once. Backlog is 0 when the repository is not waiting.
Backlog int `json:"backlog,omitzero"`
}
IndexState is a repository's embedding index: the active generation and the newest run. Empty strings and nulls mean none.
type InstanceJob ¶
InstanceJob is a job with the slug of the account it is of.
type InstancePull ¶
InstancePull identifies the account owning a pull in the global list.
type InstanceQueue ¶
type InstanceQueue struct {
Jobs []InstanceJob `json:"jobs"`
Slots []ModelSlots `json:"slots"`
}
InstanceQueue is the queue of every account the viewer can read: the jobs that have not finished, oldest first, then the most recently finished, and the model slots that say why a job waits.
type InstanceSetting ¶
type InstanceSetting struct {
Section string `json:"section"`
Key string `json:"key"`
Value string `json:"value"`
Source configfile.Source `json:"source"`
}
InstanceSetting is one instance-wide setting as the admin console shows it, read-only: its value, and whether it comes from this process's environment, the configuration file, the dashboard or a built-in default. A secret shows only whether it is set.
type Job ¶
type Job struct {
HeartbeatOverdue bool `json:"heartbeatOverdue,omitzero"`
RecentFailure bool `json:"recentFailure,omitzero"`
HeartbeatAt *time.Time `json:"heartbeatAt,omitzero"`
CancelableReviewID string `json:"cancelableReviewId,omitzero"`
ID int64 `json:"id"`
Kind string `json:"kind"`
State rivertype.JobState `json:"state"`
Attempt int `json:"attempt"`
MaxAttempts int `json:"maxAttempts"`
CreatedAt time.Time `json:"createdAt"`
ScheduledAt time.Time `json:"scheduledAt"`
AttemptedAt *time.Time `json:"attemptedAt"`
FinalizedAt *time.Time `json:"finalizedAt"`
Args JobArgs `json:"args"`
LastError string `json:"lastError"`
// Cause is why the last attempt failed, "" when the error does not say.
Cause JobCause `json:"cause"`
}
Job is one River job of the account.
type JobActions ¶
JobActions queues dashboard actions on River.
type JobArgs ¶
type JobArgs struct {
Repository string `json:"repository"`
Number int `json:"number"`
Head string `json:"head"`
Trigger string `json:"trigger"`
CommentID int64 `json:"commentId"`
Resolved *bool `json:"resolved,omitzero"`
}
JobArgs are the parts of a job's arguments that the queue shows. Fields that a kind does not carry are zero.
type JobCause ¶
type JobCause string
JobCause is why a job's last attempt failed, where kritika can tell from the error: what the dashboard says in place of the error's own text.
CauseForgeUnavailable is GitHub not answering a call, or answering it with a server error: nothing kritika or its admin can fix, and the job's next attempt can pass.
type Me ¶
type Me struct {
User User `json:"user"`
Admin bool `json:"admin"`
Accounts []string `json:"accounts"`
AccountHosts map[string]string `json:"accountHosts"`
Settings UserSettings `json:"settings"`
}
Me is who the session acts as: an admin, who reads and changes everything, or a member of Accounts, the slugs ("<forge>/<name>") of the accounts that it can read. AccountHosts is the host of the forge each of them is on, by slug: accounts of one name on two instances of a forge differ by it alone.
type Message ¶
type Message struct {
Role model.Role `json:"role"`
Text string `json:"text"`
ToolCalls []ToolCall `json:"toolCalls"`
ToolResults []ToolResult `json:"toolResults"`
}
Message is one request message.
type ModelSlots ¶
type ModelSlots struct {
Account string `json:"account"`
Model string `json:"model"`
Held int `json:"held"`
Slots int `json:"slots"`
}
ModelSlots is how many of an account's slots for a model are held by a running review. Slots is the concurrency of the model's provider.
type MonthUsage ¶
type MonthUsage struct {
Tokens int64 `json:"tokens"`
CostUSD float64 `json:"costUsd"`
UnpricedCalls int64 `json:"unpricedCalls,omitzero"`
TokensPerMonth int64 `json:"tokensPerMonth"`
ReviewsToday int64 `json:"reviewsToday"`
ReviewsPerDay int `json:"reviewsPerDay"`
Reviews int64 `json:"reviews"`
UnpricedReviews int64 `json:"unpricedReviews,omitzero"`
ReviewCostUSD float64 `json:"reviewCostUsd"`
MedianReviewCostUSD *float64 `json:"medianReviewCostUsd"`
}
MonthUsage is an account's usage against its caps (a zero cap is unset), and the reviews that completed this month: their cost together, and the median cost of one, null when none completed, both leaving out the unpriced reviews, whose cost is not known.
type Pull ¶
type Pull struct {
Repository string `json:"repository"`
Number int `json:"number"`
Title string `json:"title"`
Author string `json:"author"`
State string `json:"state"`
Draft bool `json:"draft"`
Fork bool `json:"fork"`
Merged bool `json:"merged"`
// Paused is whether its automatic reviews are paused: a push is
// recorded, not reviewed, until someone asks for a review or resumes
// them.
Paused bool `json:"paused"`
HeadSHA string `json:"headSha"`
HeadRef string `json:"headRef"`
BaseRef string `json:"baseRef"`
URL string `json:"url"`
OpenedAt *time.Time `json:"openedAt"`
UpdatedAt time.Time `json:"updatedAt"`
Labels []Label `json:"labels"`
LastReview *ReviewBrief `json:"lastReview"`
// ReviewCount is how many of its reviews completed. CostUSD is what all
// of them spent, the ones that did not complete included.
ReviewCount int `json:"reviewCount"`
CostUSD float64 `json:"costUsd"`
UnpricedCalls int64 `json:"unpricedCalls,omitzero"`
}
Pull is one pull request.
type PullDetail ¶
type PullDetail struct {
Pull Pull `json:"pull"`
Reviews []Review `json:"reviews"`
Followups []Followup `json:"followups"`
Job *Job `json:"job"`
}
PullDetail is a pull request with every review and follow-up. Job is its review job that is not finished, nil when there is none. A review row only exists once a job got as far as starting the review. So a job that waits or keeps failing before that shows nowhere else.
type PullRef ¶
type PullRef struct {
Repository string `json:"repository"`
Number int `json:"number"`
Title string `json:"title"`
URL string `json:"url"`
}
PullRef names a pull request, and where it is on the forge.
type RegisterResult ¶
type RegisterResult struct {
Added int `json:"added"`
}
RegisterResult is how many repositories a registration added.
type RepoActivity ¶
type RepoActivity struct {
Repository string `json:"repository"`
// Account is set in the instance's list, where a row can be any readable
// account's.
Account string `json:"account,omitzero"`
Reviews int `json:"reviews"`
Findings SeverityCounts `json:"findings"`
Addressed int `json:"addressed"`
}
RepoActivity is what one repository's reviews came to over the window.
type RepoConfig ¶
type RepoConfig struct {
ReviewID string `json:"reviewId"`
// Commit is the merge base the review read the file at.
Commit string `json:"commit"`
// Found is false when there was no file there.
Found bool `json:"found"`
// Settings are the repository's configuration with the file applied.
Settings RepoSettings `json:"settings"`
// Filters are the file's own conditions, passed beside the admin's.
Filters configfile.Filters `json:"filters"`
// Dropped are the file's values outside the admin's bounds. The admin's
// value applies for each.
Dropped []string `json:"dropped"`
// Ignored is why the file was ignored as a whole, when it was.
Ignored string `json:"ignored,omitempty"`
}
RepoConfig is the repository's .kritika.yaml as the last review that ran read it, applied to the admin's configuration as it is now.
type RepoDetail ¶
type RepoDetail struct {
Repository
Settings RepoSettings `json:"settings"`
Sources map[string]configfile.Source `json:"sources"`
RepoConfig *RepoConfig `json:"repoConfig"`
IndexRuns []IndexRun `json:"indexRuns"`
// IndexJobs are the repository's index jobs queued or running, the
// running ones first.
IndexJobs []IndexJob `json:"indexJobs"`
}
RepoDetail is one repository, its configuration and recent index runs. Sources says, by the policy table's keys, which layer each value of the admin's configuration comes from: the defaults, the account (its entry or the repository's entry in it) or kritika's default. RepoConfig is null until a review reads the repository's .kritika.yaml.
type RepoSettings ¶
type RepoSettings struct {
Enabled bool `json:"enabled"`
Models configfile.Models `json:"models"`
Filters configfile.Filters `json:"filters"`
Ignore []string `json:"ignore"`
MaxAutoReviews int `json:"maxAutoReviews"`
MaxDeltaFiles int `json:"maxDeltaFiles"`
Review configfile.Review `json:"review"`
Confidence configfile.Confidence `json:"confidence"`
Skills configfile.Skills `json:"skills"`
Agent configfile.AgentSettings `json:"agent"`
Limits configfile.Limits `json:"limits"`
}
RepoSettings is a repository's configuration as it resolves: the admin's, or with the in-repo .kritika.yaml applied (RepoConfig). The blocks are the configuration's own resolved types. Durations are served in whole seconds.
type Repository ¶
type Repository struct {
ID string `json:"id"`
FullName string `json:"fullName"`
Enabled bool `json:"enabled"`
DefaultBranch string `json:"defaultBranch"`
Archived bool `json:"archived"`
Fork bool `json:"fork"`
// Visibility is public, private or internal as GitHub reports it, ""
// until it has.
Visibility string `json:"visibility"`
// TurnedOn starts false for discovered repositories, then follows the
// admin's choice. A null value lets the configuration decide whether it
// runs.
TurnedOn *bool `json:"turnedOn"`
Index IndexState `json:"index"`
LastReview *ReviewRef `json:"lastReview"`
}
Repository is one row of the repository list.
type Response ¶
type Response struct {
Text string `json:"text"`
ToolCalls []ToolCall `json:"toolCalls"`
Stop model.StopReason `json:"stop"`
}
Response is what the model answered.
type Resync ¶
type Resync struct {
// Entry is the path of the dashboard's entry script, as the build
// manifest names it, "" when the server serves a UI built without one.
// A tab that booted from another script runs another build of the
// dashboard, and reloads instead.
Entry string `json:"entry"`
}
Resync is the data of the resync event, which opens every stream and stands for events the client missed: it refetches everything it shows.
type Review ¶
type Review struct {
ID string `json:"id"`
Status store.ReviewStatus `json:"status"`
Trigger string `json:"trigger"`
Scope review.Scope `json:"scope"`
Model string `json:"model"`
HeadSHA string `json:"headSha"`
CostUSD float64 `json:"costUsd"`
UnpricedCalls int64 `json:"unpricedCalls,omitzero"`
Calls int64 `json:"calls,omitzero"`
PlanCalls int64 `json:"planCalls,omitzero"`
Tokens TokenCounts `json:"tokens"`
DurationMs *int64 `json:"durationMs"`
CreatedAt time.Time `json:"createdAt"`
FinishedAt *time.Time `json:"finishedAt"`
// SkipReason is why a skipped review was: disabled, filtered or
// only_skipped_paths from the repository's configuration, or the
// runner's unchanged_patch or too_large.
SkipReason string `json:"skipReason"`
Error string `json:"error"`
// Confidence is null for a review that was not scored.
Confidence *Confidence `json:"confidence"`
}
Review is one review pass as lists show it. DurationMs is null while the review runs.
type ReviewBrief ¶
type ReviewBrief struct {
ID string `json:"id"`
Status store.ReviewStatus `json:"status"`
Scope review.Scope `json:"scope"`
Findings SeverityCounts `json:"findings"`
CreatedAt time.Time `json:"createdAt"`
}
ReviewBrief is a pull request's newest review.
type ReviewDetail ¶
type ReviewDetail struct {
Review ReviewInfo `json:"review"`
Summary *Summary `json:"summary"`
Findings []Finding `json:"findings"`
RunnerRun *RunnerRun `json:"runnerRun"`
AgentRun *AgentRun `json:"agentRun"`
Usage []UsageRow `json:"usage"`
ContextPack *ContextPack `json:"contextPack"`
}
ReviewDetail is everything recorded about one review but its bodies.
type ReviewDiff ¶
type ReviewDiff struct {
Pending bool `json:"pending,omitzero"`
Diff string `json:"diff"`
DeltaDiff string `json:"deltaDiff"`
Swept bool `json:"swept"`
}
ReviewDiff is a review's diff and, for an incremental one, the diff since the prior review's head. Swept says that the retention sweep emptied both. Pending means that an active review did not write its pack yet.
type ReviewInfo ¶
type ReviewInfo struct {
Review
Pull PullRef `json:"pull"`
// PullState is open or closed, and PullMerged whether it was merged: a
// merged or closed pull request takes no more reviews.
PullState string `json:"pullState"`
PullMerged bool `json:"pullMerged"`
ScopeReason string `json:"scopeReason"`
MergeBaseSHA string `json:"mergeBaseSha"`
PatchID string `json:"patchId"`
PriorReviewID *string `json:"priorReviewId"`
// NewestReviewID is the pull request's newest review that was not
// skipped, null when none is newer than this.
NewestReviewID *string `json:"newestReviewId"`
CancelRequestedAt *time.Time `json:"cancelRequestedAt"`
// ReplacedByReviewID is the newer review whose start canceled this
// one, null for a review that ended any other way.
ReplacedByReviewID *string `json:"replacedByReviewId"`
}
ReviewInfo is a review row in full.
type ReviewRaw ¶
type ReviewRaw struct {
RepoFiles map[string]string `json:"repoFiles"`
Stages []ContextChunk `json:"stages"`
Result json.RawMessage `json:"result"`
LogTail string `json:"logTail"`
}
ReviewRaw is the review's inputs and output as stored: the repository files and context that the runner gathered, the agent's submitted review, and the runner's log tail. The submitted review is null for a review that did not submit one.
type ReviewRef ¶
type ReviewRef struct {
ID string `json:"id"`
Status store.ReviewStatus `json:"status"`
CreatedAt time.Time `json:"createdAt"`
}
ReviewRef is a review's id, status and start.
type Rule ¶
type Rule struct {
Kind RuleKind `json:"kind"`
ID string `json:"id"`
Text string `json:"text"`
Path string `json:"path"`
Description string `json:"description"`
Paths []string `json:"paths"`
When []configfile.When `json:"when"`
Source RuleSource `json:"source"`
Repositories []string `json:"repositories"`
Findings int `json:"findings"`
Addressed int `json:"addressed"`
Dismissed int `json:"dismissed"`
Downvoted int `json:"downvoted"`
}
Rule is one written rule or file that reviews read. It has where it is set, the paths it applies to (every change when empty), and the running repositories whose reviews read it.
ID is a written rule's, with its Text or, for a file rule, its Path. A written rule also has WhenExpr, the CEL expression over the pull request. The rule applies only when WhenExpr is true of the pull request. Path and Description are a context file's.
Findings, Addressed, Dismissed and Downvoted are a written rule's too. Findings is its repositories' findings that cite its id, once per pull request as the findings list counts them. The other three are how many of those were addressed, dismissed, or drew a 👎 on their comment.
type RuleKind ¶
type RuleKind string
RuleKind is what a rule is to a review: a check written in the configuration, as text or a file, or a context file that explains the code.
type RuleSource ¶
type RuleSource string
RuleSource is where a rule is set: a layer of the configuration, as configfile.Source names it, or RuleFromRepository, the repository's own .kritika.yaml.
const RuleFromRepository RuleSource = "repository"
RuleFromRepository is the rule source beyond the configuration's layers.
type RunnerRun ¶
type RunnerRun struct {
ID string `json:"id"`
Phase string `json:"phase"`
JobName string `json:"jobName"`
PodName string `json:"podName"`
NodeName string `json:"nodeName"`
CreatedAt time.Time `json:"createdAt"`
ScheduledAt *time.Time `json:"scheduledAt"`
StartedAt *time.Time `json:"startedAt"`
FinishedAt *time.Time `json:"finishedAt"`
HeartbeatAt *time.Time `json:"heartbeatAt"`
ExitCode *int `json:"exitCode"`
TerminationReason string `json:"terminationReason"`
DeadlineExceeded bool `json:"deadlineExceeded"`
Error string `json:"error"`
LogTail string `json:"logTail"`
}
RunnerRun is the Kubernetes Job that prepared a review.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves the dashboard.
func (*Server) Run ¶
Run feeds the event stream from the store's notifications until ctx ends. The web process runs exactly one, however many streams it serves. When it returns, every open stream ends too. So a browser reconnects to a replica that is still listening, and does not wait on one that is shutting down.
type SetupStatus ¶
type SetupStatus struct {
// WebURL is the dashboard's URL, and HooksURL where each connection's
// webhook goes, its name appended.
WebURL string `json:"webUrl"`
HooksURL string `json:"hooksUrl"`
// Connections are the running connections.
Connections []string `json:"connections"`
// ReviewModel is defaults.models.review, which validation holds to a
// model that an instance provider serves. It is "" when unset.
ReviewModel string `json:"reviewModel"`
// Embedding is whether an embedder is set.
Embedding bool `json:"embedding"`
}
SetupStatus is how far the instance is from reviewing, what the Configuration page's checklist shows.
type SeverityCounts ¶
SeverityCounts counts findings by severity.
type Stage ¶
type Stage struct {
Stage string `json:"stage"`
Path string `json:"path"`
Language string `json:"language"`
Symbol string `json:"symbol"`
Kind string `json:"kind"`
Scope string `json:"scope"`
StartLine int `json:"startLine"`
EndLine int `json:"endLine"`
Ref string `json:"ref"`
Bytes int `json:"bytes"`
}
Stage is one context chunk without its text.
type Summary ¶
type Summary struct {
Headline string `json:"headline,omitempty"`
Take string `json:"take"`
Praise []string `json:"praise"`
Diagram string `json:"diagram,omitempty"`
}
Summary is a review's overall take and praise. Diagram is the Mermaid source of its flow diagram, "" when the review drew none.
type TimelineStep ¶
type TimelineStep struct {
Index int `json:"index"`
Part int `json:"part"`
Tools []string `json:"tools"`
DurationMs int64 `json:"durationMs"`
OutputBytes int `json:"outputBytes"`
InputTokens int64 `json:"inputTokens"`
OutputTokens int64 `json:"outputTokens"`
}
TimelineStep is one agent step. Part is the part of a split review that it was for, from 1. It is 0 when the review was not split.
type TokenCounts ¶
TokenCounts are input and output tokens.
type TokenStatus ¶
type TokenStatus string
TokenStatus is whether a token still reads: it stops at its expiry, and goes stale when the sign-in configuration it came from changes, as a session ends.
const ( TokenActive TokenStatus = "active" TokenExpired TokenStatus = "expired" TokenStale TokenStatus = "stale" )
Token statuses.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Input json.RawMessage `json:"input"`
}
ToolCall is a tool call a model made.
type ToolDef ¶
type ToolDef struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema json.RawMessage `json:"inputSchema"`
}
ToolDef is a tool a model was offered.
type ToolExecution ¶
ToolExecution counts starts of one command, across versions and providers.
type ToolResult ¶
type ToolResult struct {
CallID string `json:"callId"`
Content string `json:"content"`
IsError bool `json:"isError"`
TruncatedBytes int `json:"truncatedBytes"`
}
ToolResult is what a tool call returned.
type ToolUsage ¶
type ToolUsage struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
RecordedRuns int64 `json:"recordedRuns"`
TotalExecutions int64 `json:"totalExecutions"`
Tools []ToolExecution `json:"tools"`
}
ToolUsage ranks commands across the instance's currently served accounts.
type Transcript ¶
type Transcript struct {
System string `json:"system"`
Tools []ToolDef `json:"tools"`
Turns []Turn `json:"turns"`
}
Transcript is a set of model calls: the system prompt and tools the first carried, then one turn per call.
type Turn ¶
type Turn struct {
Index int `json:"index"`
ID string `json:"id"`
Kind transcript.Kind `json:"kind"`
Step int `json:"step"`
// Part is the part of a split review that the call stepped for, from 1.
// It is 0 when the review was not split.
Part int `json:"part"`
Model string `json:"model"`
Upstream string `json:"upstream"`
System *string `json:"system"`
Tools *[]ToolDef `json:"tools"`
Reset bool `json:"reset"`
MessagesFrom int `json:"messagesFrom"`
Messages []Message `json:"messages"`
Response Response `json:"response"`
Usage Usage `json:"usage"`
CostUSD float64 `json:"costUsd"`
ChatGPTPlan bool `json:"chatgptPlan,omitzero"`
Unpriced bool `json:"unpriced,omitzero"`
DurationMs int64 `json:"durationMs"`
Error string `json:"error"`
Truncated bool `json:"truncated"`
CreatedAt time.Time `json:"createdAt"`
RunnerRunID string `json:"runnerRunId"`
// CarriedReviewID is the review whose conversation holds the messages
// before MessagesFrom, nil when they are earlier turns here.
CarriedReviewID *string `json:"carriedReviewId"`
}
Turn is one model call: the messages new in its request from index MessagesFrom, and the answer. System and Tools are set when the call changed them from its part's call before. At a part's first call, they are set when the call changed them from the conversation's. They are null otherwise. Reset says that Messages is the whole request.
type TurnOnRequest ¶
type TurnOnRequest struct {
On bool `json:"on"`
}
TurnOnRequest turns a repository on, or off.
type Usage ¶
type Usage struct {
Input int64 `json:"input"`
CacheRead int64 `json:"cacheRead"`
CacheWrite int64 `json:"cacheWrite"`
Output int64 `json:"output"`
}
Usage counts one or more model calls' tokens.
type UsagePoint ¶
type UsagePoint struct {
Key string `json:"key"`
// Account is set in the instance's series for keys of one account:
// a review run, or the account itself when grouped by account.
Account string `json:"account,omitzero"`
InputTokens int64 `json:"inputTokens"`
CacheReadTokens int64 `json:"cacheReadTokens"`
CacheWriteTokens int64 `json:"cacheWriteTokens"`
OutputTokens int64 `json:"outputTokens"`
CostUSD float64 `json:"costUsd"`
UnpricedCalls int64 `json:"unpricedCalls,omitzero"`
Calls int64 `json:"calls"`
PlanCalls int64 `json:"planCalls,omitzero"`
}
UsagePoint is one key of a usage series.
type UsageRow ¶
type UsageRow struct {
RunnerRunID string `json:"runnerRunId,omitzero"`
Role string `json:"role"`
Model string `json:"model"`
Upstream string `json:"upstream"`
InputTokens int64 `json:"inputTokens"`
OutputTokens int64 `json:"outputTokens"`
CostUSD float64 `json:"costUsd"`
ChatGPTPlan bool `json:"chatgptPlan,omitzero"`
Unpriced bool `json:"unpriced,omitzero"`
CreatedAt time.Time `json:"createdAt"`
}
UsageRow is one usage row charged to a review.
type UsageSeries ¶
type UsageSeries struct {
Group store.UsageGroup `json:"group"`
From time.Time `json:"from"`
To time.Time `json:"to"`
Rows []UsagePoint `json:"rows"`
// Previous uses the same filters over the preceding window of equal
// length. Time and review groups return one total. Named groups return
// per-key comparisons. Cache detail is omitted.
Previous []UsagePoint `json:"previous"`
}
UsageSeries is the account's usage in [From, To) grouped by Group.
type User ¶
type User struct {
ID string `json:"id"`
DisplayName string `json:"displayName"`
Email string `json:"email"`
AvatarURL string `json:"avatarUrl"`
}
User is the signed-in human.
type UserAccess ¶
type UserAccess struct {
Admin bool `json:"admin"`
AllAccounts bool `json:"allAccounts"`
Accounts []string `json:"accounts"`
}
UserAccess is what a session lets its user read: everything as an admin, every account, or the slugs of Accounts.
type UserSettings ¶
type UserSettings struct {
TimeZone string `json:"timeZone"`
Clock string `json:"clock"`
Theme string `json:"theme"`
}
UserSettings is what a user chose for their own dashboard. An empty field leaves the choice to the browser. TimeZone is an IANA zone name, Clock "12" or "24", Theme "light" or "dark".
type UserSignIn ¶
UserSignIn is one of a user's sign-ins: the provider, as the configuration names its type, and the login it knows them by.
Source Files
¶
- actions.go
- actions_jobs.go
- audit.go
- connections.go
- cursor.go
- errors.go
- hub.go
- job_cause.go
- mcp.go
- request.go
- routes_analytics.go
- routes_chatgpt.go
- routes_findings.go
- routes_index.go
- routes_instance_series.go
- routes_pulls.go
- routes_read.go
- routes_reviews.go
- routes_rules.go
- routes_tools.go
- routes_usage.go
- scope.go
- server.go
- setup.go
- tokens.go
- types.go
- types_analytics.go
- types_findings.go
- types_manage.go
- types_pulls.go
- types_queue.go
- types_reviews.go
- types_rules.go
- types_tokens.go
- types_transcript.go
- types_usage.go
- types_users.go
- users.go