Documentation
¶
Overview ¶
Package kernel is what the core's own services (the agent, slots, the router) are given: the app's shared state, already assembled. It is an interface so those services can be built and tested without the whole app.
Index ¶
- Constants
- type App
- func (a *App) AddTools(tools ...BoundTool) error
- func (a *App) AppName() string
- func (a *App) Bus() *events.Bus
- func (a *App) Cards() module.Cards
- func (a *App) Catalog() Catalog
- func (a *App) CommandInfos() []CommandInfo
- func (a *App) Commands() []module.Command
- func (a *App) Config(scope string) module.Config
- func (a *App) DB() *sql.DB
- func (a *App) DataDir() string
- func (a *App) DeclareSettings(scope string, s []module.Setting) error
- func (a *App) Desk() module.Desk
- func (a *App) Events() module.Events
- func (a *App) Log() *slog.Logger
- func (a *App) Marks() module.Marks
- func (a *App) ModuleRoutes() http.Handler
- func (a *App) Modules() []ModuleInfo
- func (a *App) RunCommand(ctx context.Context, id string, args map[string]any) (any, error)
- func (a *App) Settings() *config.Store
- func (a *App) Situation(ctx context.Context) module.Situation
- func (a *App) Slots() []BoundSlot
- func (a *App) Start(ctx context.Context) error
- func (a *App) Stop(ctx context.Context) error
- func (a *App) Title() string
- func (a *App) Tools() []BoundTool
- func (a *App) WM() *desk.Desk
- type BoundSlot
- type BoundTool
- type Catalog
- type CatalogItem
- type CatalogModule
- type CommandInfo
- type Kernel
- type ModuleInfo
- type Options
Constants ¶
const CoreScope = "surface"
CoreScope is the settings scope of the core's own settings.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the assembled app: the Kernel the core's services are given.
func New ¶
New assembles the app: opens the stores, reads every module's manifest and builds its Host. Start then starts the modules.
func (*App) AddTools ¶
AddTools adds a core service's own tools (the agent's: slots, reflexes, rules), so they are offered at /api/tools and /mcp like every other. Call before serving. A name already taken is an error.
func (*App) CommandInfos ¶
func (a *App) CommandInfos() []CommandInfo
CommandInfos lists every command with the module that brought it.
func (*App) DeclareSettings ¶
DeclareSettings adds a core service's settings (the agent's, say). Call before serving.
func (*App) ModuleRoutes ¶
ModuleRoutes serves the modules' own routes (/api/m/<id>/...).
func (*App) Modules ¶
func (a *App) Modules() []ModuleInfo
Modules lists the started modules' manifests.
func (*App) RunCommand ¶
RunCommand runs a command by id.
func (*App) Start ¶
Start starts the modules in order. Routes a module adds in Start are served afterwards.
type BoundSlot ¶
type BoundSlot struct {
module.Slot
Module string
Knowledge func(ctx context.Context, s module.Situation) (string, error)
}
BoundSlot is a slot with the module that brought it and its Knowledge bound to that module's Host. Knowledge is nil when the slot has none.
type BoundTool ¶
type BoundTool struct {
module.Tool
Module string
Call func(ctx context.Context, input json.RawMessage) (any, error)
}
BoundTool is a tool with the module that brought it and a call already bound to that module's Host.
type Catalog ¶
type Catalog struct {
App string `json:"app"`
Title string `json:"title"`
Modules []CatalogModule `json:"modules"`
}
Catalog is what the app is made of, as data: its modules with their views, commands, tools and slots. It is what a module that composes setups (the Interaction Builder) and the agent read to know what there is to arrange.
type CatalogItem ¶
type CatalogItem struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
About string `json:"about,omitempty"`
Level string `json:"level,omitempty"`
}
CatalogItem is a view, a command or a tool, by id and what it is for.
type CatalogModule ¶
type CatalogModule struct {
ID string `json:"id"`
Title string `json:"title"`
About string `json:"about,omitempty"`
Views []CatalogItem `json:"views,omitempty"`
Commands []CatalogItem `json:"commands,omitempty"`
Tools []CatalogItem `json:"tools,omitempty"`
Slots []module.Slot `json:"slots,omitempty"`
Settings []module.Setting `json:"settings,omitempty"`
}
CatalogModule is one module of the catalog. The core's own entries are under "surface".
type CommandInfo ¶
CommandInfo is a command as the page and the agent are told it.
type Kernel ¶
type Kernel interface {
AppName() string
// DataDir is the app's data directory. It exists.
DataDir() string
// DB is the core database. A service adds its own tables with storage.Migrate under
// its own migration set.
DB() *sql.DB
Log() *slog.Logger
Desk() module.Desk
Events() module.Events
Marks() module.Marks
Cards() module.Cards
// Config is the live settings of one scope ("agent", or a module id).
Config(scope string) module.Config
// Tools is every tool in the app, bound to the Host of the module that brought it:
// each module's own, and the desk's (desk_*, window_context, marks_*, card_*).
Tools() []BoundTool
// Slots is every module's context slots, bound likewise.
Slots() []BoundSlot
// Situation is what is happening now: the window in front, the open windows, the
// user's mode and the layout in use.
Situation(ctx context.Context) module.Situation
RunCommand(ctx context.Context, id string, args map[string]any) (any, error)
Commands() []module.Command
}
Kernel is the assembled app, as a core service sees it.
type ModuleInfo ¶
ModuleInfo is one started module, for the app's manifest.
type Options ¶
type Options struct {
// Name is the app's name ("desk"); Title is how a person reads it.
Name string
Title string
// DataDir is the app's data directory. It is created, private.
DataDir string
// DB is the core database. When nil the kernel opens <DataDir>/surface.db itself.
DB *sql.DB
Log *slog.Logger
// Modules are the ids to start, in order. Nil starts every registered module.
Modules []string
}
Options are what an app gives the kernel.