cloudclient

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 16 Imported by: 0

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

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 New

func New(baseURL, token string, opts ...Option) *Client

New returns a client for the hosted gateway.

func (*Client) Advise

func (c *Client) Advise(ctx context.Context, question, effort string) (string, error)

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

func (c *Client) ByokDelete(ctx context.Context, provider string) error

ByokDelete removes the user's key for provider.

func (*Client) ByokList

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

ByokList fetches the provider roster + the user's masked key rows.

func (*Client) ByokPut

func (c *Client) ByokPut(ctx context.Context, provider, key string) (ByokPutResult, error)

ByokPut stores (or replaces) the user's key for provider. The gateway live-probes the vendor first by default.

func (*Client) ByokValidate

func (c *Client) ByokValidate(ctx context.Context, provider string) (bool, string, error)

ByokValidate live-probes the STORED key. ok=false carries the vendor's complaint in msg.

func (*Client) SetRetryNotify

func (c *Client) SetRetryNotify(fn func(attempt int, err error, delay time.Duration))

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.

func (*Client) WebFetch

func (c *Client) WebFetch(ctx context.Context, url string) (string, error)

WebFetch proxies the gateway's server-side web_fetch capability.

func (*Client) WebSearch

func (c *Client) WebSearch(ctx context.Context, query string) (string, error)

WebSearch proxies the gateway's server-side web_search capability.

type Option

type Option func(*Client)

Option configures a Client.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient overrides the default HTTP client (for tests or a custom timeout).

func WithRetryNotify

func WithRetryNotify(fn func(attempt int, err error, delay time.Duration)) Option

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.

Jump to

Keyboard shortcuts

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