client

package
v0.0.0-...-53658a8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 17 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,
	sessionID int64,
	pinNumber int64,
	fields []string,
) (*PinFull, error)

GetPinByNumber calls GET /api/sessions/{id}/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, sessionID int64) (*SessionDetail, error)

GetSession calls GET /api/sessions/{id}/.

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) 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
}

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 PinLite

type PinLite struct {
	ID          int64          `json:"id"`
	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 {
	Slug string `json:"slug"`
	Name string `json:"name"`
}

Project is the project attached to a session.

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 {
	ID        int64     `json:"id"`
	Status    string    `json:"status"`
	Project   *Project  `json:"project"`
	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 {
	ID               int64     `json:"id"`
	Project          *Project  `json:"project"`
	URL              string    `json:"url"`
	Status           string    `json:"status"`
	PinCount         int       `json:"pin_count"`
	FirstPinFeedback string    `json:"first_pin_feedback"`
	Reporter         *Reporter `json:"reporter"`
	UpdatedAt        string    `json:"updated_at"`
	FreeTierLocked   bool      `json:"free_tier_locked"`
}

SessionSummary is a compact session record returned by ListSessions.

Jump to

Keyboard shortcuts

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