Documentation
¶
Overview ¶
Package cloudclient is the CLI's HTTP client for the memcode gateway's SIDE-CHANNEL surfaces: /v1/advisor, /v1/websearch, /v1/webfetch, and the /v1/byok key-management routes. The TURN wire lives elsewhere — the shared providers/memcode transport (OpenAI-compat + the memcode extensions). Every call here rides requestWithRetry (Cloud Run cold-start 5xx / 429 / transient net errors), with SetRetryNotify surfacing "⊙ retrying…" in the TUI.
Index ¶
- type ByokKey
- type ByokKeys
- type ByokPutResult
- type Client
- func (c *Client) Advise(ctx context.Context, question, effort string) (string, error)
- func (c *Client) ByokDelete(ctx context.Context, provider string) error
- func (c *Client) ByokList(ctx context.Context) (ByokKeys, error)
- func (c *Client) ByokPut(ctx context.Context, provider, key string) (ByokPutResult, error)
- func (c *Client) ByokValidate(ctx context.Context, provider string) (bool, string, error)
- func (c *Client) SetRetryNotify(fn func(attempt int, err error, delay time.Duration))
- func (c *Client) WebFetch(ctx context.Context, url string) (string, error)
- func (c *Client) WebSearch(ctx context.Context, query string) (string, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByokKey ¶
type ByokKey struct {
Provider string `json:"provider"`
Tail string `json:"tail"`
Status string `json:"status"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
}
ByokKey is one masked key row (never the key itself).
type ByokKeys ¶
type ByokKeys struct {
Providers []string `json:"providers"`
Keys []ByokKey `json:"keys"`
Warning string `json:"warning,omitempty"`
}
ByokKeys is the /v1/byok/keys listing: the server-enumerated provider roster (registry-derived — clients never hardcode it) + this user's rows.
type ByokPutResult ¶
type ByokPutResult struct {
Provider string `json:"provider"`
Tail string `json:"tail"`
Status string `json:"status"`
Warning string `json:"warning,omitempty"`
}
ByokPutResult is the masked outcome of storing a key.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one memcode gateway deployment.
func (*Client) Advise ¶
Advise asks the gateway's second-opinion advisor (a different vendor, reasoning on) for guidance on the best path forward. effort is the reasoning depth (low|medium|high; "" → high).
func (*Client) ByokDelete ¶
ByokDelete removes the user's key for provider.
func (*Client) ByokPut ¶
ByokPut stores (or replaces) the user's key for provider. The gateway live-probes the vendor first by default.
func (*Client) ByokValidate ¶
ByokValidate live-probes the STORED key. ok=false carries the vendor's complaint in msg.
func (*Client) SetRetryNotify ¶
SetRetryNotify wires a retry-notify callback AFTER construction (e.g. from the runtime, which doesn't own the client at provider.NewFromEnv time). Same callback contract as WithRetryNotify. Non-breaking: nil = silent retry.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient overrides the default HTTP client (for tests or a custom timeout).
func WithRetryNotify ¶
WithRetryNotify registers a callback invoked before each retry backoff, so a caller (the runtime loop) can surface "⊙ retrying…" in the TUI. The attempt is 1-based (1 = first retry); err is the failure that triggered the retry; delay is the backoff the client is about to sleep. Non-breaking: callers that don't set it get silent retry.