MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / NewClientFromURL

Function NewClientFromURL

internal/cli/client.go:40–77  ·  view source on GitHub ↗

NewClientFromURL creates a client from a full base URL (e.g., "https://app.getpad.dev").

(baseURL string)

Source from the content-addressed store, hash-verified

38
39// NewClientFromURL creates a client from a full base URL (e.g., "https://app.getpad.dev").
40func NewClientFromURL(baseURL string) *Client {
41 baseURL = strings.TrimRight(baseURL, "/")
42 c := &Client{
43 baseURL: baseURL + "/api/v1",
44 httpClient: &http.Client{
45 Timeout: 10 * time.Second,
46 },
47 // Long-running transfer client for streaming endpoints
48 // (workspace export bundles in/out, future S3 downloads).
49 // 10s on the default client is the right SLA for normal API
50 // calls but kills a multi-GiB bundle upload mid-stream over
51 // anything but a fast local link. 1 hour is generous enough
52 // for ~100 MB/s uplinks shipping a 350 GiB bundle and still
53 // caps a hung connection eventually. (Codex review on PR
54 // #306 round 2.)
55 streamClient: &http.Client{
56 Timeout: 1 * time.Hour,
57 },
58 }
59
60 // Auto-load credentials for THIS server URL if any are saved. We use
61 // the original baseURL (without the /api/v1 suffix added below) so
62 // the lookup matches what login/save commands key on. Credentials
63 // for other servers are left untouched in the store — see TASK-1228
64 // / IDEA-1226 for the per-server design.
65 if store, err := LoadStore(); err == nil {
66 if creds := store.Get(baseURL); creds != nil {
67 c.authToken = creds.Token
68 }
69 }
70
71 // Auto-load agent name from .pad.toml if available
72 if pt, _ := LoadPadToml(); pt != nil && pt.AgentName != "" {
73 c.agentName = pt.AgentName
74 }
75
76 return c
77}
78
79// SetAuthToken sets the authorization token for API requests.
80func (c *Client) SetAuthToken(token string) {

Callers 15

setupCmdFunction · 0.92
loginCmdFunction · 0.92
logoutCmdFunction · 0.92
whoamiCmdFunction · 0.92
resetPasswordCmdFunction · 0.92
initCmdFunction · 0.92
collectServerInfoFunction · 0.92
completeCollectionNamesFunction · 0.92
padInitCmdFunction · 0.92

Calls 3

LoadStoreFunction · 0.85
LoadPadTomlFunction · 0.85
GetMethod · 0.65