api

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 16 Imported by: ? 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

Index

Constants

View Source
const (
	// DefaultBaseURL is the production Entire API origin.
	DefaultBaseURL = "https://entire.io"

	// DefaultAuthBaseURL is the production Entire login server — the
	// default for `entire login --server`.
	//
	// This apex host is a dispatcher, not a token issuer: it redirects
	// /authorize and /device_authorization to the caller's regional login
	// server (e.g. https://us.auth.entire.io) and serves no token endpoint,
	// no discovery document, and no JWKS. Tokens are always minted by a
	// region, with iss and aud set to that region's host — which is what
	// gets persisted as a context's CoreURL and is the target of every
	// later refresh and RFC 8693 exchange.
	DefaultAuthBaseURL = "https://auth.entire.io"

	// BaseURLEnvVar overrides the Entire API origin for local development.
	BaseURLEnvVar = "ENTIRE_API_BASE_URL"

	// DefaultWebBaseURL is the production Entire web app origin. Browser
	// links point here; API calls stay on DefaultBaseURL.
	DefaultWebBaseURL = "https://entire.com"

	// WebBaseURLEnvVar overrides the web app origin used for browser links,
	// e.g. a local frontend on its own port during development.
	WebBaseURLEnvVar = "ENTIRE_WEB_BASE_URL"

	// AuthBaseURLEnvVar is the retired auth-origin override. Nothing reads
	// its value — RejectRemovedAuthEnv fails every command when it is set,
	// pointing at `entire login --server`.
	AuthBaseURLEnvVar = "ENTIRE_AUTH_BASE_URL"
)
View Source
const (
	TrailChecksAvailable     = "available"
	TrailChecksUnavailable   = "unavailable"
	TrailChecksNotApplicable = "not_applicable"
)

TrailChecks.Availability values. Runs are meaningful only when available.

Variables

View Source
var ErrInsecureHTTP = errors.New("refusing to use insecure http:// base URL for authentication (use --insecure-http-auth to override)")

ErrInsecureHTTP is returned when the base URL uses HTTP without an explicit opt-in.

Functions

func BaseURL

func BaseURL() string

BaseURL returns the effective Entire API base URL. ENTIRE_API_BASE_URL takes precedence over the production default.

func BaseURLOverride added in v0.11.0

func BaseURLOverride() (string, bool)

BaseURLOverride returns the normalized ENTIRE_API_BASE_URL and true when the user pointed the CLI at an explicit data host, or ("", false) when BaseURL() would fall back to the production default. See auth.resolveCellClientSubject for a caller that must tell the two apart.

func CheckResponse added in v0.5.2

func CheckResponse(resp *http.Response) error

CheckResponse returns an error if the response status code indicates failure. For non-2xx responses, it reads and parses the error message from the body and returns it as an *HTTPError. The caller is responsible for closing resp.Body.

func DecodeJSON added in v0.5.2

func DecodeJSON(resp *http.Response, dest any) error

DecodeJSON reads the response body and decodes it into dest. It limits the body size to protect against unbounded reads. The caller is responsible for closing resp.Body.

func IsHTTPErrorStatus added in v0.6.0

func IsHTTPErrorStatus(err error, status int) bool

IsHTTPErrorStatus reports whether err wraps an *HTTPError with the given HTTP status.

func ListProjectConfig added in v0.13.0

func ListProjectConfig[T any](ctx context.Context, c *Client, path string, query url.Values) ([]T, error)

ListProjectConfig reads every page of a project configuration list. query holds the list's filters; the cursor is added per page.

func NormalizeOriginURL added in v0.6.3

func NormalizeOriginURL(raw string) string

NormalizeOriginURL canonicalises an origin URL the same way auth-go's tokenmanager does internally: lowercase scheme/host, default port stripped (80 for http, 443 for https), path/query/fragment dropped, trailing slash collapsed. On parse failure, raw is returned unchanged so non-URL audience values still compare byte-for-byte.

Mirrors auth-go's internal/oauthhttp.NormalizeOriginURL so the value the CLI hands to the manager as Issuer survives the manager's own normalisation pass byte-for-byte; a cosmetically-different origin (uppercase host, explicit :443, trailing slash) would otherwise be keyed under a different keyring slot than the manager later reads.

func OriginOnly added in v0.6.3

func OriginOnly(raw string) string

OriginOnly is a backwards-compatible alias for NormalizeOriginURL. Callers reading raw URLs (e.g. ENTIRE_API_BASE_URL) and feeding them into tokenmanager.TokenRequest.Resource use this to strip path/query/fragment before the lib's stricter origin-only validator runs.

func RawJSONAbsent added in v0.13.0

func RawJSONAbsent(raw json.RawMessage) bool

RawJSONAbsent reports a detail-only field the read did not carry: missing or null.

func RejectRemovedAuthEnv added in v0.7.6

func RejectRemovedAuthEnv() error

RejectRemovedAuthEnv returns an error when ENTIRE_AUTH_BASE_URL is set at all (even empty). The variable is retired in favour of `entire login --server`; failing loudly beats silently ignoring an override the operator believes is in effect.

func RepoChangesPath added in v0.13.3

func RepoChangesPath(repoID string) (string, error)

RepoChangesPath returns the Changes collection route for a resolved repository ID.

func RequireSecureURL

func RequireSecureURL(baseURL string) error

RequireSecureURL returns ErrInsecureHTTP if the base URL uses the http scheme. Call this before making authenticated requests unless --insecure-http-auth is set.

func ResolveURLFromBase

func ResolveURLFromBase(baseURL, path string) (string, error)

ResolveURLFromBase joins an API-relative path against an explicit base URL. Only http and https schemes are accepted.

func WebBaseURLOverride added in v0.12.0

func WebBaseURLOverride() (string, bool)

WebBaseURLOverride returns the normalized ENTIRE_WEB_BASE_URL and true when set, or ("", false) when browser links should follow the data host's site.

Types

type AgentRun added in v0.13.0

type AgentRun struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Agent  struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"agent"`
}

AgentRun is the run an agent run request started, as far as the CLI reports it.

type AgentRunRequest added in v0.13.0

type AgentRunRequest struct {
	Target AgentRunTarget `json:"target"`
}

AgentRunRequest is POST /{host}/{project}/agents/{id}/runs: one run of the agent on one change of a project trail.

type AgentRunTarget added in v0.13.0

type AgentRunTarget struct {
	TrailID  string `json:"trail_id"`
	ChangeID string `json:"change_id"`
}

AgentRunTarget names the change a run reviews; the change's repository is the run's.

type AuthSession added in v0.7.4

type AuthSession struct {
	ID     string `json:"id"`
	UserID string `json:"user_id"`
	Name   string `json:"name"`
	// Scope is "cli", "web" or "system"; ClientID is the raw OAuth client.
	Scope      string  `json:"scope"`
	ClientID   string  `json:"client_id"`
	ExpiresAt  string  `json:"expires_at"`
	LastUsedAt *string `json:"last_used_at"`
	CreatedAt  string  `json:"created_at"`
}

AuthSession is a single active login session — an OAuth refresh-token family — returned by entire-core's session endpoint. One is created per `entire login`, across all of a user's devices. Plaintext token values are never returned by the server, only metadata. (The list envelope's wire key is "tokens"; the rows are sessions.)

type AuthSessionsResponse added in v0.7.4

type AuthSessionsResponse struct {
	Sessions []AuthSession `json:"tokens"`
}

AuthSessionsResponse is the envelope returned by the list endpoint.

type ChangeCreateRequest added in v0.11.5

type ChangeCreateRequest struct {
	RepositoryID string `json:"repositoryId"`
	Title        string `json:"title"`
	BranchName   string `json:"branchName,omitempty"`
	BranchAction string `json:"branchAction,omitempty"`
	Base         string `json:"base,omitempty"`
	Status       string `json:"status,omitempty"`
}

ChangeCreateRequest places a branch: its title is the branch name, and the description, type, priority, and assignees belong to the project trail.

type ChangeCreateResponse added in v0.11.5

type ChangeCreateResponse struct {
	ID           string `json:"id"`
	TrailID      string `json:"trailId"`
	RepositoryID string `json:"repositoryId"`
}

type ChangeResource added in v0.11.5

type ChangeResource struct {
	TrailResource

	TrailID      string `json:"trailId"`
	RepositoryID string `json:"repositoryId"`
}

ChangeResource is a repository Change read through its owning project trail: the branch-backed TrailResource plus the containment that route asserts.

type ChangeSummary added in v0.11.5

type ChangeSummary struct {
	ID           string `json:"id"`
	RepositoryID string `json:"repositoryId"`
	Repository   string `json:"repository"`
	Branch       string `json:"branch"`
	// Base is the branch the change merges into; empty from a server that
	// does not report it.
	Base           string    `json:"base,omitempty"`
	Number         int       `json:"number"`
	Title          string    `json:"title"`
	Status         string    `json:"status"`
	HasCodeChanges bool      `json:"hasCodeChanges"`
	CreatedAt      time.Time `json:"createdAt"`
	UpdatedAt      time.Time `json:"updatedAt"`
}

type Client added in v0.5.2

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

Client is an authenticated HTTP client for the Entire API. It attaches the bearer token to all outgoing requests via the Authorization header.

func NewClientWithBaseURL added in v0.6.3

func NewClientWithBaseURL(token, baseURL string) *Client

NewClientWithBaseURL creates a new authenticated API client targeting an explicit base URL.

Both constructors require the base URL. Their predecessor, NewClient(token), defaulted the host to BaseURL() — ENTIRE_API_BASE_URL or the production apex — which is exactly the ambient default the data plane no longer has: the host belongs to the acting login and comes from auth.ResolveDataAPI / auth.DataBaseURL. Keeping a one-argument constructor around would let the next caller reintroduce that silently, sending a staging login's bearer to entire.io, so the base URL is a required argument and every caller has to say where it got it.

func NewClientWithTokenSource added in v0.13.2

func NewClientWithTokenSource(source TokenSource, baseURL string) *Client

NewClientWithTokenSource is NewClientWithBaseURL with a bearer resolved per request from source instead of fixed at construction.

func NewClientWithTransport added in v0.11.5

func NewClientWithTransport(token, baseURL string, transport http.RoundTripper) *Client

NewClientWithTransport creates an API client using an injected network transport, retaining the standard bearer and redirect policies. A nil transport uses http.DefaultTransport. The transport must not rewrite the request URL: the redirect policy only sees the URL it was given, so a scheme rewrite beneath it would hide a downgrade.

func (*Client) BaseURL added in v0.13.2

func (c *Client) BaseURL() string

BaseURL returns the origin the client sends requests to.

func (*Client) CreateProjectConfig added in v0.13.0

func (c *Client) CreateProjectConfig(ctx context.Context, path string, body, out any) error

CreateProjectConfig POSTs a configuration create. The API requires an Idempotency-Key on every create: a retry with the same key and body returns what the first attempt saved instead of saving another. Each call is one logical create, so it gets a fresh key.

func (*Client) Delete added in v0.5.2

func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)

Delete sends an authenticated DELETE request to the given API-relative path.

func (*Client) Get added in v0.5.2

func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)

Get sends an authenticated GET request to the given API-relative path.

func (*Client) GetStream added in v0.6.2

func (c *Client) GetStream(ctx context.Context, path string, headers http.Header) (*http.Response, error)

GetStream sends an authenticated GET request with optional extra request headers (e.g. Accept: text/event-stream, Last-Event-ID) and returns the response with the body still open. Callers are responsible for reading and closing resp.Body. Intended for streaming endpoints such as Server-Sent Events; for normal JSON requests use Get.

func (*Client) ListAuthSessions added in v0.7.4

func (c *Client) ListAuthSessions(ctx context.Context) ([]AuthSession, error)

ListAuthSessions returns the authenticated user's active login sessions.

func (*Client) Patch added in v0.5.2

func (c *Client) Patch(ctx context.Context, path string, body any) (*http.Response, error)

Patch sends an authenticated PATCH request with a JSON body to the given API-relative path.

func (*Client) Post added in v0.5.2

func (c *Client) Post(ctx context.Context, path string, body any) (*http.Response, error)

Post sends an authenticated POST request with a JSON body to the given API-relative path.

func (*Client) ProjectConfigRequest added in v0.13.0

func (c *Client) ProjectConfigRequest(ctx context.Context, method, path string, headers http.Header, body, out any) error

ProjectConfigRequest sends one request to a project configuration route (agents, environments, presets) and decodes the response into out. headers carry the write preconditions: If-Match on a replace (the etag write token of the last read), Idempotency-Key on a create (see CreateProjectConfig).

func (*Client) ProjectTrailRequest added in v0.11.5

func (c *Client) ProjectTrailRequest(ctx context.Context, method, path string, body any, headers http.Header, out any) (string, error)

ProjectTrailRequest decodes the unwrapped project API response and preserves the HTTP ETag (timestamp text in the body loses precision). It never retries writes or downgrades a failed conditional write to an unconditional one.

func (*Client) Put added in v0.5.2

func (c *Client) Put(ctx context.Context, path string, body any) (*http.Response, error)

Put sends an authenticated PUT request with a JSON body to the given API-relative path.

func (*Client) ReplaceProjectConfig added in v0.13.0

func (c *Client) ReplaceProjectConfig(ctx context.Context, path, etag string, body, out any) error

ReplaceProjectConfig PUTs a configuration replace under the etag of the last read; a stale etag is refused rather than overwriting a newer version.

func (*Client) RepoTrailsEnabled added in v0.13.0

func (c *Client) RepoTrailsEnabled(ctx context.Context, repoID string) (enabled, known bool, err error)

RepoTrailsEnabled reads a repository's Trails setting from the cell that holds it (GET /api/v1/repos/{repo_id}). known is false when the response carries no setting, so callers can tell "off" from "not reported".

func (*Client) Request added in v0.8.0

func (c *Client) Request(ctx context.Context, method, path string, headers http.Header, body io.Reader) (*http.Response, error)

Request sends an authenticated request with an explicit method, optional extra headers, and an optional raw body. It's the general-purpose escape hatch behind `entire api`; prefer the typed verbs (Get/Post/…) for normal use. The bearer, User-Agent, and default Accept are still attached by the transport; a body defaults to Content-Type: application/json unless the caller supplies its own via headers.

func (*Client) RevokeAllAuthSessions added in v0.11.0

func (c *Client) RevokeAllAuthSessions(ctx context.Context) error

RevokeAllAuthSessions revokes every session of the authenticated user, browser and web included (DELETE on the collection with scope=all). A login server that predates the endpoint answers 404 or 405; callers fall back to list + revoke by id.

func (*Client) RevokeAuthSession added in v0.7.4

func (c *Client) RevokeAuthSession(ctx context.Context, id string) error

RevokeAuthSession revokes the login session with the given id.

func (*Client) RevokeCLIAuthSessions added in v0.11.0

func (c *Client) RevokeCLIAuthSessions(ctx context.Context) error

RevokeCLIAuthSessions revokes every CLI login session of the authenticated user, on every machine, in one call (DELETE on the collection). Browser and web sessions stay. A login server that predates the endpoint answers 404 or 405.

func (*Client) RevokeCurrentAuthSession added in v0.7.4

func (c *Client) RevokeCurrentAuthSession(ctx context.Context) error

RevokeCurrentAuthSession revokes the login session this client is authenticating with (the family the current bearer belongs to).

func (*Client) SetTrailRoute added in v0.10.1

func (c *Client) SetTrailRoute(trailID, path string)

SetTrailRoute registers the entire-api base path for a resolved trail, so later requests spelled with the trail's ID are rewritten onto its /api/v1/repos/{repo_id}/changes/{number} route (see rewriteTrailRoute). The ID-based paths are internal rewrite keys, not outgoing wire routes.

func (*Client) TrailsEnabled added in v0.7.7

func (c *Client) TrailsEnabled(ctx context.Context, repoID string) (bool, error)

TrailsEnabled probes trail availability: 2xx=true, 403/404/410=false, everything else ambiguous.

func (*Client) WithAuthSessionsPath added in v0.7.4

func (c *Client) WithAuthSessionsPath(path string) *Client

WithAuthSessionsPath sets the base path used by ListAuthSessions, RevokeCurrentAuthSession, and RevokeAuthSession. Returns the receiver for chaining at construction:

c := api.NewClientWithBaseURL(token, base).WithAuthSessionsPath(p)

type ErrorResponse added in v0.5.2

type ErrorResponse struct {
	Error     any    `json:"error"`
	Detail    string `json:"detail"`
	Title     string `json:"title"`
	Code      string `json:"code"`
	RequestID string `json:"request_id"`
}

ErrorResponse represents a standard API error response. Older endpoints return {"error":"message"}; newer endpoints return {"error":{"code":"...","message":"...",...}}; entire-api cells return RFC 9457 problem details (application/problem+json), whose human-readable text is detail with title as the coarser fallback. RequestID is a problem-details extension entire-api sets on every error; it is what support needs to find the server-side trace, so it is carried through to HTTPError.

func (ErrorResponse) ErrorCode added in v0.11.1

func (e ErrorResponse) ErrorCode() string

ErrorCode extracts the stable machine-readable code, if the server sent one. entire-api's contract (docs/api-errors.md there) is to branch on code, never on message text: problem details and compact cell errors carry it top-level; the legacy nested envelope carries it as error.code.

func (ErrorResponse) Message added in v0.6.3

func (e ErrorResponse) Message() string

Message extracts the human-readable error message from any envelope shape.

type HTTPError added in v0.6.0

type HTTPError struct {
	StatusCode int
	Message    string
	// Code is the server's stable error code (e.g. rate_limited, conflict,
	// wrong_cell) when it sent one. Branch on it, not on Message, which is
	// human-readable prose the server may reword.
	Code string
	// RequestID is the RFC 9457 request_id extension when the server sent one.
	RequestID string
}

HTTPError is returned by CheckResponse for non-2xx responses. Callers can use errors.As to inspect the HTTP status, or IsHTTPErrorStatus for a quick check.

func (*HTTPError) Error added in v0.6.0

func (e *HTTPError) Error() string

type ProjectAgent added in v0.13.0

type ProjectAgent struct {
	ProjectAgentDefinition

	ID            string                 `json:"id"`
	ProjectID     string                 `json:"project_id"`
	Version       int64                  `json:"version"`
	ETag          string                 `json:"etag"`
	Preset        *ProjectAgentPresetRef `json:"preset"`
	IsEnabled     bool                   `json:"is_enabled"`
	EnvironmentID string                 `json:"environment_id"`
	RepositoryIDs []string               `json:"repository_ids"`
	Triggers      []ProjectAgentTrigger  `json:"triggers"`
	// StaleRepositoryIDs are selected repositories the project no longer
	// owns. A write that keeps one is refused.
	StaleRepositoryIDs []string   `json:"stale_repository_ids"`
	ArchivedAt         *time.Time `json:"archived_at"`
}

ProjectAgent is a project's agent at its current version.

type ProjectAgentDefinition added in v0.13.0

type ProjectAgentDefinition struct {
	Name            string             `json:"name"`
	Description     string             `json:"description"`
	Harness         string             `json:"harness"`
	Model           *string            `json:"model"`
	ReasoningEffort *string            `json:"reasoning_effort"`
	TimeoutMS       int                `json:"timeout_ms"`
	Instructions    string             `json:"instructions"`
	Signal          ProjectAgentSignal `json:"signal"`
}

ProjectAgentDefinition is what an agent is called and runs. For a preset agent these are the preset's, as the catalog has it now.

type ProjectAgentPreset added in v0.13.0

type ProjectAgentPreset struct {
	ID          string                 `json:"id"`
	Version     int                    `json:"version"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Agent       ProjectAgentDefinition `json:"agent"`
}

ProjectAgentPreset is one Entire-maintained agent from GET /agents/presets.

type ProjectAgentPresetRef added in v0.13.0

type ProjectAgentPresetRef struct {
	ID      string `json:"id"`
	Version int    `json:"version"`
}

ProjectAgentPresetRef names the Entire preset an agent runs.

type ProjectAgentRun added in v0.13.0

type ProjectAgentRun struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Error  *struct {
		Code    *string `json:"code"`
		Message string  `json:"message"`
	} `json:"error"`
	Agent struct {
		ID      string `json:"id"`
		Version int64  `json:"version"`
		Name    string `json:"name"`
	} `json:"agent"`
	Trigger struct {
		Kind string `json:"kind"`
	} `json:"trigger"`
	// TrailID, ChangeID and Branch are on list items; a single run's read
	// carries them in Target instead.
	TrailID  string `json:"trail_id"`
	ChangeID string `json:"change_id"`
	Branch   string `json:"branch"`
	Target   *struct {
		TrailID  string `json:"trail_id"`
		ChangeID string `json:"change_id"`
		Ref      string `json:"ref"`
		HeadSHA  string `json:"head_sha"`
	} `json:"target"`
	Attempt             int     `json:"attempt"`
	RetryOf             *string `json:"retry_of"`
	Diagnostic          *string `json:"diagnostic"`
	ReviewChangesResult *struct {
		Summary *string `json:"summary"`
		Signal  struct {
			ValueType string          `json:"value_type"`
			Value     json.RawMessage `json:"value"`
			Rationale string          `json:"rationale"`
		} `json:"signal"`
		Findings []json.RawMessage `json:"findings"`
	} `json:"review_changes_result"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ProjectAgentRun is a project agent's run, as GET /{host}/{project}/runs and .../runs/{id} return it. Only the fields the CLI renders are modeled; the commands' --json prints the server's response unchanged.

type ProjectAgentRunPage added in v0.13.0

type ProjectAgentRunPage struct {
	Items      []json.RawMessage `json:"items"`
	NextCursor *string           `json:"next_cursor,omitempty"`
}

ProjectAgentRunPage is one page of GET /{host}/{project}/runs.

type ProjectAgentSignal added in v0.13.0

type ProjectAgentSignal struct {
	ValueType string `json:"value_type"`
	Polarity  string `json:"polarity,omitempty"`
}

ProjectAgentSignal is the reading each review distills to.

type ProjectAgentTrigger added in v0.13.0

type ProjectAgentTrigger struct {
	ID       string   `json:"id,omitempty"`
	Kind     string   `json:"kind"`
	When     string   `json:"when,omitempty"`
	Branches []string `json:"branches,omitempty"`
	Paths    []string `json:"paths,omitempty"`
}

ProjectAgentTrigger is one saved trigger. The same shape is sent back on a write, so an unchanged trigger keeps its id and push history.

type ProjectAgentWrite added in v0.13.0

type ProjectAgentWrite struct {
	Preset      string `json:"preset,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	// IsEnabled is always sent: the API defaults a missing value to false,
	// but a write should say what it means.
	IsEnabled       bool                  `json:"is_enabled"`
	Harness         string                `json:"harness,omitempty"`
	Model           *string               `json:"model,omitempty"`
	ReasoningEffort *string               `json:"reasoning_effort,omitempty"`
	TimeoutMS       int                   `json:"timeout_ms,omitempty"`
	Instructions    string                `json:"instructions,omitempty"`
	Signal          *ProjectAgentSignal   `json:"signal,omitempty"`
	RepositoryIDs   []string              `json:"repository_ids"`
	Triggers        []ProjectAgentTrigger `json:"triggers,omitempty"`
	EnvironmentID   string                `json:"environment_id,omitempty"`
}

ProjectAgentWrite is a create or replace body. A preset create sends Preset and the placement fields only; a custom agent sends every definition field and no Preset. A replace of a preset agent without Preset customizes it under the same id.

type ProjectConfigPage added in v0.13.0

type ProjectConfigPage[T any] struct {
	Items      []T     `json:"items"`
	NextCursor *string `json:"next_cursor,omitempty"`
}

ProjectConfigPage is one page of a project configuration list.

type ProjectEnvironment added in v0.13.0

type ProjectEnvironment struct {
	RunsOn      string     `json:"runs_on"`
	Managed     bool       `json:"managed"`
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	ArchivedAt  *time.Time `json:"archived_at"`
}

ProjectEnvironment is a project's saved sandbox environment.

type ProjectEnvironmentInput added in v0.13.0

type ProjectEnvironmentInput struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

ProjectEnvironmentInput is an environment create body.

type ProjectTrail added in v0.11.5

type ProjectTrail struct {
	Project   *TrailProject `json:"project,omitempty"`
	GroupKey  string        `json:"groupKey,omitempty"`
	ID        string        `json:"id"`
	ProjectID string        `json:"projectId"`
	Number    int           `json:"number"`
	URL       string        `json:"url,omitempty"`
	Title     string        `json:"title"`
	Body      string        `json:"body"`
	Status    string        `json:"status"`
	// Phase is derived by the server on read (planning, building, complete,
	// closed); it complements Status rather than replacing it.
	Phase              string          `json:"phase,omitempty"`
	Metadata           map[string]any  `json:"metadata"`
	Type               string          `json:"type"`
	Priority           string          `json:"priority"`
	Assignees          []string        `json:"assignees"`
	AssigneeAccountIDs []*string       `json:"assigneeAccountIds"`
	RepositoryIDs      []string        `json:"repoIds"`
	AuthorAccountID    string          `json:"authorAccountId"`
	CreatedAt          time.Time       `json:"createdAt"`
	LastActivityAt     time.Time       `json:"lastActivityAt,omitzero"`
	ClosedAt           *time.Time      `json:"closedAt"`
	Changes            []ChangeSummary `json:"changes,omitempty"`
	IsPossiblyPartial  bool            `json:"isPossiblyPartial,omitempty"`
}

ProjectTrail is project intent, separate from branch-backed TrailResource. Changes is absent from list responses. A detail is potentially access-filtered; neither its changes nor its repoIds are an authoritative complete inventory.

type ProjectTrailAttachment added in v0.13.0

type ProjectTrailAttachment struct {
	ID          string    `json:"id"`
	ProjectID   string    `json:"project_id"`
	TrailID     string    `json:"trail_id"`
	Filename    string    `json:"filename"`
	ContentType string    `json:"content_type"`
	SizeBytes   int64     `json:"size_bytes"`
	IsReady     bool      `json:"is_ready"`
	Kind        string    `json:"kind"`
	CreatedBy   string    `json:"created_by_account_id"`
	CreatedAt   time.Time `json:"created_at"`
	Width       *int      `json:"width"`
	Height      *int      `json:"height"`
}

ProjectTrailAttachment is one attachment as list and complete return it.

type ProjectTrailAttachmentComplete added in v0.13.0

type ProjectTrailAttachmentComplete struct {
	Attachment ProjectTrailAttachment `json:"attachment"`
}

ProjectTrailAttachmentComplete is POST .../attachments/{id}/complete.

type ProjectTrailAttachmentIntent added in v0.13.0

type ProjectTrailAttachmentIntent struct {
	Filename    string `json:"filename"`
	ContentType string `json:"content_type"`
	Width       int    `json:"width,omitempty"`
	Height      int    `json:"height,omitempty"`
}

ProjectTrailAttachmentIntent is POST /{host}/{project}/trails/{trail}/attachments: it registers an upload and returns where to PUT the bytes.

type ProjectTrailAttachmentList added in v0.13.0

type ProjectTrailAttachmentList struct {
	Attachments []ProjectTrailAttachment `json:"attachments"`
}

ProjectTrailAttachmentList is GET .../attachments.

type ProjectTrailAttachmentUpload added in v0.13.0

type ProjectTrailAttachmentUpload struct {
	ID     string `json:"id"`
	Upload struct {
		URL       string    `json:"url"`
		ExpiresAt time.Time `json:"expires_at"`
		MaxBytes  int64     `json:"max_bytes"`
	} `json:"upload"`
}

ProjectTrailAttachmentUpload is the registered upload: the attachment's ID and a short-lived presigned PUT URL for its bytes.

type ProjectTrailCreateRequest added in v0.11.5

type ProjectTrailCreateRequest struct {
	Title         string                `json:"title"`
	Body          string                `json:"body,omitempty"`
	Status        string                `json:"status,omitempty"`
	Type          string                `json:"type,omitempty"`
	Priority      string                `json:"priority,omitempty"`
	Assignees     []string              `json:"assignees,omitempty"`
	RepositoryIDs []string              `json:"repoIds,omitempty"`
	Changes       []ChangeCreateRequest `json:"changes,omitempty"`
}

type ProjectTrailGroupTotal added in v0.11.5

type ProjectTrailGroupTotal struct {
	Rank       int    `json:"rank"`
	Key        string `json:"key"`
	Label      string `json:"label"`
	TotalCount int    `json:"totalCount"`
}

type ProjectTrailListResponse added in v0.11.5

type ProjectTrailListResponse struct {
	Items         []ProjectTrail           `json:"items"`
	NextPageToken *string                  `json:"nextPageToken"`
	Groups        []ProjectTrailPageGroup  `json:"groups,omitempty"`
	GroupTotals   []ProjectTrailGroupTotal `json:"groupTotals,omitempty"`
	GroupBy       string                   `json:"groupBy,omitempty"`
	Jurisdiction  string                   `json:"jurisdiction,omitempty"`
	Capabilities  map[string]bool          `json:"capabilities,omitempty"`
}

ProjectTrailListResponse is the single-project GET /api/v1/trails response. Preserve server counts and the opaque project/filter-bound continuation token.

type ProjectTrailPageGroup added in v0.11.5

type ProjectTrailPageGroup struct {
	ProjectTrailGroupTotal

	ItemCount int `json:"itemCount"`
}

type ProjectTrailUpdateRequest added in v0.11.5

type ProjectTrailUpdateRequest struct {
	Title     *string   `json:"title,omitempty"`
	Body      *string   `json:"body,omitempty"`
	Status    *string   `json:"status,omitempty"`
	Type      *string   `json:"type,omitempty"`
	Priority  *string   `json:"priority,omitempty"`
	Assignees *[]string `json:"assignees,omitempty"`
}

ProjectTrailUpdateRequest can update the description and intent atomically. Pointers preserve explicit clears, unlike omitempty on a plain string/slice.

type TokenSource added in v0.13.2

type TokenSource interface {
	// Token returns the bearer for a request; an error fails the request
	// before anything is sent.
	Token(ctx context.Context) (string, error)
	// Unauthorized is called after a request using token was answered 401,
	// so the source can drop a cached bearer the server no longer accepts.
	// The request is not retried; the next one asks Token again.
	Unauthorized(token string)
}

TokenSource supplies the bearer for each request of a client built by NewClientWithTokenSource. Use it for a credential whose bearer is short-lived and renewable, so a long-running command (a reconnecting stream, say) never sends a token that expired after the client was built.

type TrailActionAvailability added in v0.11.5

type TrailActionAvailability struct {
	State  string  `json:"state"`
	Reason *string `json:"reason"`
}

TrailActionAvailability.State is enabled, blocked, or unavailable; Reason says why when it is not enabled.

type TrailActions added in v0.11.5

type TrailActions struct {
	Merge           TrailActionAvailability `json:"merge"`
	MergeWithBypass TrailActionAvailability `json:"merge_with_bypass"`
}

TrailActions is the detail's per-caller availability of each operation; only the merge operations are decoded. The server revalidates on submit.

type TrailAgent added in v0.13.0

type TrailAgent struct {
	Agent struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"agent"`
	Reading    *TrailAgentReading `json:"reading"`
	TrendDelta *int               `json:"trend_delta"`
	LatestRun  *TrailAgentRun     `json:"latest_run"`
	WaitingFor *string            `json:"waiting_for"`
}

TrailAgent is one project agent on a change, as the change detail projects it (TrailResource.Agents): the agent, its latest reading and run, or what it waits for before its first run. Only the fields the CLI renders are modeled; --json passes the server's items through.

type TrailAgentReading added in v0.13.0

type TrailAgentReading struct {
	PercentValue *int    `json:"percent_value"`
	SizeValue    *string `json:"size_value"`
	BooleanValue *bool   `json:"boolean_value"`
	Summary      *string `json:"summary"`
	RunID        string  `json:"run_id"`
	HeadSHA      *string `json:"head_sha"`
}

TrailAgentReading is a finished review's reading; the field value_type names is the one set.

type TrailAgentRun added in v0.13.0

type TrailAgentRun struct {
	ID        string  `json:"id"`
	Status    string  `json:"status"`
	HeadSHA   *string `json:"head_sha"`
	CreatedAt string  `json:"created_at"`
	Error     *struct {
		Message string `json:"message"`
	} `json:"error"`
}

TrailAgentRun is an agent's latest run on a change.

type TrailApproval added in v0.9.0

type TrailApproval struct {
	ID        string    `json:"id"`
	Author    string    `json:"author"`
	Event     string    `json:"event"`
	Body      string    `json:"body,omitempty"`
	CommitSHA string    `json:"commit_sha,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

TrailApproval is a single approval decision on a trail. Author is exposed as a login string while UnmarshalJSON accepts both shapes entire-api itself uses: the approvals collection sends a bare login string, the trail resource sends an {id,login} object. Both are live — this is not legacy tolerance.

func (*TrailApproval) UnmarshalJSON added in v0.10.1

func (a *TrailApproval) UnmarshalJSON(data []byte) error

type TrailApprovalRequest added in v0.9.0

type TrailApprovalRequest struct {
	Event string `json:"event"`
	Body  string `json:"body,omitempty"`
}

type TrailApprovalResponse added in v0.9.0

type TrailApprovalResponse struct {
	OK       bool          `json:"ok"`
	Approval TrailApproval `json:"approval"`
}

type TrailApprovalsResponse added in v0.9.0

type TrailApprovalsResponse struct {
	Approvals []TrailApproval `json:"approvals"`
}

type TrailBodyDocument added in v0.7.8

type TrailBodyDocument struct {
	TextSnapshot string `json:"text_snapshot"`
}

type TrailCIPullRequestResponse added in v0.13.0

type TrailCIPullRequestResponse struct {
	PRNumber int `json:"prNumber"`
}

TrailCIPullRequestResponse is POST .../trails/{number}/ci-pr.

type TrailCheckRun added in v0.11.3

type TrailCheckRun struct {
	Name        string     `json:"name"`
	Status      string     `json:"status"`
	Conclusion  *string    `json:"conclusion"`
	DetailsURL  *string    `json:"details_url"`
	StartedAt   *time.Time `json:"started_at"`
	CompletedAt *time.Time `json:"completed_at"`
	AppName     *string    `json:"app_name"`
}

TrailCheckRun is one CI run. Conclusion is null until the run completes.

type TrailChecks added in v0.11.3

type TrailChecks struct {
	Availability string          `json:"availability"`
	Runs         []TrailCheckRun `json:"runs"`
}

TrailChecks are the third-party CI runs for the snapshot's head.

type TrailDiscussionCreateRequest added in v0.11.1

type TrailDiscussionCreateRequest struct {
	Title string `json:"title,omitempty"`
	Body  string `json:"body"`
}

TrailDiscussionCreateRequest is the body for POST .../:number/discussions. Body is required; Title is optional (server defaults it to "Conversation").

type TrailDiscussionCreateResponse added in v0.11.1

type TrailDiscussionCreateResponse struct {
	Discussion TrailDiscussionSummary  `json:"discussion"`
	Message    *TrailDiscussionMessage `json:"message"`
}

TrailDiscussionCreateResponse is the response from POST .../:number/discussions.

type TrailDiscussionDetailResponse added in v0.11.1

type TrailDiscussionDetailResponse struct {
	Discussion  TrailDiscussionSummary   `json:"discussion"`
	Messages    []TrailDiscussionMessage `json:"messages"`
	EventCursor string                   `json:"event_cursor"`
}

TrailDiscussionDetailResponse is the response from GET .../:number/discussions/:id.

type TrailDiscussionMessage added in v0.11.1

type TrailDiscussionMessage struct {
	ETag      string                 `json:"etag,omitempty"`
	ID        string                 `json:"id"`
	Author    string                 `json:"author"` // GitHub login
	CreatedAt time.Time              `json:"created_at"`
	Body      string                 `json:"body"`
	Replies   []TrailDiscussionReply `json:"replies"`
}

TrailDiscussionMessage is a top-level message in a discussion.

type TrailDiscussionMessageRequest added in v0.11.1

type TrailDiscussionMessageRequest struct {
	Body string `json:"body"`
}

TrailDiscussionMessageRequest is the body for POST/PATCH message endpoints.

type TrailDiscussionMessageResponse added in v0.11.1

type TrailDiscussionMessageResponse struct {
	Message TrailDiscussionMessage `json:"message"`
}

TrailDiscussionMessageResponse is the response from the message endpoints.

type TrailDiscussionParticipant added in v0.11.1

type TrailDiscussionParticipant struct {
	Login string `json:"login"`
}

TrailDiscussionParticipant identifies a discussion participant by login.

type TrailDiscussionReply added in v0.11.1

type TrailDiscussionReply struct {
	ETag      string    `json:"etag,omitempty"`
	ID        string    `json:"id"`
	Author    string    `json:"author"` // GitHub login
	CreatedAt time.Time `json:"created_at"`
	Body      string    `json:"body"`
}

TrailDiscussionReply is a reply on a discussion message. Replies do not nest further.

type TrailDiscussionSummary added in v0.11.1

type TrailDiscussionSummary struct {
	ID                string                       `json:"id"`
	TrailID           string                       `json:"trail_id"`
	Kind              string                       `json:"kind"` // "discussion" | "code_review"
	Title             string                       `json:"title"`
	ReviewCommentID   *string                      `json:"review_comment_id"`
	Resolved          bool                         `json:"resolved"`
	ResolvedBy        *string                      `json:"resolved_by"` // actor UUID
	ResolvedAt        *time.Time                   `json:"resolved_at"`
	CreatedBy         *string                      `json:"created_by"` // actor UUID
	CreatedAt         time.Time                    `json:"created_at"`
	UpdatedAt         time.Time                    `json:"updated_at"`
	LastMessageAt     *time.Time                   `json:"last_message_at"`
	LastMessageAuthor *string                      `json:"last_message_author"` // GitHub login
	MessageCount      int                          `json:"message_count"`
	Participants      []TrailDiscussionParticipant `json:"participants"`
}

TrailDiscussionSummary is a discussion's metadata. The server's review_comment blob (present only for kind=="code_review") is intentionally not decoded here: code-review discussions are surfaced through `trail finding`.

type TrailDiscussionUpdateRequest added in v0.11.1

type TrailDiscussionUpdateRequest struct {
	Title    *string `json:"title,omitempty"`
	Resolved *bool   `json:"resolved,omitempty"`
}

TrailDiscussionUpdateRequest is the body for PATCH .../:number/discussions/:id. Pointer fields distinguish "not provided" from an explicit value.

type TrailDiscussionUpdateResponse added in v0.11.1

type TrailDiscussionUpdateResponse struct {
	Discussion TrailDiscussionSummary `json:"discussion"`
}

TrailDiscussionUpdateResponse is the response from PATCH .../:number/discussions/:id.

type TrailDiscussionsResponse added in v0.11.1

type TrailDiscussionsResponse struct {
	Items       []TrailDiscussionSummary `json:"items"`
	NextCursor  *string                  `json:"next_cursor,omitempty"`
	EventCursor string                   `json:"event_cursor"`
}

TrailDiscussionsResponse is the response from GET .../:number/discussions.

type TrailGate added in v0.11.3

type TrailGate struct {
	ID               string              `json:"id"`
	GateDefinitionID string              `json:"gate_definition_id"`
	GateKey          string              `json:"gate_key"`
	GateType         string              `json:"gate_type"`
	Blocking         bool                `json:"blocking"`
	Status           string              `json:"status"`
	State            string              `json:"state,omitempty"`
	Outcome          *string             `json:"outcome"`
	Rationale        *string             `json:"rationale"`
	HeadSHA          *string             `json:"head_sha"`
	EvaluatedAtSHA   *string             `json:"evaluated_at_sha"`
	StaleReason      *string             `json:"stale_reason"`
	FindingCount     *int64              `json:"finding_count"`
	Reviewers        []TrailGateReviewer `json:"reviewers"`
	RunnerIDs        []string            `json:"runner_ids"`
	Value            json.RawMessage     `json:"value"`
	CreatedAt        time.Time           `json:"created_at"`
	CompletedAt      *time.Time          `json:"completed_at"`
}

TrailGate is one evaluated gate row. Value's shape depends on GateType (approvals, checks, findings, ...), so it is kept as raw JSON and passed through untouched.

type TrailGateReviewer added in v0.11.3

type TrailGateReviewer struct {
	Login           string  `json:"login"`
	State           string  `json:"state"`
	ReviewedHeadSHA *string `json:"reviewed_head_sha"`
	Reason          *string `json:"reason"`
}

TrailGateReviewer is a reviewer's standing on an approvals gate.

type TrailListResponse added in v0.5.2

type TrailListResponse struct {
	Trails     []TrailResource `json:"items"`
	Total      int             `json:"total_count"`
	NextCursor *string         `json:"next_cursor"`
}

TrailListResponse is the response from entire-api's trail list endpoint.

type TrailMergeDetail added in v0.11.5

type TrailMergeDetail struct {
	Actions      *TrailActions              `json:"actions"`
	Mergeability *TrailMergeabilityResponse `json:"mergeability"`
}

TrailMergeDetail is the part of GET .../trails/{number} the merge command reads: the mergeability snapshot and the caller's merge actions, both from the same server read.

type TrailMergeRequest added in v0.11.5

type TrailMergeRequest struct {
	ExpectedHeadSha string `json:"expectedHeadSha,omitempty"`
	Bypass          bool   `json:"bypass,omitempty"`
	// DeleteBranch overrides the repo's delete-branch-on-merge setting for a
	// native trail; nil leaves it to the setting. A pointer, because an
	// explicit false must reach the server.
	DeleteBranch *bool `json:"deleteBranch,omitempty"`
}

type TrailMergeResponse added in v0.11.5

type TrailMergeResponse struct {
	OK bool `json:"ok"`
	// Empty when the merge fast-forwarded or the base was already up to date.
	MergeCommitSha string `json:"mergeCommitSha"`
	// BranchDeleted reports whether the server deleted the trail's branch
	// after the merge. It is always false for a GitHub-backed trail, whose
	// branch GitHub manages.
	BranchDeleted bool `json:"branchDeleted"`
	// BranchKeptReason says why a native trail's branch was kept; empty when
	// it was deleted and for a GitHub-backed trail.
	BranchKeptReason string `json:"branchKeptReason,omitempty"`
}

type TrailMergeability added in v0.11.3

type TrailMergeability struct {
	HeadSHA        *string     `json:"head_sha"`
	Mergeable      bool        `json:"mergeable"`
	ConflictStatus string      `json:"conflict_status"`
	Checks         TrailChecks `json:"checks"`
	Gates          []TrailGate `json:"gates"`
}

TrailMergeability is the backend's mergeability snapshot for a trail, served on the detail resource (TrailDetailResponse.mergeability). It is the authoritative merge verdict: the CLI surfaces it as-is and never derives mergeability from its parts. head_sha, gates, and checks all come from the same server read that decided mergeable, so they are consistent with it.

The wire object carries further fields; TrailMergeabilityResponse decodes the ones the merge command needs.

type TrailMergeabilityResponse added in v0.11.5

type TrailMergeabilityResponse struct {
	TrailMergeability

	BypassPolicy     string `json:"bypass_policy"`
	BehindBy         int    `json:"behind_by"`
	ComparisonStatus string `json:"comparison_status"`
	// DeleteBranchOnMerge is the repo's default for the merge request's
	// deleteBranch. It is nil for a GitHub-backed repo, whose branch GitHub
	// manages, when readiness is unavailable, and from a server that predates
	// the setting.
	DeleteBranchOnMerge *bool `json:"delete_branch_on_merge"`
}

TrailMergeabilityResponse is the full mergeability snapshot the detail resource serves (TrailMergeability, as `trail show` reads it) plus the fields the merge command needs to decide on and explain a bypass and to say what the merge will do with the trail's branch.

type TrailParentReference added in v0.11.5

type TrailParentReference struct {
	ID                    string `json:"id"`
	Number                int    `json:"number"`
	ProjectID             string `json:"project_id"`
	Host                  string `json:"host"`
	Project               string `json:"project"`
	Path                  string `json:"path"`
	Jurisdiction          string `json:"jurisdiction"`
	PrimaryProcessingCell string `json:"primary_processing_cell"`
	URL                   string `json:"url,omitempty"`
}

TrailParentReference is navigation returned by repository Change reads. Absence can mean inaccessible or unresolved, not necessarily parentless. Path is relative to the PROJECT cell, never the repository's cell.

type TrailProject added in v0.11.5

type TrailProject struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Provider     string `json:"provider"`
	Jurisdiction string `json:"jurisdiction"`
	Reference    struct {
		Forge   string `json:"forge"`
		Project string `json:"project"`
	} `json:"reference"`
	Capabilities struct {
		CanManageTrails bool `json:"canManageTrails"`
	} `json:"capabilities"`
}

TrailProject is project navigation returned by detail reads. List items need not carry it: the collection is already addressed by projectId.

type TrailResource added in v0.5.2

type TrailResource struct {
	ID                 string                `json:"id,omitempty"`
	Number             int                   `json:"number,omitempty"`
	URL                string                `json:"url,omitempty"`
	Branch             string                `json:"branch"`
	OriginalBranch     string                `json:"original_branch,omitempty"`
	Base               string                `json:"base"`
	Title              string                `json:"title"`
	Body               string                `json:"body,omitempty"`
	Status             string                `json:"status"`
	ReadyForReview     *bool                 `json:"ready_for_review,omitempty"` // nil when the server omits it
	Phase              string                `json:"phase,omitempty"`
	Author             *trail.Author         `json:"author"`
	Labels             []string              `json:"labels,omitempty"`
	Priority           string                `json:"priority,omitempty"`
	Type               string                `json:"type,omitempty"`
	Reviewers          []trail.Reviewer      `json:"reviewers,omitempty"`
	RequestedReviewers []string              `json:"requested_reviewers,omitempty"`
	CreatedAt          time.Time             `json:"created_at"`
	UpdatedAt          time.Time             `json:"updated_at"`
	MergedAt           *time.Time            `json:"merged_at,omitempty"`
	CheckpointCount    int                   `json:"checkpoint_count,omitempty"`
	CommitsAhead       int                   `json:"commits_ahead,omitempty"`
	BodyDocument       *TrailBodyDocument    `json:"body_document,omitempty"`
	Parent             *TrailParentReference `json:"parent,omitempty"`
	// Mergeability is served on the detail resource only; list items omit it.
	// It stays raw so that every detail-route decode (approve, update, resume,
	// review-target resolution, ...) does not depend on the snapshot's shape;
	// only `trail show` reads it, through DecodeMergeability.
	Mergeability json.RawMessage `json:"mergeability,omitempty"`
	// Agents is detail-only too, and raw for the same reason: `trail finding`
	// passes it through to --json and reads it through DecodeAgents.
	Agents json.RawMessage `json:"agents,omitempty"`
	// FromDetail reports that the resource was decoded from the detail route
	// rather than a list page. It is the reliable marker: body_document can be
	// absent from a valid detail response.
	FromDetail bool `json:"-"`
}

TrailResource represents a trail returned by entire-api. The backend uses snake_case and nullable branch fields. Branch is empty when the trail is currently unlinked; OriginalBranch separately preserves its last link.

func (*TrailResource) DecodeAgents added in v0.13.0

func (r *TrailResource) DecodeAgents() ([]TrailAgent, error)

DecodeAgents decodes the detail resource's agents; nil when the read did not carry them.

func (*TrailResource) DecodeMergeability added in v0.11.3

func (r *TrailResource) DecodeMergeability() (*TrailMergeability, error)

DecodeMergeability decodes the detail resource's mergeability snapshot. It returns nil, nil when the snapshot is absent or null.

func (*TrailResource) ToMetadata added in v0.5.2

func (r *TrailResource) ToMetadata() *trail.Metadata

ToMetadata converts a TrailResource to display metadata.

type TrailReview added in v0.7.6

type TrailReview struct {
	ID            string    `json:"id"`
	TrailID       string    `json:"trail_id"`
	CodeVersionID string    `json:"code_version_id"`
	ActorID       string    `json:"actor_id"`
	Summary       *string   `json:"summary"`
	StartedAt     time.Time `json:"started_at"`
}

TrailReview represents a review session.

type TrailReviewCodeVersion added in v0.7.6

type TrailReviewCodeVersion struct {
	ID           string    `json:"id"`
	TrailID      string    `json:"trail_id"`
	RepositoryID string    `json:"repo_id"`
	BaseRef      *string   `json:"base_ref"`
	HeadRef      *string   `json:"head_ref"`
	BaseSHA      *string   `json:"base_sha"`
	HeadSHA      *string   `json:"head_sha"`
	CapturedAt   time.Time `json:"captured_at"`
}

TrailReviewCodeVersion pins the base/head that a review covers.

type TrailReviewComment added in v0.7.6

type TrailReviewComment struct {
	ID                        string                       `json:"id"`
	TrailID                   string                       `json:"trail_id"`
	RepositoryID              string                       `json:"repo_id"`
	ReviewID                  string                       `json:"review_id"`
	CodeVersionID             string                       `json:"code_version_id"`
	ActorID                   string                       `json:"actor_id"`
	Title                     *string                      `json:"title"`
	Body                      *string                      `json:"body"`
	Severity                  *string                      `json:"severity"`
	Confidence                *float64                     `json:"confidence"`
	Status                    string                       `json:"status"`
	StatusReason              *string                      `json:"status_reason"`
	StaleOutcome              string                       `json:"stale_outcome"`
	StaleCheckedAt            *time.Time                   `json:"stale_checked_at"`
	StaleCheckedCodeVersionID *string                      `json:"stale_checked_code_version_id"`
	ClientID                  *string                      `json:"client_id"`
	ClientIDHash              *string                      `json:"client_id_hash"`
	CreatedAt                 time.Time                    `json:"created_at"`
	UpdatedAt                 time.Time                    `json:"updated_at"`
	Location                  TrailReviewLocation          `json:"location"`
	SuggestedChanges          []TrailReviewSuggestedChange `json:"suggested_changes,omitempty"`
	DiscussionID              *string                      `json:"discussion_id,omitempty"`
	DiscussionMessageCount    int                          `json:"discussion_message_count,omitempty"`
	OutgoingLinks             []TrailReviewOutgoingLink    `json:"outgoing_links,omitempty"`
}

TrailReviewComment is a single agent-native review finding.

type TrailReviewCommentBatchError added in v0.7.6

type TrailReviewCommentBatchError struct {
	Code      string  `json:"code"`
	Message   string  `json:"message"`
	Field     *string `json:"field"`
	Retryable bool    `json:"retryable"`
}

TrailReviewCommentBatchError describes why a single finding in a batch failed.

type TrailReviewCommentBatchRequest added in v0.7.6

type TrailReviewCommentBatchRequest struct {
	Comments []TrailReviewCommentInput `json:"comments"`
}

TrailReviewCommentBatchRequest posts a batch of findings to a review via POST /api/v1/repos/{repo_id}/changes/{number}/reviews/{id}/comments. The API requires at least one comment and rejects batches larger than the review's max_comments_per_batch limit.

type TrailReviewCommentBatchResponse added in v0.7.6

type TrailReviewCommentBatchResponse struct {
	Results []TrailReviewCommentBatchResult `json:"results"`
}

TrailReviewCommentBatchResponse is returned by the batch comment endpoint.

type TrailReviewCommentBatchResult added in v0.7.6

type TrailReviewCommentBatchResult struct {
	ClientID        string                        `json:"client_id"`
	Status          string                        `json:"status"`
	Comment         *TrailReviewComment           `json:"comment,omitempty"`
	SuggestedChange *TrailReviewSuggestedChange   `json:"suggested_change,omitempty"`
	Error           *TrailReviewCommentBatchError `json:"error,omitempty"`
}

TrailReviewCommentBatchResult reports the per-finding outcome of a batch. Status is one of "created", "existing", or "error"; Comment is populated for the first two, Error for the last.

type TrailReviewCommentInput added in v0.7.6

type TrailReviewCommentInput struct {
	ClientID        string                                   `json:"client_id"`
	Body            *string                                  `json:"body,omitempty"`
	Severity        *string                                  `json:"severity,omitempty"`
	Confidence      *float64                                 `json:"confidence,omitempty"`
	Status          *string                                  `json:"status,omitempty"`
	StatusReason    *string                                  `json:"status_reason,omitempty"`
	Location        TrailReviewLocationCreateRequest         `json:"location"`
	SuggestedChange *TrailReviewSuggestedChangeCreateRequest `json:"suggested_change,omitempty"`
}

TrailReviewCommentInput is a single finding within a batch create request. client_id (an idempotency key) and location are required by the API.

type TrailReviewCommentPatchRequest added in v0.7.6

type TrailReviewCommentPatchRequest struct {
	Title        *string  `json:"title,omitempty"`
	Body         *string  `json:"body,omitempty"`
	Severity     *string  `json:"severity,omitempty"`
	Confidence   *float64 `json:"confidence,omitempty"`
	Status       string   `json:"status,omitempty"`
	StatusReason *string  `json:"status_reason,omitempty"`
}

TrailReviewCommentPatchRequest updates a review finding.

type TrailReviewCommentsResponse added in v0.7.6

type TrailReviewCommentsResponse struct {
	Comments    []TrailReviewComment `json:"comments"`
	NextCursor  *string              `json:"next_cursor,omitempty"`
	EventCursor string               `json:"event_cursor,omitempty"`
}

TrailReviewCommentsResponse is returned by trail/review comment list endpoints.

type TrailReviewCounts added in v0.7.6

type TrailReviewCounts struct {
	Open      int `json:"open"`
	Resolved  int `json:"resolved"`
	Dismissed int `json:"dismissed"`
	Stale     int `json:"stale"`
	Total     int `json:"total"`
}

TrailReviewCounts are review-scoped comment counts.

type TrailReviewLimits added in v0.7.6

type TrailReviewLimits struct {
	MaxCommentsPerBatch int `json:"max_comments_per_batch"`
}

TrailReviewLimits carries the server-enforced batch limits for a review.

type TrailReviewLocation added in v0.7.6

type TrailReviewLocation struct {
	ID              string  `json:"id"`
	ReviewCommentID string  `json:"review_comment_id"`
	CodeVersionID   string  `json:"code_version_id"`
	Granularity     string  `json:"granularity"`
	FilePath        *string `json:"file_path"`
	StartLine       *int    `json:"start_line"`
	StartColumn     *int    `json:"start_column"`
	EndLine         *int    `json:"end_line"`
	EndColumn       *int    `json:"end_column"`
	SelectedText    *string `json:"selected_text"`
	NearbyText      *string `json:"nearby_text"`
	Language        *string `json:"language"`
}

TrailReviewLocation identifies where a finding applies.

type TrailReviewLocationCreateRequest added in v0.7.6

type TrailReviewLocationCreateRequest struct {
	Granularity  string  `json:"granularity"`
	FilePath     *string `json:"file_path,omitempty"`
	StartLine    *int    `json:"start_line,omitempty"`
	StartColumn  *int    `json:"start_column,omitempty"`
	EndLine      *int    `json:"end_line,omitempty"`
	EndColumn    *int    `json:"end_column,omitempty"`
	SelectedText *string `json:"selected_text,omitempty"`
	NearbyText   *string `json:"nearby_text,omitempty"`
	Language     *string `json:"language,omitempty"`
}

TrailReviewLocationCreateRequest identifies where a new finding applies.

type TrailReviewOutgoingLink struct {
	SourceCommentID string `json:"source_comment_id"`
	TargetCommentID string `json:"target_comment_id"`
	LinkType        string `json:"link_type"`
}

TrailReviewOutgoingLink relates two review comments.

type TrailReviewRerunResponse added in v0.13.0

type TrailReviewRerunResponse struct {
	Launched int `json:"launched"`
}

TrailReviewRerunResponse is POST /repos/{repo_id}/changes/{number}/review-rerun. Launched counts only the repository-configured reviewers it started; the project's agents are started the way a push starts them and are not counted.

type TrailReviewStartRequest added in v0.7.6

type TrailReviewStartRequest struct {
	HeadSHA *string `json:"head_sha,omitempty"`
	BaseSHA *string `json:"base_sha,omitempty"`
	BaseRef *string `json:"base_ref,omitempty"`
	HeadRef *string `json:"head_ref,omitempty"`
}

TrailReviewStartRequest starts a review session for a trail via POST /api/v1/repos/{repo_id}/changes/{number}/reviews. All fields are optional; the server resolves the code version (base/head) when they are omitted.

type TrailReviewStartResponse added in v0.7.6

type TrailReviewStartResponse struct {
	ReviewID       string            `json:"review_id"`
	TrailID        string            `json:"trail_id"`
	RepositoryID   string            `json:"repo_id"`
	CodeVersionID  string            `json:"code_version_id"`
	BaseSHA        *string           `json:"base_sha"`
	HeadSHA        *string           `json:"head_sha"`
	EventStreamURL string            `json:"event_stream_url"`
	DiffURL        string            `json:"diff_url"`
	FilesURL       string            `json:"files_url"`
	Limits         TrailReviewLimits `json:"limits"`
}

TrailReviewStartResponse is returned by POST /api/v1/repos/{repo_id}/changes/{number}/reviews.

type TrailReviewStateResponse added in v0.7.6

type TrailReviewStateResponse struct {
	Review      TrailReview            `json:"review"`
	CodeVersion TrailReviewCodeVersion `json:"code_version"`
	Counts      TrailReviewCounts      `json:"counts"`
	Comments    []TrailReviewComment   `json:"comments"`
	NextCursor  *string                `json:"next_cursor"`
	EventCursor string                 `json:"event_cursor"`
}

TrailReviewStateResponse is returned by GET /api/v1/repos/{repo_id}/changes/{number}/reviews/{id}.

type TrailReviewSuggestedChange added in v0.7.6

type TrailReviewSuggestedChange struct {
	ID                string    `json:"id"`
	ReviewCommentID   string    `json:"review_comment_id"`
	CodeVersionID     string    `json:"code_version_id"`
	ChangeType        string    `json:"change_type"`
	Patch             *string   `json:"patch"`
	Instruction       *string   `json:"instruction"`
	ExpectedFilePath  *string   `json:"expected_file_path"`
	ExpectedFileHash  *string   `json:"expected_file_hash"`
	ExpectedStartLine *int      `json:"expected_start_line"`
	ExpectedEndLine   *int      `json:"expected_end_line"`
	ExpectedLines     *string   `json:"expected_lines"`
	CreatedBy         string    `json:"created_by"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
}

TrailReviewSuggestedChange describes a machine-applicable or manual fix.

type TrailReviewSuggestedChangeCreateRequest added in v0.7.6

type TrailReviewSuggestedChangeCreateRequest struct {
	ChangeType        string  `json:"change_type"`
	Patch             *string `json:"patch,omitempty"`
	Instruction       *string `json:"instruction,omitempty"`
	ExpectedFilePath  *string `json:"expected_file_path,omitempty"`
	ExpectedFileHash  *string `json:"expected_file_hash,omitempty"`
	ExpectedStartLine *int    `json:"expected_start_line,omitempty"`
	ExpectedEndLine   *int    `json:"expected_end_line,omitempty"`
	ExpectedLines     *string `json:"expected_lines,omitempty"`
}

TrailReviewSuggestedChangeCreateRequest attaches a suggested fix to a new finding.

Every change_type other than manual_instruction requires the full expected_* anchor — the API rejects a patch that arrives without it. The anchor describes the pre-image the patch was written against, so a later apply can tell whether the file has moved on:

  • ExpectedFileHash is the git blob OID of the whole file as it stood in the author's worktree, i.e. what `git hash-object <file>` prints in that repo. The server stores it opaquely, so this is the CLI's convention; keep producers in agreement before relying on it for staleness checks.
  • ExpectedLines is the byte-exact content of ExpectedStartLine..ExpectedEndLine with line endings intact — not CRLF-normalized display text.

type TrailUpdateBranchResponse added in v0.13.0

type TrailUpdateBranchResponse struct {
	MergeCommitSHA string `json:"mergeCommitSha"`
}

TrailUpdateBranchResponse is POST /repos/{repo_id}/changes/{number}/update-branch. MergeCommitSHA is empty when the branch was already up to date.

type TrailUpdateRequest added in v0.5.2

type TrailUpdateRequest struct {
	// ReadyForReview marks the change ready (true) or back to draft (false).
	// The server keeps it false on a repository without an approval gate, but
	// still applies the matching draft state to a backing pull request.
	ReadyForReview *bool `json:"ready_for_review,omitempty"`
	// Base retargets the change onto another base branch.
	Base *string `json:"base,omitempty"`
}

type TrailUpdateResponse added in v0.5.2

type TrailUpdateResponse struct {
	Trail TrailResource `json:"trail"`
}

Jump to

Keyboard shortcuts

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