api

package
v0.1.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRequest

type AuthRequest struct {
	Method        string `json:"method,omitempty"`        // "token" | "ssh-agent" | "ssh-key" | ""
	Token         string `json:"token,omitempty"`         // ephemeral plaintext
	CredentialRef string `json:"credentialRef,omitempty"` // e.g. "${vault:GIT_TOKEN}"
	SSHUser       string `json:"sshUser,omitempty"`
	SSHKeyPath    string `json:"sshKeyPath,omitempty"`
}

AuthRequest is the optional auth payload accepted on /api/skills/sources/* endpoints. Raw Token values are transient; CredentialRef (e.g. "${vault:GIT_TOKEN}") is resolved against the live vault on every request.

type ClientStatus

type ClientStatus struct {
	Name       string `json:"name"`
	Slug       string `json:"slug"`
	Detected   bool   `json:"detected"`
	Linked     bool   `json:"linked"`
	Transport  string `json:"transport"`
	ConfigPath string `json:"configPath,omitempty"`
	// Model is the client's declared pricing model from stack.yaml
	// client_models, when present. Pricing attribution only — it carries no
	// access-control meaning and is independent of EffectiveScope.
	Model string `json:"model,omitempty"`
	// EffectiveModel reports which model actually priced this client's
	// recorded cost, with provenance (declared | mixed | none). Read-only
	// and derived from observed cost; nil when the client has no traffic.
	EffectiveModel *EffectiveModel `json:"effectiveModel,omitempty"`
	// EffectiveScope is the backend-computed per-client tool access scope when a
	// `clients:` block is configured: the servers and prefixed tools this client
	// can reach. nil when no access scoping is in effect, so the frontend can
	// distinguish "unscoped (legacy)" from "scoped to nothing".
	EffectiveScope *mcp.ClientScopeResult `json:"effectiveScope,omitempty"`
}

ClientStatus describes an LLM client's detection and link state.

type EffectiveModel

type EffectiveModel struct {
	Model      string       `json:"model,omitempty"`
	Provenance string       `json:"provenance"`
	Share      float64      `json:"share,omitempty"`
	Models     []ModelShare `json:"models,omitempty"`
}

EffectiveModel is the read-time interpretation of which model(s) priced an entity's (client or server) traffic, with provenance. It describes which declaration gridctl applied when pricing the traffic — NOT which model the upstream client actually used; the gateway cannot observe that. Model and Share describe the dominant entry; Models lists every model that priced the entity, descending by cost.

type MCPServerStatus

type MCPServerStatus struct {
	Name          string   `json:"name"`
	Transport     string   `json:"transport"`
	Endpoint      string   `json:"endpoint"`
	Initialized   bool     `json:"initialized"`
	ToolCount     int      `json:"toolCount"`
	Tools         []string `json:"tools"`
	External      bool     `json:"external"`
	LocalProcess  bool     `json:"localProcess"`
	SSH           bool     `json:"ssh"`
	SSHHost       string   `json:"sshHost,omitempty"`
	OpenAPI       bool     `json:"openapi"`
	OpenAPISpec   string   `json:"openapiSpec,omitempty"`
	OutputFormat  string   `json:"outputFormat,omitempty"`
	Healthy       *bool    `json:"healthy,omitempty"`
	LastCheck     *string  `json:"lastCheck,omitempty"`
	HealthError   string   `json:"healthError,omitempty"`
	ToolWhitelist []string `json:"toolWhitelist,omitempty"`
	// Model is the pricing model DECLARED on this server in stack.yaml
	// (model: field only — a gateway default_model is not folded in here).
	// Empty when the server inherits the default or has no attribution.
	Model string `json:"model,omitempty"`
	// EffectiveModel reports which model actually priced this server's
	// recorded cost, with provenance (declared | mixed | none). Read-only
	// and derived from observed cost; nil when the server has no traffic.
	EffectiveModel *EffectiveModel `json:"effectiveModel,omitempty"`

	Replicas  []mcp.ReplicaStatus  `json:"replicas,omitempty"`
	Autoscale *mcp.AutoscaleStatus `json:"autoscale,omitempty"`
}

MCPServerStatus mirrors the mcp.MCPServerStatus type for API responses.

type ModelShare

type ModelShare struct {
	Model   string  `json:"model"`
	CostUSD float64 `json:"cost_usd"`
	Share   float64 `json:"share"`
}

ModelShare is one model's slice of an entity's recorded cost: the model ID, its USD cost, and its share (0–1) of the entity's total recorded cost.

type ResourceStatus

type ResourceStatus struct {
	Name   string `json:"name"`
	Image  string `json:"image"`
	Status string `json:"status"`
}

ResourceStatus contains status information for a resource container.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server provides the combined API server for gridctl.

func NewServer

func NewServer(gateway *mcp.Gateway, staticFS fs.FS) *Server

NewServer creates a new API server.

func (*Server) Close

func (s *Server) Close()

Close performs cleanup of the API server's managed resources.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the main HTTP handler.

func (*Server) LogBuffer

func (s *Server) LogBuffer() *logging.LogBuffer

LogBuffer returns the log buffer for gateway logs.

func (*Server) MetricsAccumulator

func (s *Server) MetricsAccumulator() *metrics.Accumulator

MetricsAccumulator returns the token metrics accumulator.

func (*Server) PinStore

func (s *Server) PinStore() *pins.PinStore

PinStore returns the wired pin store, or nil when schema pinning is not configured. Exposed so callers and tests can confirm whether pin management is active.

func (*Server) RegistryServer

func (s *Server) RegistryServer() *registry.Server

RegistryServer returns the registry server.

func (*Server) ReloadHandler

func (s *Server) ReloadHandler() *reload.Handler

ReloadHandler returns the reload handler.

func (*Server) SetAllowedOrigins

func (s *Server) SetAllowedOrigins(origins []string)

SetAllowedOrigins sets the CORS allowed origins for the server.

func (*Server) SetAuth

func (s *Server) SetAuth(authType, token, header string)

SetAuth configures authentication for the server. When configured, all requests (except /health and /ready) must include a valid token.

func (*Server) SetClientModelAttribution

func (s *Server) SetClientModelAttribution(get func() map[string]string)

SetClientModelAttribution sets a getter for the client ID -> model mapping (stack.yaml client_models) used to price tool calls by calling client. Same contract as SetModelAttribution: the getter follows hot reloads and must be safe for concurrent calls. Feeds the /api/status client_models exposure, the cost_attribution flag, and the /api/clients model field.

func (*Server) SetDeclaredServerModels

func (s *Server) SetDeclaredServerModels(get func() map[string]string)

SetDeclaredServerModels sets a getter for the server -> model mapping as declared in stack.yaml (per-server model: only). Same contract as SetModelAttribution: the getter follows hot reloads and must be safe for concurrent calls. Feeds the /api/status server model exposure.

func (*Server) SetDefaultModel

func (s *Server) SetDefaultModel(get func() string)

SetDefaultModel sets a getter for the gateway-level default_model. The getter follows hot reloads and must be safe for concurrent calls. Feeds the /api/status default_model exposure.

func (*Server) SetDockerClient

func (s *Server) SetDockerClient(cli dockerclient.DockerClient)

SetDockerClient sets the Docker client for container operations.

func (*Server) SetGatewayAddr

func (s *Server) SetGatewayAddr(addr string)

SetGatewayAddr sets the base URL of this server (e.g. "http://localhost:8180"). Used to build the MCP config JSON for CLI proxy sessions so the claude CLI can reach gridctl's MCP gateway at <gatewayAddr>/sse.

func (*Server) SetLogBuffer

func (s *Server) SetLogBuffer(buffer *logging.LogBuffer)

SetLogBuffer sets the log buffer for gateway logs.

func (*Server) SetMetricsAccumulator

func (s *Server) SetMetricsAccumulator(acc *metrics.Accumulator)

SetMetricsAccumulator sets the token metrics accumulator.

func (*Server) SetModelAttribution

func (s *Server) SetModelAttribution(get func() map[string]string)

SetModelAttribution sets a getter for the server -> model mapping used to price tool calls. The getter (rather than a static map) lets hot reloads of `model:` / `default_model:` reach handlers without re-wiring; it must be safe for concurrent calls. Feeds the optimize model stats and the /api/status cost_attribution flag.

func (*Server) SetPinStore

func (s *Server) SetPinStore(ps *pins.PinStore)

SetPinStore sets the pin store for schema pin management.

func (*Server) SetProber

func (s *Server) SetProber(p *probe.Prober)

SetProber wires an externally-constructed prober. The API server owns the limiter but the prober's cache and spawner come from the gateway builder.

func (*Server) SetProvisionerRegistry

func (s *Server) SetProvisionerRegistry(r *provisioner.Registry, serverName string)

SetProvisionerRegistry sets the provisioner registry for client detection.

func (*Server) SetRegistryServer

func (s *Server) SetRegistryServer(r *registry.Server)

SetRegistryServer sets the registry server for skill management.

func (*Server) SetReloadHandler

func (s *Server) SetReloadHandler(h *reload.Handler)

SetReloadHandler sets the reload handler for hot reload support.

func (*Server) SetSkillSourcePaths

func (s *Server) SetSkillSourcePaths(lockPath, configPath string)

SetSkillSourcePaths overrides the skill lock-file and skills.yaml paths used by /api/skills/* handlers. Empty values keep the global defaults.

func (*Server) SetSkillUpdateCachePath

func (s *Server) SetSkillUpdateCachePath(path string)

SetSkillUpdateCachePath overrides the skill update cache path. Empty keeps the global default. Tests use this to isolate from $HOME/.gridctl/cache.

func (*Server) SetStackFile

func (s *Server) SetStackFile(path string)

SetStackFile sets the path to the stack YAML file for spec endpoints.

func (*Server) SetStackName

func (s *Server) SetStackName(name string)

SetStackName sets the stack name for container lookups.

func (*Server) SetStartWatcher

func (s *Server) SetStartWatcher(fn func(stackPath string))

SetStartWatcher sets a callback that activates live-reload file watching for the given stack path. Called by POST /api/stack/initialize after cold-loading.

func (*Server) SetTokenizerName

func (s *Server) SetTokenizerName(name string)

SetTokenizerName sets the active tokenizer mode for display in /api/status.

func (*Server) SetTraceBuffer

func (s *Server) SetTraceBuffer(buf *tracing.Buffer)

SetTraceBuffer sets the distributed tracing ring buffer.

func (*Server) SetVaultStore

func (s *Server) SetVaultStore(v *vault.Store)

SetVaultStore sets the vault store for secrets management.

type ServerInfo

type ServerInfo struct {
	Name      string `json:"name"`
	Version   string `json:"version"`
	Tokenizer string `json:"tokenizer,omitempty"`
}

ServerInfo mirrors the mcp.ServerInfo type for API responses.

type SkillDiffResponse

type SkillDiffResponse struct {
	Skill       string `json:"skill"`
	Local       string `json:"local"`
	Upstream    string `json:"upstream"`
	UnifiedDiff string `json:"unifiedDiff,omitempty"`
	Drifted     bool   `json:"drifted"`
}

SkillDiffResponse is the body of the per-skill compare-with-upstream endpoint.

type SkillPreview

type SkillPreview struct {
	Name        string                   `json:"name"`
	Description string                   `json:"description"`
	Body        string                   `json:"body"`
	Valid       bool                     `json:"valid"`
	Errors      []string                 `json:"errors,omitempty"`
	Warnings    []string                 `json:"warnings,omitempty"`
	Findings    []skills.SecurityFinding `json:"findings,omitempty"`
	Exists      bool                     `json:"exists"`
}

SkillPreview represents a previewed skill from a repo (not yet imported).

type SkillSourceEntry

type SkillSourceEntry struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	State       string `json:"state"`
	IsRemote    bool   `json:"isRemote"`
	ContentHash string `json:"contentHash,omitempty"`
	// HasLocalEdits is true when the on-disk SKILL.md diverges from the hash
	// snapshotted at the last import/sync (i.e. the user edited it locally).
	HasLocalEdits bool `json:"hasLocalEdits"`
}

SkillSourceEntry represents a single skill within a source.

type SkillSourceStatus

type SkillSourceStatus struct {
	Name           string             `json:"name"`
	Repo           string             `json:"repo"`
	Ref            string             `json:"ref,omitempty"`
	Path           string             `json:"path,omitempty"`
	AutoUpdate     bool               `json:"autoUpdate"`
	UpdateInterval string             `json:"updateInterval"`
	Skills         []SkillSourceEntry `json:"skills"`
	LastFetched    string             `json:"lastFetched,omitempty"`
	CommitSHA      string             `json:"commitSha,omitempty"`
	UpdateAvail    bool               `json:"updateAvailable"`
	// DriftedSkills lists the skills in this source whose on-disk SKILL.md has
	// local edits (drift) that a sync would otherwise overwrite.
	DriftedSkills []string `json:"driftedSkills,omitempty"`
}

SkillSourceStatus represents a skill source with its update status.

type SkillSyncResult

type SkillSyncResult struct {
	Skill    string   `json:"skill"`
	Imported int      `json:"imported,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
	Error    string   `json:"error,omitempty"`
	// Skipped, when set, is the reason a drifted skill was left untouched
	// (e.g. "local edits"). Its tracking metadata is still advanced.
	Skipped string `json:"skipped,omitempty"`
	// Backup is the file name of the pre-overwrite SKILL.md backup written
	// when a drifted skill was force-overwritten.
	Backup string `json:"backup,omitempty"`
}

SkillSyncResult is the per-skill outcome within a sync.

type SourceSyncResult

type SourceSyncResult struct {
	Name   string            `json:"name"`
	Repo   string            `json:"repo"`
	Pinned bool              `json:"pinned,omitempty"`
	Skills []SkillSyncResult `json:"skills,omitempty"`
	Error  string            `json:"error,omitempty"`
}

SourceSyncResult is the per-source outcome of a bulk sync.

type SourceSyncSummary

type SourceSyncSummary struct {
	Sources       []SourceSyncResult `json:"sources"`
	SyncedSources int                `json:"syncedSources"`
	UpdatedSkills int                `json:"updatedSkills"`
	SkippedSkills int                `json:"skippedSkills"`
	FailedSources int                `json:"failedSources"`
	PinnedSources int                `json:"pinnedSources"`
}

SourceSyncSummary is the aggregate response from a bulk sync.

type SourceUpdateSummary

type SourceUpdateSummary struct {
	Name      string `json:"name"`
	Repo      string `json:"repo"`
	Current   string `json:"currentSha"`
	Latest    string `json:"latestSha,omitempty"`
	HasUpdate bool   `json:"hasUpdate"`
	Error     string `json:"error,omitempty"`
}

SourceUpdateSummary represents update status for a single source.

type StackRecipe

type StackRecipe struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Category    string `json:"category"`
	Spec        string `json:"spec"`
}

StackRecipe is a pre-built stack template.

type UpdateSummary

type UpdateSummary struct {
	Available int                   `json:"available"`
	Sources   []SourceUpdateSummary `json:"sources"`
}

UpdateSummary represents pending updates across all sources.

type WizardDraft

type WizardDraft struct {
	ID           string                 `json:"id"`
	Name         string                 `json:"name"`
	ResourceType string                 `json:"resourceType"`
	FormData     map[string]interface{} `json:"formData"`
	CreatedAt    string                 `json:"createdAt"`
	UpdatedAt    string                 `json:"updatedAt"`
}

WizardDraft represents a saved wizard draft.

Jump to

Keyboard shortcuts

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