{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cloudclient\n\nPackage 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.\n\n## Types\n\n```go\ntype ByokKey struct {\n\tProvider  string `json:\"provider\"`\n\tTail      string `json:\"tail\"`\n\tStatus    string `json:\"status\"`\n\tCreatedAt string `json:\"created_at,omitempty\"`\n\tUpdatedAt string `json:\"updated_at,omitempty\"`\n}\n```\nByokKey is one masked key row (never the key itself).\n\n```go\ntype ByokKeys struct {\n\tProviders []string  `json:\"providers\"`\n\tKeys      []ByokKey `json:\"keys\"`\n\tWarning   string    `json:\"warning,omitempty\"`\n}\n```\nByokKeys is the /v1/byok/keys listing: the server-enumerated provider roster (registry-derived — clients never hardcode it) + this user's rows.\n\n```go\ntype ByokPutResult struct {\n\tProvider string `json:\"provider\"`\n\tTail     string `json:\"tail\"`\n\tStatus   string `json:\"status\"`\n\tWarning  string `json:\"warning,omitempty\"`\n}\n```\nByokPutResult is the masked outcome of storing a key.\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient talks to one memcode gateway deployment.\n\n```go\nfunc New(baseURL, token string, opts ...Option) *Client\n```\nNew returns a client for the hosted gateway.\n\n```go\nfunc (c *Client) Advise(ctx context.Context, question, effort string) (string, error)\n```\nAdvise 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).\n\n```go\nfunc (c *Client) ByokDelete(ctx context.Context, provider string) error\n```\nByokDelete removes the user's key for provider.\n\n```go\nfunc (c *Client) ByokList(ctx context.Context) (ByokKeys, error)\n```\nByokList fetches the provider roster + the user's masked key rows.\n\n```go\nfunc (c *Client) ByokPut(ctx context.Context, provider, key string) (ByokPutResult, error)\n```\nByokPut stores (or replaces) the user's key for provider. The gateway live-probes the vendor first by default.\n\n```go\nfunc (c *Client) ByokValidate(ctx context.Context, provider string) (bool, string, error)\n```\nByokValidate live-probes the STORED key. ok=false carries the vendor's complaint in msg.\n\n```go\nfunc (c *Client) SetRetryNotify(fn func(attempt int, err error, delay time.Duration))\n```\nSetRetryNotify 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.\n\n```go\nfunc (c *Client) WebFetch(ctx context.Context, url string) (string, error)\n```\nWebFetch proxies the gateway's server-side web\\_fetch capability.\n\n```go\nfunc (c *Client) WebFetchModel(ctx context.Context, url, model string) (string, error)\n```\nWebFetchModel proxies /v1/webfetch, optionally hinting the pinned model so the gateway routes to the matching vendor's web fetch tool.\n\n```go\nfunc (c *Client) WebSearch(ctx context.Context, query string) (string, error)\n```\nWebSearch proxies the gateway's server-side web\\_search capability.\n\n```go\nfunc (c *Client) WebSearchModel(ctx context.Context, query, model string) (string, error)\n```\nWebSearchModel proxies /v1/websearch, optionally hinting the pinned model so the gateway routes to the matching vendor's web search tool.\n\n```go\ntype Option func(*Client)\n```\nOption configures a Client.\n\n```go\nfunc WithRetryNotify(fn func(attempt int, err error, delay time.Duration)) Option\n```\nWithRetryNotify 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.\n\n","path":"github.com/memcode-ai/memcode/internal/cloudclient","name":"cloudclient","synopsis":"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.","isRedistributable":true}
