Documentation
¶
Overview ¶
Package vercel provides a client for the Vercel REST API and related CLI tooling (the `vercel` CLI for deploys). Mirrors the shape of the Cloudflare package so wiring into cmd/, routing, ask-mode and the desktop backend stays uniform.
Index ¶
- Constants
- func CreateVercelCommands() *cobra.Command
- func ResolveAPIToken() string
- func ResolveTeamID() string
- type Alias
- type BackendVercelCredentials
- type BlobStore
- type Client
- func (c *Client) CancelDeployment(ctx context.Context, deploymentID string) (string, error)
- func (c *Client) GetAPIToken() string
- func (c *Client) GetRelevantContext(ctx context.Context, question string) (string, error)
- func (c *Client) GetTeamID() string
- func (c *Client) PromoteDeployment(ctx context.Context, projectID, deploymentID string) error
- func (c *Client) RunAPI(method, endpoint, body string) (string, error)
- func (c *Client) RunAPIWithContext(ctx context.Context, method, endpoint, body string) (string, error)
- func (c *Client) RunVercelCLI(args ...string) (string, error)
- func (c *Client) RunVercelCLIWithContext(ctx context.Context, args ...string) (string, error)
- func (c *Client) RunVercelCLIWithStdin(ctx context.Context, stdinData string, args ...string) (string, error)
- type ConversationEntry
- type ConversationHistory
- type Deployment
- type Domain
- type EdgeConfig
- type EnvVar
- type KVDatabase
- type PostgresDatabase
- type Project
- type Team
- type UsageSummary
- type User
Constants ¶
const MaxAnswerLengthInContext = 500
MaxAnswerLengthInContext limits how much of previous answers to include in context.
const MaxHistoryEntries = 20
MaxHistoryEntries limits the conversation history size.
Variables ¶
This section is empty.
Functions ¶
func CreateVercelCommands ¶
CreateVercelCommands creates the Vercel command tree for static commands. Registered from cmd/root.go as a sibling of `cf`, `do`, `hetzner`, etc.
func ResolveAPIToken ¶
func ResolveAPIToken() string
ResolveAPIToken returns the Vercel API token from config or environment. Resolution order: `vercel.api_token` → VERCEL_TOKEN → VERCEL_API_TOKEN.
func ResolveTeamID ¶
func ResolveTeamID() string
ResolveTeamID returns the Vercel team ID from config or environment. Resolution order: `vercel.team_id` → VERCEL_TEAM_ID → VERCEL_ORG_ID. Team scoping is optional — personal accounts have no team ID.
Types ¶
type Alias ¶
type Alias struct {
UID string `json:"uid"`
Alias string `json:"alias"`
ProjectID string `json:"projectId,omitempty"`
DeploymentID string `json:"deploymentId,omitempty"`
Created int64 `json:"created,omitempty"`
Deployment *struct {
ID string `json:"id,omitempty"`
URL string `json:"url,omitempty"`
} `json:"deployment,omitempty"`
}
Alias represents a Vercel deployment alias (/v4/aliases response).
type BackendVercelCredentials ¶
BackendVercelCredentials represents Vercel credentials retrieved from the backend credential store (clanker-backend).
type BlobStore ¶
type BlobStore struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
}
BlobStore represents a Vercel Blob store.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Vercel REST API and the official `vercel` CLI.
func NewClientWithCredentials ¶
func NewClientWithCredentials(creds *BackendVercelCredentials, debug bool) (*Client, error)
NewClientWithCredentials creates a new Vercel client using backend credentials.
func (*Client) CancelDeployment ¶
CancelDeployment cancels an in-progress deployment using the Vercel REST API. Returns the raw API response so the caller can decide how to present it.
func (*Client) GetAPIToken ¶
GetAPIToken returns the API token.
func (*Client) GetRelevantContext ¶
GetRelevantContext gathers Vercel context for LLM queries. The output is a best-effort dump of the resources most likely to be relevant to the user's question. Sections are keyword-gated to keep the context compact.
func (*Client) PromoteDeployment ¶
PromoteDeployment promotes a deployment to production using the Vercel REST API. This is equivalent to `vercel promote <deploymentId>` but uses the API directly for programmatic use (maker plans, backend handlers, etc.).
Vercel API: POST /v10/projects/{projectID}/promote body: {"id":"<deploymentID>"}
func (*Client) RunAPIWithContext ¶
func (c *Client) RunAPIWithContext(ctx context.Context, method, endpoint, body string) (string, error)
RunAPIWithContext executes a Vercel REST call with a caller-controlled context.
func (*Client) RunVercelCLI ¶
RunVercelCLI executes the official `vercel` CLI tool for operations the REST API does not model well (source upload, prebuilt output, etc.). Phase 2+ callers shell out here; phase 1 clients just rely on REST.
func (*Client) RunVercelCLIWithContext ¶
RunVercelCLIWithContext executes the Vercel CLI with a caller-controlled context.
func (*Client) RunVercelCLIWithStdin ¶
func (c *Client) RunVercelCLIWithStdin(ctx context.Context, stdinData string, args ...string) (string, error)
RunVercelCLIWithStdin executes the Vercel CLI piping stdinData to the process's standard input. Used for commands like `env add` where the CLI reads values from stdin rather than from positional arguments.
type ConversationEntry ¶
type ConversationEntry struct {
Timestamp time.Time `json:"timestamp"`
Question string `json:"question"`
Answer string `json:"answer"`
}
ConversationEntry represents a single Q&A exchange.
type ConversationHistory ¶
type ConversationHistory struct {
Entries []ConversationEntry `json:"entries"`
TeamID string `json:"team_id"`
// contains filtered or unexported fields
}
ConversationHistory maintains conversation state for Vercel ask mode.
func NewConversationHistory ¶
func NewConversationHistory(teamID string) *ConversationHistory
NewConversationHistory creates a new conversation history for a team (or personal account).
func (*ConversationHistory) AddEntry ¶
func (h *ConversationHistory) AddEntry(question, answer string)
AddEntry adds a new conversation entry and prunes old entries.
func (*ConversationHistory) GetRecentContext ¶
func (h *ConversationHistory) GetRecentContext(maxEntries int) string
GetRecentContext returns recent conversation context as a formatted string for inclusion in LLM prompts.
func (*ConversationHistory) Load ¶
func (h *ConversationHistory) Load() error
Load loads conversation history from disk.
func (*ConversationHistory) Save ¶
func (h *ConversationHistory) Save() error
Save persists the conversation history to disk using atomic write (temp + rename).
type Deployment ¶
type Deployment struct {
UID string `json:"uid"`
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
State string `json:"state,omitempty"` // READY, BUILDING, ERROR, CANCELED, QUEUED
ReadyState string `json:"readyState,omitempty"` // legacy alias used by /v6
Target string `json:"target,omitempty"` // "production" | "" (preview)
Type string `json:"type,omitempty"` // LAMBDAS
ProjectID string `json:"projectId,omitempty"`
Created int64 `json:"created,omitempty"` // milliseconds since Unix epoch
Ready int64 `json:"ready,omitempty"` // milliseconds since Unix epoch
Creator *struct {
UID string `json:"uid"`
Username string `json:"username"`
Email string `json:"email,omitempty"`
} `json:"creator,omitempty"`
}
Deployment represents a Vercel deployment.
type Domain ¶
type Domain struct {
Name string `json:"name"`
ProjectID string `json:"projectId,omitempty"`
Verified bool `json:"verified"`
CreatedAt int64 `json:"createdAt,omitempty"` // milliseconds since Unix epoch
UpdatedAt int64 `json:"updatedAt,omitempty"` // milliseconds since Unix epoch
Nameservers []string `json:"nameservers,omitempty"`
}
Domain represents a custom domain.
type EdgeConfig ¶
type EdgeConfig struct {
ID string `json:"id"`
Slug string `json:"slug,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
}
EdgeConfig represents a Vercel Edge Config store.
type EnvVar ¶
type EnvVar struct {
ID string `json:"id"`
Key string `json:"key"`
Value string `json:"value,omitempty"`
Type string `json:"type,omitempty"` // plain, encrypted, system, secret
Target []string `json:"target,omitempty"` // production, preview, development
}
EnvVar represents a project environment variable. The `value` field is only returned when explicitly requested and when the caller's token has `read:env` scope; otherwise the UI must treat keys as opaque and not persist them.
type KVDatabase ¶
type KVDatabase struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
}
KVDatabase represents a Vercel KV (Upstash Redis) store.
type PostgresDatabase ¶
type PostgresDatabase struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
}
PostgresDatabase represents a Vercel Postgres (Neon) instance.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
AccountID string `json:"accountId"`
Framework string `json:"framework,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"` // milliseconds since Unix epoch
UpdatedAt int64 `json:"updatedAt,omitempty"` // milliseconds since Unix epoch
NodeVersion string `json:"nodeVersion,omitempty"`
Link *struct {
Type string `json:"type"`
Repo string `json:"repo,omitempty"`
RepoID int64 `json:"repoId,omitempty"`
ProductionBranch string `json:"productionBranch,omitempty"`
} `json:"link,omitempty"`
LatestDeployments []Deployment `json:"latestDeployments,omitempty"`
Targets map[string]struct {
ID string `json:"id"`
URL string `json:"url"`
Alias []string `json:"alias,omitempty"`
} `json:"targets,omitempty"`
}
Project represents a Vercel project. Fields are a subset of the /v9/projects response — enough for listing and drawer display, not the full schema.
type UsageSummary ¶
type UsageSummary struct {
Bandwidth int64 `json:"bandwidth,omitempty"`
FunctionInvocations int64 `json:"functionInvocations,omitempty"`
EdgeMiddlewareInvocations int64 `json:"edgeMiddlewareInvocations,omitempty"`
BuildMinutes float64 `json:"buildMinutes,omitempty"`
ImageOptimizations int64 `json:"imageOptimizations,omitempty"`
Period string `json:"period,omitempty"`
}
UsageSummary summarizes recent consumption for cost estimation and analytics.