client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentActivity added in v0.3.0

type AgentActivity struct {
	ID           int64  `json:"id"`
	Action       string `json:"action"`
	AgentID      *int64 `json:"agent_id"`
	AgentDisplay string `json:"agent_display"`
	PinNumber    *int64 `json:"pin_number"`
	Field        string `json:"field"`
	Status       string `json:"status"`
	Note         string `json:"note"`
	CreatedAt    string `json:"created_at"`
}

AgentActivity is an append-only agent pickup or status-change entry.

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 Attachment added in v0.3.0

type Attachment struct {
	ID          int64  `json:"id"`
	Filename    string `json:"filename"`
	ContentType string `json:"content_type"`
	SizeBytes   int64  `json:"size_bytes"`
}

Attachment is compact metadata for a file attached to a pin.

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) DownloadAttachment added in v0.3.0

func (c *Client) DownloadAttachment(
	ctx context.Context,
	pinRef ref.PinRef,
	attachmentID int64,
) (*DownloadedAttachment, error)

DownloadAttachment downloads one attachment through the scoped agent API.

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.

func (*Client) SetPinStatus added in v0.3.0

func (c *Client) SetPinStatus(
	ctx context.Context,
	pinRef ref.PinRef,
	status string,
	note string,
) (*PinStatusResult, error)

SetPinStatus updates a scoped pin and returns its identity, status, and pin-specific agent activity.

func (*Client) SetSessionStatus added in v0.3.0

func (c *Client) SetSessionStatus(
	ctx context.Context,
	sessionRef ref.SessionRef,
	status string,
	note string,
) (*SessionStatusResult, error)

SetSessionStatus updates a scoped session and returns its identity, status, and agent activity.

type DownloadedAttachment added in v0.3.0

type DownloadedAttachment struct {
	ID          int64  `json:"id"`
	Filename    string `json:"filename"`
	ContentType string `json:"content_type"`
	SizeBytes   int64  `json:"size_bytes"`
	Data        []byte `json:"-"`
}

DownloadedAttachment contains attachment bytes and response metadata.

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"`
	AgentLog       []AgentActivity  `json:"agent_log"`
}

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"`
	AgentLog       []AgentActivity  `json:"agent_log"`
}

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"`
	Status      string         `json:"status"`
	URL         *string        `json:"url"`
	Selector    *string        `json:"selector"`
	ElementInfo map[string]any `json:"element_info"`
	Metadata    map[string]any `json:"metadata"`
	Attachments []Attachment   `json:"attachments"`
}

PinLite is a compact pin record embedded in session responses.

type PinStatusResult added in v0.3.0

type PinStatusResult struct {
	Number   int64           `json:"number"`
	Status   string          `json:"status"`
	AgentLog []AgentActivity `json:"agent_log"`
}

PinStatusResult is the compact result of a pin status mutation.

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 SessionAttachment added in v0.3.0

type SessionAttachment struct {
	Attachment
	PinNumber int64 `json:"pin_number"`
}

SessionAttachment identifies an attachment and the pin that owns it in session summaries.

type SessionDetail

type SessionDetail struct {
	Title                string          `json:"title"`
	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"`
	AgentLog             []AgentActivity `json:"agent_log"`
}

SessionDetail is a full session record with its pins.

type SessionStatusResult added in v0.3.0

type SessionStatusResult 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"`
	AgentLog             []AgentActivity `json:"agent_log"`
}

SessionStatusResult is the compact result of a session status mutation.

type SessionSummary

type SessionSummary struct {
	Title                string              `json:"title"`
	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"`
	Attachments          []SessionAttachment `json:"attachments"`
}

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.

type StatusUpdate added in v0.3.0

type StatusUpdate struct {
	Status string `json:"status"`
	Note   string `json:"note,omitempty"`
}

StatusUpdate requests an explicit status transition and optional agent note.

Directories

Path Synopsis
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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