controlplane

package
v0.5.40-beta Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Overview

Package controlplane provides Kodelet's central HTTP API and server runtime. It owns authentication, conversations, chat execution, runner coordination, and workspace proxying while accepting an optional frontend HTTP handler.

Index

Constants

View Source
const OIDCCallbackPath = "/auth/oidc/callback"

OIDCCallbackPath is the control-plane route used for OIDC authorization callbacks.

Variables

This section is empty.

Functions

func NewAuthToken

func NewAuthToken() (string, error)

NewAuthToken generates a random token suitable for protecting the web UI.

func ValidateAuthToken

func ValidateAuthToken(authToken string) error

ValidateAuthToken validates a caller-provided web UI auth token.

func ValidateCORSOrigins

func ValidateCORSOrigins(origins []string) error

ValidateCORSOrigins validates caller-provided CORS origins.

Types

type CWDHint

type CWDHint struct {
	Path string `json:"path"`
}

type CWDHintsResponse

type CWDHintsResponse struct {
	BaseDir string    `json:"baseDir,omitempty"`
	Query   string    `json:"query,omitempty"`
	Hints   []CWDHint `json:"hints"`
}

type ChatProfileOption

type ChatProfileOption struct {
	Name   string `json:"name"`
	Scope  string `json:"scope"`
	Active bool   `json:"active,omitempty"`
}

ChatProfileOption represents a selectable profile in the web UI.

type ChatSettingsResponse

type ChatSettingsResponse struct {
	CurrentProfile               string              `json:"currentProfile,omitempty"`
	Profiles                     []ChatProfileOption `json:"profiles"`
	ReasoningEffort              string              `json:"reasoningEffort"`
	ReasoningEffortOptions       []string            `json:"reasoningEffortOptions"`
	DefaultCWD                   string              `json:"defaultCWD,omitempty"`
	ControlPlaneWorkspaceEnabled bool                `json:"controlPlaneWorkspaceEnabled"`
}

ChatSettingsResponse contains new-conversation settings for the web chat composer.

type FrontendHandler

type FrontendHandler interface {
	http.Handler
	IsPublicPath(path string) bool
}

FrontendHandler serves an optional browser frontend and identifies static frontend resources that must remain public before browser authentication.

type OIDCConfig

type OIDCConfig struct {
	IssuerURL         string
	ClientID          string
	ClientSecret      string
	RedirectURL       string
	Scopes            []string
	AllowedEmails     []string
	AllowedDomains    []string
	AdminEmails       []string
	TerminalEmails    []string
	RunnerAdminEmails []string
	AllowAnyUser      bool
	SessionDuration   time.Duration
	Flow              OIDCFlow
}

OIDCConfig configures generic OpenID Connect authentication for browser users.

func (OIDCConfig) Validate

func (c OIDCConfig) Validate() error

type OIDCFlow

type OIDCFlow interface {
	AuthorizationURL(state, nonce, verifier string) string
	Exchange(ctx context.Context, code, verifier, expectedNonce string) (OIDCIdentity, error)
}

OIDCFlow is the testable authorization-code boundary used by the web server.

type OIDCIdentity

type OIDCIdentity struct {
	Issuer        string
	Subject       string
	Name          string
	Email         string
	EmailVerified bool
	HostedDomain  string
}

OIDCIdentity is the verified identity returned by an OIDC authorization-code exchange.

type Principal

type Principal struct {
	ID           string   `json:"id"`
	Issuer       string   `json:"issuer,omitempty"`
	Subject      string   `json:"subject,omitempty"`
	Name         string   `json:"name,omitempty"`
	Email        string   `json:"email,omitempty"`
	Roles        []string `json:"roles"`
	SessionID    string   `json:"-"`
	CredentialID string   `json:"-"`
}

Principal is the authenticated human/API identity attached to a request.

func (Principal) HasRole

func (p Principal) HasRole(role Role) bool

type Role

type Role string

Role identifies a server-side authorization capability.

const (
	RoleUser        Role = "user"
	RoleTerminal    Role = "terminal"
	RoleRunnerAdmin Role = "runner-admin"
	RoleAdmin       Role = "admin"
)

type RunnerAuthMode

type RunnerAuthMode string

RunnerAuthMode selects the authentication mechanisms accepted by runner registration.

const (
	RunnerAuthModeToken      RunnerAuthMode = "token"
	RunnerAuthModeEnrollment RunnerAuthMode = "enrollment"
	RunnerAuthModeNone       RunnerAuthMode = "none"
)

type Server

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

Server represents the Kodelet control-plane server.

func NewServer

func NewServer(ctx context.Context, config *ServerConfig, frontendHandler FrontendHandler) (*Server, error)

NewServer creates a control-plane server. frontendHandler may be nil only for API-only token or unauthenticated deployments.

func (*Server) Close

func (s *Server) Close() error

Close closes the server and releases resources

func (*Server) HandleRunnerUIRequest

func (s *Server) HandleRunnerUIRequest(ctx context.Context, runnerID, method string, params json.RawMessage) (any, *protocol.RPCError)

HandleRunnerUIRequest routes runner-owned extension UI through the client attached to the run.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the configured control-plane routes and browser frontend.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the web server

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the web server

type ServerConfig

type ServerConfig struct {
	Host                         string
	Port                         int
	CWD                          string
	CompactRatio                 float64
	AuthToken                    string
	RunnerAuthToken              string
	WebAuthMode                  WebAuthMode
	RunnerAuthMode               RunnerAuthMode
	OIDC                         OIDCConfig
	DisableControlPlaneWorkspace bool
	CORSOrigins                  []string
}

ServerConfig holds the configuration for the control-plane server.

func (*ServerConfig) Validate

func (c *ServerConfig) Validate() error

Validate validates the server configuration

type SlashCommandsResponse

type SlashCommandsResponse struct {
	Commands []slashcommands.Command `json:"commands"`
}

type WebAuthMode

type WebAuthMode string

WebAuthMode selects the authentication mechanism for browser and control-plane API requests.

const (
	WebAuthModeToken WebAuthMode = "token"
	WebAuthModeOIDC  WebAuthMode = "oidc"
	WebAuthModeNone  WebAuthMode = "none"
)

type WebContentBlock

type WebContentBlock struct {
	Type     string          `json:"type"`
	Text     string          `json:"text,omitempty"`
	Command  string          `json:"command,omitempty"`
	Source   *WebImageSource `json:"source,omitempty"`
	ImageURL *WebImageURL    `json:"image_url,omitempty"`
}

WebContentBlock represents a typed content block rendered by the web UI.

type WebConversationResponse

type WebConversationResponse struct {
	ID                    string                 `json:"id"`
	CreatedAt             time.Time              `json:"createdAt"`
	UpdatedAt             time.Time              `json:"updatedAt"`
	Provider              string                 `json:"provider"`
	CWD                   string                 `json:"cwd,omitempty"`
	CWDLocked             bool                   `json:"cwdLocked,omitempty"`
	Profile               string                 `json:"profile,omitempty"`
	ProfileLocked         bool                   `json:"profileLocked,omitempty"`
	ReasoningEffort       string                 `json:"reasoningEffort,omitempty"`
	ReasoningEffortLocked bool                   `json:"reasoningEffortLocked,omitempty"`
	RunnerID              string                 `json:"runnerId,omitempty"`
	EnvironmentProfile    string                 `json:"environmentProfile,omitempty"`
	Runner                *runnerregistry.Runner `json:"runner,omitempty"`
	Summary               string                 `json:"summary,omitempty"`
	IsRunning             bool                   `json:"isRunning,omitempty"`
	Usage                 any                    `json:"usage"`
	Messages              []WebMessage           `json:"messages"`
	PendingSteer          []WebMessage           `json:"pendingSteer,omitempty"`
	ToolResults           any                    `json:"toolResults,omitempty"`
	MessageCount          int                    `json:"messageCount"`
}

WebConversationResponse represents a conversation response for the web UI.

type WebImageSource

type WebImageSource struct {
	Data      string `json:"data"`
	MediaType string `json:"media_type"`
}

WebImageSource represents inline image data for a web content block.

type WebImageURL

type WebImageURL struct {
	URL string `json:"url"`
}

WebImageURL represents a remote image URL for a web content block.

type WebMessage

type WebMessage struct {
	Role          string        `json:"role"`
	Content       any           `json:"content"`
	ToolCalls     []WebToolCall `json:"toolCalls,omitempty"`
	ThinkingText  string        `json:"thinkingText,omitempty"`
	ThinkingTexts []string      `json:"thinkingTexts,omitempty"`
}

WebMessage represents a message with structured tool calls for the web UI

type WebToolCall

type WebToolCall struct {
	ID       string              `json:"id"`
	Function WebToolCallFunction `json:"function"`
}

WebToolCall represents a tool call for the web UI

type WebToolCallFunction

type WebToolCallFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

WebToolCallFunction represents the function part of a tool call

Directories

Path Synopsis
Package userauth implements Kodelet-issued credentials for non-browser users.
Package userauth implements Kodelet-issued credentials for non-browser users.

Jump to

Keyboard shortcuts

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