api

package
v0.1.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 48 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"`
}

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

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"`

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

MCPServerStatus mirrors the mcp.MCPServerStatus type for API responses.

type PlaygroundAuthResponse

type PlaygroundAuthResponse struct {
	Providers map[string]PlaygroundProviderAuth `json:"providers"`
	Ollama    struct {
		Reachable bool   `json:"reachable"`
		Endpoint  string `json:"endpoint"`
	} `json:"ollama"`
}

PlaygroundAuthResponse is the body returned by POST /api/playground/auth.

type PlaygroundChatRequest

type PlaygroundChatRequest struct {
	Message   string `json:"message"`
	SessionID string `json:"sessionId"`
	AuthMode  string `json:"authMode"`
	Model     string `json:"model"`
	OllamaURL string `json:"ollamaUrl,omitempty"`
	AgentID   string `json:"agentId,omitempty"`
}

PlaygroundChatRequest is the body accepted by POST /api/playground/chat.

type PlaygroundChatResponse

type PlaygroundChatResponse struct {
	SessionID string `json:"sessionId"`
	Status    string `json:"status"`
}

PlaygroundChatResponse is the body returned by POST /api/playground/chat.

type PlaygroundProviderAuth

type PlaygroundProviderAuth struct {
	APIKey  bool   `json:"apiKey"`
	KeyName string `json:"keyName"`
	CLIPath string `json:"cliPath"`
}

PlaygroundProviderAuth reports whether a single LLM provider has usable auth configured. apiKey reflects the vault state (key resolved successfully); keyName is the vault key referenced (empty when no convention key is found); cliPath is non-empty when a CLI proxy binary is reachable. The frontend surfaces these to the user in the auth banner.

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) 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) SetAgentApprovalRegistry

func (s *Server) SetAgentApprovalRegistry(reg *compose.Registry)

SetAgentApprovalRegistry wires the in-process approval registry the /api/agent/runs/{id}/approve handler falls back to when no runtime aggregate is installed. SetAgentRuntime takes precedence at read time. Retained for test-fixture wiring.

func (*Server) SetAgentDevServer

func (s *Server) SetAgentDevServer(dev *devserver.Server)

SetAgentDevServer wires the agent IDE dev-server endpoints into the daemon's API surface. When set, /api/agent/dev/* routes serve parsed skill graphs and file-watcher events from the configured project root. Passing nil disables the routes — they 503.

The daemon path is convenience: `gridctl agent dev` already stands up its own listener on port 8181 for standalone authoring. When the operator wants the project-aware IDE inside the same web UI as the gateway dashboard, they can wire a dev server here at apply time (or via a future serve flag).

SetAgentRuntime takes precedence over this setter at read time; retained for test fixtures and the current daemon path that builds the dev server out-of-band.

func (*Server) SetAgentRunStore

func (s *Server) SetAgentRunStore(store *persist.Store)

SetAgentRunStore wires the persist.Store the /api/agent/runs/* handlers fall back to when no runtime aggregate is installed. Production callers should use SetAgentRuntime, which takes precedence over this setter at read time. Retained for tests that need only one slice of runtime state.

func (*Server) SetAgentRuntime

func (s *Server) SetAgentRuntime(rt *agentruntime.Runtime)

SetAgentRuntime installs the unified runtime aggregate. When set, the per-component setters below are ignored at read time. Wire-time only: the controller calls this once during apply before HTTP serving starts; field access is unsynchronised to match the rest of the per-server setter pattern.

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) 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) SetPinStore

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

SetPinStore sets the pin store for schema pin management.

func (*Server) SetPlaygroundProvider

func (s *Server) SetPlaygroundProvider(p agent.ChatModel)

SetPlaygroundProvider injects the LLM provider used by /api/playground/{chat,stream}. Passing nil disables the playground (the chat endpoint returns a clear error). The provider is typically the prefix-routing agent/llm/gateway.Provider built at apply-time by pkg/controller from the vault keys present.

SetAgentRuntime takes precedence over this setter at read time; retained for test fixtures.

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) 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 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"`
}

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"`
}

SkillSourceStatus represents a skill source with its update status.

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