Documentation
¶
Overview ¶
Package client provides an HTTP client for the BuildMax server API.
Index ¶
- Constants
- Variables
- func NewArtifactPublisher(serverURL, teamID string, token TokenFunc) tool.ArtifactPublisher
- type ArtifactPublisher
- type Client
- func (c *Client) DownloadRelease(ctx context.Context, token, name, version string, allowYanked bool, ...) (string, error)
- func (c *Client) GetPlugin(ctx context.Context, token, name string) (*pluginwire.PluginResponse, error)
- func (c *Client) ListPlugins(ctx context.Context, token string) ([]model.Plugin, error)
- func (c *Client) ListTeamModels(ctx context.Context, token, teamID string) ([]llmwire.Model, error)
- func (c *Client) Login(ctx context.Context, email, otp, platform string) (*LoginResponse, error)
- func (c *Client) LoginWithPassword(ctx context.Context, email, password, platform string) (*LoginResponse, error)
- func (c *Client) Logout(ctx context.Context, refreshToken, accessToken string) error
- func (c *Client) PublishRelease(ctx context.Context, token, name string, body io.Reader, ...) (*model.PluginRelease, error)
- func (c *Client) Refresh(ctx context.Context, refreshToken string) (*RefreshResponse, error)
- func (c *Client) RequestOTP(ctx context.Context, email, intent string) error
- func (c *Client) SetPluginArchived(ctx context.Context, token, name string, archived bool) error
- func (c *Client) YankRelease(ctx context.Context, token, name, version, reason string) error
- type LoginResponse
- type LoginUser
- type RefreshResponse
- type TokenFunc
Constants ¶
const DefaultServerURL = "http://localhost:5678"
DefaultServerURL is where a client looks when nobody has named a server: the address buildmax-server listens on when it runs on this machine. It is the last fallback, not an assumption — settings.yaml's server_url wins, and a deployment behind an ingress publishes one origin for Portal and API that is not this one.
Variables ¶
var ErrRefreshRejected = errors.New("refresh token rejected")
ErrRefreshRejected means the server refused the refresh token: it is spent, revoked, expired, or was replayed. The session is over and only a new login will produce another.
Functions ¶
func NewArtifactPublisher ¶
func NewArtifactPublisher(serverURL, teamID string, token TokenFunc) tool.ArtifactPublisher
NewArtifactPublisher returns a publisher, or nil when this surface has no server to reach. Returning nil is what leaves the tool unregistered.
Types ¶
type ArtifactPublisher ¶
type ArtifactPublisher struct {
ServerURL string
// TeamID is optional. Empty means the server keeps the artifact in the
// caller's personal team, which is what a client that has never been asked
// to choose a team should get.
TeamID string
Token TokenFunc
HTTP *http.Client
}
ArtifactPublisher publishes a local file through a BuildMax server on the signed-in person's session.
It exists only where there is a server to publish to. A CLI or Desktop session running straight against a model provider has no artifact capability at all, and its agent is given no artifact tool — see docs/design/unified-artifacts.md section 7.1.
func (*ArtifactPublisher) PublishArtifact ¶
func (p *ArtifactPublisher) PublishArtifact(ctx context.Context, in tool.ArtifactUpload) (tool.PublishedArtifact, error)
PublishArtifact implements tool.ArtifactPublisher.
type Client ¶
Client is a stateless HTTP client for the BuildMax server API.
func (*Client) DownloadRelease ¶
func (c *Client) DownloadRelease(ctx context.Context, token, name, version string, allowYanked bool, w io.Writer) (string, error)
DownloadRelease streams one release's bytes into w and returns the digest the server sent with them.
The bytes are copied straight through rather than collected: a package is bounded, but bounded at tens of megabytes, and the caller is writing to a staging file anyway.
func (*Client) GetPlugin ¶
func (c *Client) GetPlugin(ctx context.Context, token, name string) (*pluginwire.PluginResponse, error)
GetPlugin returns one entry and every release published under it, withdrawn ones included and marked.
func (*Client) ListPlugins ¶
ListPlugins returns the deployment's browsable catalog.
func (*Client) ListTeamModels ¶
ListTeamModels calls GET /api/teams/{team_id}/llm/models and returns the model aliases the team may use through the managed gateway.
The reply names aliases only. Which provider serves one, and with whose credential, stays on the server.
func (*Client) Login ¶
Login calls POST /api/login with a single-use login code — the recovery path, used to claim a new account or replace a forgotten password. platform identifies the calling client ("cli", "desktop", "portal").
func (*Client) LoginWithPassword ¶
func (c *Client) LoginWithPassword(ctx context.Context, email, password, platform string) (*LoginResponse, error)
LoginWithPassword calls POST /api/login with a password, the everyday way in.
func (*Client) PublishRelease ¶
func (c *Client) PublishRelease( ctx context.Context, token, name string, body io.Reader, source model.PluginReleaseSource, ) (*model.PluginRelease, error)
PublishRelease uploads one package.
The body is the archive itself, streamed from the reader, and the claim about where it came from travels beside it. The server hashes and inspects what it receives, so nothing here is trusted on the far side.
func (*Client) Refresh ¶
Refresh calls POST /api/token/refresh, exchanging a refresh token for a new pair.
A rejected token returns ErrRefreshRejected, which the caller must be able to tell apart from the server being unreachable: one means sign in again, the other means try later.
func (*Client) RequestOTP ¶
RequestOTP calls POST /api/otp/request. intent is "login" or "signup".
func (*Client) SetPluginArchived ¶
SetPluginArchived retires or restores a catalog entry.
type LoginResponse ¶
type LoginResponse struct {
// Token is AccessToken under the name it had before a login returned two
// credentials. A server older than that split sends only this one.
Token string `json:"token"`
AccessToken string `json:"access_token"`
// RefreshToken is empty when the server keeps no store for it, which means
// the login ends when the access token does.
RefreshToken string `json:"refresh_token"`
ExpiresIn int64 `json:"expires_in"`
User LoginUser `json:"user"`
}
LoginResponse is the successful result of POST /api/login.
func (*LoginResponse) Access ¶
func (r *LoginResponse) Access() string
Access returns the access token under whichever name the server used.
type LoginUser ¶
type LoginUser struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
}
LoginUser is the user subset returned in a login response.
type RefreshResponse ¶
type RefreshResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int64 `json:"expires_in"`
}
RefreshResponse is the successful result of POST /api/token/refresh.