Documentation
¶
Overview ¶
Package api hosts the HTTP API layer that wraps the clanker agent.
Phase 4 (per the planning doc) — exposes Tencent Cloud inventory and helper endpoints as JSON so the React/Vite dashboard (Phase 5+) can drive the agent without shelling out to the CLI.
The server uses stdlib net/http (Go 1.22+ pattern routing) — no third party router needed at this scale.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetVersion ¶
func SetVersion(v string)
SetVersion sets the version string returned by the /api/v1/version endpoint. Called once from cmd/server.go after main() initialises cmd.Version.
Types ¶
type ApplyRecord ¶
type ApplyRecord struct {
ID int64 `json:"id"`
StartedAt time.Time `json:"started_at"`
Provider string `json:"provider"`
Status string `json:"status"` // "ok" or "error"
Duration string `json:"duration"`
Destroyer bool `json:"destroyer"`
CommandCount int `json:"command_count"`
DestructiveCount int `json:"destructive_count"`
Summary string `json:"summary,omitempty"`
Question string `json:"question,omitempty"`
Error string `json:"error,omitempty"`
Output string `json:"output,omitempty"`
OutputTruncated bool `json:"output_truncated,omitempty"`
}
ApplyRecord is what /api/v1/maker/history returns for each past apply.
Output is truncated server-side so the list endpoint stays cheap. For full output a future endpoint can fetch by ID.
type Config ¶
type Config struct {
Addr string // listen address, e.g. ":8080"
Token string // bearer token; required unless Insecure is true
Insecure bool // explicit opt-in to running without auth; refused otherwise
CORSOrigin string // value for Access-Control-Allow-Origin; defaults to http://localhost:4173 (the bundled dashboard)
ReadTimeout time.Duration
WriteTimeout time.Duration
Debug bool
}
Config controls how the HTTP server is bound and how requests are authorised. A missing Token aborts startup unless Insecure is set explicitly — see Server.Run.