Documentation
¶
Overview ¶
Package server provides the public PowerContext server configuration and lifecycle facade.
Index ¶
- Constants
- func DefaultDatabasePath() (string, error)
- func DefaultSchedulerPath() (string, error)
- func DefaultSeekDBPath() (string, error)
- func NewHTTPHandler(handler v1.Handler, options HTTPOptions) (http.Handler, error)
- func PowerContextDataDir() (string, error)
- func SQLiteDSN(value string) (string, error)
- type Application
- type AuthConfig
- type AuthenticationTokenRequiredError
- type DashboardConfig
- type DashboardScope
- type DatabaseConfig
- type Dependencies
- type ExternalSkillRoot
- type ExternalSkillTarget
- type ExternalSkillsConfig
- type HTTPConfig
- type HTTPConfigOverride
- type HTTPOptions
- type HandoffReportConfig
- type InferenceConfig
- type LoggingConfig
- type MCPConfig
- type MCPOptions
- type MetricsConfig
- type OceanBaseDatabaseConfig
- type ProcessConfig
- type RuntimeConfig
- type SQLiteDatabaseConfig
- type SeekDBDatabaseConfig
- type TracingConfig
- type UnauthenticatedNonLoopbackBindError
Constants ¶
const ( PowerContextHomeEnv = "POWERCONTEXT_HOME" DefaultMCPPath = "/mcp" )
Variables ¶
This section is empty.
Functions ¶
func DefaultDatabasePath ¶
func DefaultSchedulerPath ¶
func DefaultSeekDBPath ¶
func NewHTTPHandler ¶
NewHTTPHandler assembles the generated OpenAPI server and the transport-wide policy middleware. Lifecycle and listener ownership remain with cmd/server.
func PowerContextDataDir ¶
PowerContextDataDir matches platformdirs.user_data_path("powercontext", appauthor=False) on the supported Linux and macOS release targets.
func SQLiteDSN ¶
SQLiteDSN converts the frozen SQLAlchemy URL spelling without accepting a different database scheme by accident. Three-slash URLs intentionally keep a relative database path: the frozen .env.example relies on resolving that path from the Server working directory, just as SQLAlchemy does.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is one fully assembled Runtime and its shared endpoint adapter. Close is idempotent and drains admitted work before closing persistence.
func OpenApplication ¶
func OpenApplication(ctx context.Context, config ProcessConfig, dependencies Dependencies) (*Application, error)
OpenApplication initializes persistence projections before making any operation reachable. A partially initialized application is always closed.
func (*Application) Endpoint ¶
func (a *Application) Endpoint() v1.Handler
func (*Application) HTTPHandler ¶
func (a *Application) HTTPHandler() (http.Handler, error)
type AuthConfig ¶
func (AuthConfig) GoString ¶
func (c AuthConfig) GoString() string
func (AuthConfig) LogValue ¶
func (c AuthConfig) LogValue() slog.Value
func (AuthConfig) String ¶
func (c AuthConfig) String() string
type AuthenticationTokenRequiredError ¶
type AuthenticationTokenRequiredError struct{}
AuthenticationTokenRequiredError reports enabled bearer authentication without the token required to authenticate requests.
func (*AuthenticationTokenRequiredError) Error ¶
func (*AuthenticationTokenRequiredError) Error() string
type DashboardConfig ¶
type DashboardConfig struct {
Enabled bool
Scopes []DashboardScope
}
type DashboardScope ¶
type DatabaseConfig ¶
type DatabaseConfig struct {
Kind string
SQLite SQLiteDatabaseConfig
OceanBase OceanBaseDatabaseConfig
SeekDB SeekDBDatabaseConfig
}
type Dependencies ¶
type Dependencies struct {
MemoryCandidates memory.CandidatePipeline
ExperienceCandidates experience.CandidatePipeline
ExperienceGenerator experience.Generator
SkillGenerator skill.Generator
HandoffGenerator handoff.GenerationPipeline
EmbeddingModel inference.EmbeddingModel
MemoryReranker memory.Reranker
ExternalSkills skill.ExternalProvider
HTTPClient *http.Client
Clock func() time.Time
IDFactory func(string) (string, error)
Logger *slog.Logger
TracerProvider trace.TracerProvider
}
Dependencies are deliberate extension points for deterministic tests and custom deployments. Nil values are assembled from InferenceConfig where possible; they are not service locators and do not own lifecycle.
type ExternalSkillRoot ¶
type ExternalSkillTarget ¶
type ExternalSkillsConfig ¶
type ExternalSkillsConfig struct {
HostID string
Targets []ExternalSkillTarget
CodexRoots []ExternalSkillRoot
}
type HTTPConfig ¶
func (HTTPConfig) Address ¶
func (c HTTPConfig) Address() string
type HTTPConfigOverride ¶
HTTPConfigOverride contains only command-line values that were explicitly provided and must be merged before ProcessConfig validation.
type HTTPOptions ¶
type HTTPOptions struct {
BearerToken string
HandoffReportRoutes bool
TracerProvider trace.TracerProvider
MeterProvider metric.MeterProvider
Logger *slog.Logger
AccessLog bool
MCP MCPOptions
// contains filtered or unexported fields
}
type HandoffReportConfig ¶
type HandoffReportConfig struct{ Enabled bool }
type InferenceConfig ¶
type LoggingConfig ¶
type MCPOptions ¶
type MCPOptions struct {
Enabled bool
Path string
Version string
Stateless bool
JSONResponse bool
SessionTimeout time.Duration
Logger *slog.Logger
}
MCPOptions controls the optional MCP Streamable HTTP route. Path defaults to /mcp. A disabled MCP surface is not mounted and therefore returns 404.
type MetricsConfig ¶
type MetricsConfig struct{ Enabled bool }
type OceanBaseDatabaseConfig ¶
type ProcessConfig ¶
type ProcessConfig struct {
HTTP HTTPConfig
MCP MCPConfig
Auth AuthConfig
AllowUnauthenticatedNonLoopback bool
Dashboard DashboardConfig
Logging LoggingConfig
Metrics MetricsConfig
Tracing TracingConfig
Runtime RuntimeConfig
Database DatabaseConfig
HandoffReport HandoffReportConfig
Inference InferenceConfig
ExternalSkills ExternalSkillsConfig
SchedulerPath string
}
ProcessConfig is the validated process-owned configuration. Domain packages intentionally never read it or inspect the environment.
func DefaultConfig ¶
func DefaultConfig() (ProcessConfig, error)
DefaultConfig returns the same validated defaults used by LoadConfig, without consulting POWERCONTEXT_SERVER_* overrides.
func LoadConfig ¶
func LoadConfig() (ProcessConfig, error)
LoadConfig overlays POWERCONTEXT_SERVER_* values on the frozen Python defaults. Nested object fields use the same one-level underscore spelling; slices use JSON, matching pydantic-settings' environment representation.
func LoadConfigWithHTTPOverride ¶
func LoadConfigWithHTTPOverride(override HTTPConfigOverride) (ProcessConfig, error)
LoadConfigWithHTTPOverride overlays explicitly provided HTTP command-line values before running the same final validation used by LoadConfig.
func (ProcessConfig) Validate ¶
func (c ProcessConfig) Validate() error
type RuntimeConfig ¶
type SQLiteDatabaseConfig ¶
type SeekDBDatabaseConfig ¶
type TracingConfig ¶
type TracingConfig struct{ Enabled bool }
type UnauthenticatedNonLoopbackBindError ¶
type UnauthenticatedNonLoopbackBindError struct{}
UnauthenticatedNonLoopbackBindError reports a Server bind that would expose unauthenticated HTTP or MCP traffic outside the local machine.
func (*UnauthenticatedNonLoopbackBindError) Error ¶
func (*UnauthenticatedNonLoopbackBindError) Error() string