core

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package core assembles a Surface app: the kernel (desk, commands, settings, marks, events), the selected modules and the embedded agent, behind one HTTP handler.

An app's main (generated by `surface generate`) starts Substrate, imports its modules and hands this package what Substrate opened:

app, err := core.New(ctx, core.Options{Name: "desk", DataDir: dir, DB: db, Modules: surfaceModules, Assets: assets})
err = app.Start(ctx)
http.Serve(l, app.Handler())

Everything else in the core is under core/internal, out of a module's reach: a module sees only the module package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is a running Surface app.

func New

func New(ctx context.Context, o Options) (*App, error)

New assembles the app. Nothing is served and no module is started until Start.

func (*App) Handler

func (a *App) Handler() http.Handler

Handler serves the app: its API, its modules' routes, its agent and its page.

func (*App) PublicRoute added in v0.17.0

func (a *App) PublicRoute(r *http.Request) bool

PublicRoute reports whether r is for a module route marked module.Public, which an app with sign-in serves without a signed-in caller.

func (*App) Publish added in v0.20.0

func (a *App) Publish(topic string, data any)

Publish puts an event on the app's bus (what modules see through Host.Events).

func (*App) Start

func (a *App) Start(ctx context.Context) error

Start starts the modules.

func (*App) Stop

func (a *App) Stop(ctx context.Context) error

Stop stops the agent, then the modules, and closes the stores.

type Options

type Options struct {
	// Name is the app's name: lower case letters, digits and dashes. Title is how a person
	// reads it.
	Name  string
	Title string
	// DataDir is the app's data directory.
	DataDir string
	// DB is the core database (Substrate's database module). When nil the core opens
	// <DataDir>/surface.db itself.
	DB  *sql.DB
	Log *slog.Logger
	// Modules are the module ids to start, in order. Nil starts every module compiled in.
	Modules []string
	// Assets is the built page. Nil serves the API only.
	Assets fs.FS
	// Keys mints identity API keys for modules (module.KeysOf); nil without sign-in.
	Keys module.Keys
}

Options are what an app gives the core.

Directories

Path Synopsis
internal
ade
Package ade lets the agent show the owner things on the desk: point at a window or at a part of one (an anchor its view declared), spotlight it, draw an arrow between two, and walk the owner through a short guide.
Package ade lets the agent show the owner things on the desk: point at a window or at a part of one (an anchor its view declared), spotlight it, draw an arrow between two, and walk the owner through a short guide.
agent
Package agent is the embedded agent of a Surface app: one agent the owner talks to in the agent panel, with every tool in the app, whose context changes with what is in front.
Package agent is the embedded agent of a Surface app: one agent the owner talks to in the agent panel, with every tool in the app, whose context changes with what is in front.
agent/profile
Package profile reads, checks and stages module agent profiles.
Package profile reads, checks and stages module agent profiles.
api
Package api is the core's HTTP surface: what the page draws from and what an outside client (a CLI, a script, another agent) drives the app through.
Package api is the core's HTTP surface: what the page draws from and what an outside client (a CLI, a script, another agent) drives the app through.
attend
Package attend keeps what needs the owner, or has not been seen by them yet, in one place with one vocabulary, so the desk can say "this is waiting for you" the same way wherever it comes from (docs/attention.md).
Package attend keeps what needs the owner, or has not been seen by them yet, in one place with one vocabulary, so the desk can say "this is waiting for you" the same way wherever it comes from (docs/attention.md).
cards
Package cards keeps the cards: what the app shows the user outside a window (a notice, a question, a request to approve, progress) and what they answered.
Package cards keeps the cards: what the app shows the user outside a window (a notice, a question, a request to approve, progress) and what they answered.
classifier
Package classifier labels the owner's messages to the embedded agent: what the message asks for (the act facet: command, question, task, correction, approval, chat) and which slot it belongs to (the slot facet: the app's slots and general).
Package classifier labels the owner's messages to the embedded agent: what the message asks for (the act facet: command, question, task, correction, approval, chat) and which slot it belongs to (the slot facet: the app's slots and general).
config
Package config is the app's live settings: declared by the core and by modules, kept in the app's database, and read at the moment of use.
Package config is the app's live settings: declared by the core and by modules, kept in the app's database, and read at the moment of use.
desk
Package desk is the window manager: which windows are open, which is in front, how they are laid out, and the layouts the user saved.
Package desk is the window manager: which windows are open, which is in front, how they are laid out, and the layouts the user saved.
events
Package events is the app's event bus: in-process publish and subscribe by topic prefix.
Package events is the app's event bus: in-process publish and subscribe by topic prefix.
genui
Package genui is Surface's host for generated UI: the reviewed GenUI contract and gateway from Substrate, given this app's storage, policy and effects.
Package genui is Surface's host for generated UI: the reviewed GenUI contract and gateway from Substrate, given this app's storage, policy and effects.
kernel
Package kernel is what the core's own services (the agent, slots, the router) are given: the app's shared state, already assembled.
Package kernel is what the core's own services (the agent, slots, the router) are given: the app's shared state, already assembled.
marks
Package marks keeps the collaboration marks: notes pinned to a part of something, by the owner or the agent, with replies, until resolved.
Package marks keeps the collaboration marks: notes pinned to a part of something, by the owner or the agent, with replies, until resolved.
reflex
Package reflex holds the agent's reflexes: standing rules that watch the conversation and the app, and act when their trigger fires.
Package reflex holds the agent's reflexes: standing rules that watch the conversation and the app, and act when their trigger fires.
router
Package router stands in front of the agent.
Package router stands in front of the agent.
script
Package script runs one walk-through three ways (docs/scripts.md):
Package script runs one walk-through three ways (docs/scripts.md):
slots
Package slots decides what the embedded agent has in mind for a turn.
Package slots decides what the embedded agent has in mind for a turn.
storage
Package storage opens SQLite databases and moves their schema forward.
Package storage opens SQLite databases and moves their schema forward.
wardentoken
Package wardentoken mints short-lived bearer tokens for one audience from a Warden parent credential kept in a file, and hands them to HTTP clients.
Package wardentoken mints short-lived bearer tokens for one audience from a Warden parent credential kept in a file, and hands them to HTTP clients.

Jump to

Keyboard shortcuts

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