client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	URL         string `json:"url"`
	ExpiresAt   string `json:"expires_at"`
	ContentType string `json:"content_type"`
	SizeBytes   *int64 `json:"size_bytes"`
}

Asset is a signed or public asset reference returned by the API.

type BulkErrItem

type BulkErrItem struct {
	Pin       string `json:"pin"`
	Code      string `json:"error_code"`
	Message   string `json:"error_message"`
	RequestID string `json:"request_id,omitempty"`
}

BulkErrItem is the stable JSON representation of a per-pin bulk failure.

type BulkResult

type BulkResult struct {
	Pins   []*PinFull    `json:"pins"`
	Errors []BulkErrItem `json:"errors"`
}

BulkResult contains successful pins and per-pin failures from a bulk fetch.

func (BulkResult) AllFailed

func (r BulkResult) AllFailed() bool

AllFailed reports whether every attempted pin fetch failed.

func (BulkResult) FirstFailureExitCode

func (r BulkResult) FirstFailureExitCode() int

FirstFailureExitCode maps the first bulk error to the stable CLI exit code.

type Client

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

Client talks to the Disbug API.

func New

func New(apiURL, token, userAgent string, sleeper seams.Sleeper, doer seams.HTTPDoer, clock seams.Clock) *Client

New constructs a Disbug API client.

func (*Client) GetPinByNumber

func (c *Client) GetPinByNumber(
	ctx context.Context,
	sessionRef ref.SessionRef,
	pinNumber int64,
	fields []string,
) (*PinFull, error)

GetPinByNumber calls GET /api/teams/{team}/projects/{project}/sessions/{number}/pins/by-number/{n}/.

func (*Client) GetPinsBulk

func (c *Client) GetPinsBulk(ctx context.Context, items []ref.PinFetch) BulkResult

GetPinsBulk fetches pins concurrently while isolating per-pin failures.

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, sessionRef ref.SessionRef) (*SessionDetail, error)

GetSession calls GET /api/teams/{team}/projects/{project}/sessions/{number}/.

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context, p *ListSessionsParams) (*ListSessionsResponse, error)

ListSessions calls GET /api/sessions/.

func (*Client) Me

func (c *Client) Me(ctx context.Context) (*Me, error)

Me calls GET /api/me/.

func (*Client) MeCached

func (c *Client) MeCached(ctx context.Context) (*Me, error)

MeCached returns GET /api/me/ with a 30 second in-memory success cache.

func (*Client) RequireCapability

func (c *Client) RequireCapability(ctx context.Context, want string) error

RequireCapability returns a user-facing error when the API does not advertise want.

func (*Client) ResolveReplay

func (c *Client) ResolveReplay(ctx context.Context, pin *PinFull, sessionNumber, pinNumber int64) (*PinFullResolved, error)

ResolveReplay downloads the replay asset to a local cache file and returns a PinFullResolved with the replay field replaced by a local file path.

func (*Client) RevokeToken

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

RevokeToken revokes the agent token currently in use.

func (*Client) SearchPins

func (c *Client) SearchPins(ctx context.Context, p *SearchParams) (*SearchPinsResponse, error)

SearchPins calls GET /api/search/ with scope=pins.

func (*Client) SearchSessions

func (c *Client) SearchSessions(ctx context.Context, p *SearchParams) (*SearchSessionsResponse, error)

SearchSessions calls GET /api/search/ and returns session summaries. When Scope is "pins", the pin search hits are mapped to their parent sessions.

type ListSessionsParams

type ListSessionsParams struct {
	Status          string
	Project         string
	Limit           int
	Cursor          string
	CreatedAtAfter  string
	CreatedAtBefore string
}

ListSessionsParams holds optional filters for ListSessions.

type ListSessionsResponse

type ListSessionsResponse struct {
	Results           []SessionSummary `json:"results"`
	NextCursor        *string          `json:"next_cursor"`
	Count             int              `json:"count"`
	FreeTierTruncated bool             `json:"free_tier_truncated"`
}

ListSessionsResponse is the paginated session list response.

type Me

type Me struct {
	AgentName      string   `json:"agent_name"`
	Team           string   `json:"team"`
	TeamSlug       string   `json:"team_slug"`
	CreatedByEmail string   `json:"created_by_email"`
	TokenPrefix    string   `json:"token_prefix"`
	LastUsedAt     string   `json:"last_used_at"`
	APIVersion     string   `json:"api_version"`
	Capabilities   []string `json:"capabilities"`
}

Me is the response from GET /api/me/.

func (*Me) HasCapability

func (m *Me) HasCapability(name string) bool

HasCapability reports whether the API advertised a capability.

type PinFull

type PinFull struct {
	PinLite
	Screenshot     *Asset           `json:"screenshot"`
	SessionReplay  *Asset           `json:"session_replay"`
	VoiceNote      *Asset           `json:"voice_note"`
	VideoRecording *Asset           `json:"video_recording"`
	Console        []map[string]any `json:"console"`
	Network        []map[string]any `json:"network"`
	Events         []map[string]any `json:"events"`
}

PinFull is a full pin record, including optional heavy fields.

type PinFullResolved

type PinFullResolved struct {
	PinLite
	Screenshot     *Asset           `json:"screenshot"`
	SessionReplay  *ReplayFile      `json:"session_replay"`
	VoiceNote      *Asset           `json:"voice_note"`
	VideoRecording *Asset           `json:"video_recording"`
	Console        []map[string]any `json:"console"`
	Network        []map[string]any `json:"network"`
	Events         []map[string]any `json:"events"`
}

PinFullResolved is a PinFull with asset URLs resolved to local file paths.

type PinLite

type PinLite struct {
	Number      int64          `json:"number"`
	Feedback    string         `json:"feedback"`
	URL         *string        `json:"url"`
	Selector    *string        `json:"selector"`
	ElementInfo map[string]any `json:"element_info"`
	Metadata    map[string]any `json:"metadata"`
}

PinLite is a compact pin record embedded in session responses.

type Project

type Project struct {
	ID   int64  `json:"id"`
	Slug string `json:"slug"`
	Name string `json:"name"`
}

Project is the project attached to a session.

type ReplayFile

type ReplayFile struct {
	Path       string `json:"path"`
	DurationMs int    `json:"duration_ms"`
	EventCount int    `json:"event_count"`
	SizeBytes  int64  `json:"size_bytes"`
}

ReplayFile is a downloaded replay file with lightweight metadata.

func DownloadReplay

func DownloadReplay(ctx context.Context, asset *Asset, sessionID int64, pinNumber int64) (*ReplayFile, error)

DownloadReplay fetches a replay asset URL, decompresses if gzipped, writes to a cache file, and returns the path with metadata.

type Reporter

type Reporter struct {
	Email       string `json:"email"`
	DisplayName string `json:"display_name"`
}

Reporter is the user-facing reporter identity attached to a session.

type SearchParams

type SearchParams struct {
	Query string
	Scope string // "sessions" or "pins"; SearchSessions defaults empty scope to "sessions"
	Limit int
}

SearchParams configures a /api/search/ call.

type SearchPinsHit

type SearchPinsHit struct {
	Pin     PinLite        `json:"pin"`
	Session SessionSummary `json:"session"`
}

SearchPinsHit is a pin search result with its parent session.

type SearchPinsResponse

type SearchPinsResponse struct {
	Results []SearchPinsHit `json:"results"`
	Total   int             `json:"total"`
}

SearchPinsResponse is the pin search response.

type SearchSessionsResponse

type SearchSessionsResponse struct {
	Results []SessionSummary `json:"results"`
	Total   int              `json:"total"`
}

SearchSessionsResponse is the session search response.

type SessionDetail

type SessionDetail struct {
	TeamSlug             string    `json:"team_slug"`
	Project              *Project  `json:"project"`
	ProjectSessionNumber int64     `json:"project_session_number"`
	ReportURL            string    `json:"report_url"`
	Status               string    `json:"status"`
	Reporter             *Reporter `json:"reporter"`
	URL                  string    `json:"url"`
	UpdatedAt            string    `json:"updated_at"`
	Pins                 []PinLite `json:"pins"`
}

SessionDetail is a full session record with its pins.

type SessionSummary

type SessionSummary struct {
	TeamSlug             string    `json:"team_slug"`
	Project              *Project  `json:"project"`
	ProjectSessionNumber int64     `json:"project_session_number"`
	ReportURL            string    `json:"report_url"`
	URL                  string    `json:"url"`
	Status               string    `json:"status"`
	PinCount             int       `json:"pin_count"`
	FirstPinFeedback     string    `json:"first_pin_feedback"`
	Reporter             *Reporter `json:"reporter"`
	CreatedAt            string    `json:"created_at"`
	UpdatedAt            string    `json:"updated_at"`
	FreeTierLocked       bool      `json:"free_tier_locked"`
}

SessionSummary is a compact session record returned by ListSessions.

func (SessionSummary) ScopedID

func (s SessionSummary) ScopedID() string

ScopedID returns a stable cloud watch identifier that does not expose DB primary keys.

func (SessionSummary) SessionRef

func (s SessionSummary) SessionRef() (ref.SessionRef, error)

SessionRef returns the scoped reference for this session summary.

Jump to

Keyboard shortcuts

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