server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 28 Imported by: 0 modules, 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 server wires the MCP server (stdio) to the browser manager, the tool handlers and the Cockpit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts Options, stdin io.Reader, stdout io.Writer) error

Run serves MCP over the given stdio streams until the client disconnects or ctx ends.

Types

type Options

type Options struct {
	Version     string
	BrowsersDir string
	ProfilesDir string
	ProfileDir  string
	// ProfileName is the profile's name (--profile; "default"), "" for a --profile-dir outside
	// the profiles directory. Per-profile data keys on it.
	ProfileName string
	// Session is a saved login (--session): every launch uses a fresh ephemeral profile seeded
	// with it, deleted on exit. SessionsDir is where the session tool saves (~/.daisybell/sessions).
	Session     *storagestate.State
	SessionsDir string
	// RetouchesDir holds the per-site CSS the human kept (~/.daisybell/retouches; "" leaves
	// retouches off). The Cockpit injects them whether or not the retouch group is on.
	RetouchesDir string
	// MapsDir holds this profile's site maps (map group). "" is <home>/maps/<profile key>
	// (paths.MapsKey: the profile name, or a hash of a --profile-dir outside the profiles).
	MapsDir  string
	Headless bool
	// DownloadsDir overrides ~/Downloads/daisybell.
	DownloadsDir string
	// Bus receives activity events and Hook runs before every input (both optional, in addition
	// to the Cockpit's).
	Bus      activity.Bus
	Hook     activity.PreActionHook
	Logger   *slog.Logger
	Progress io.Writer

	// NoCockpit disables the side panel / overlay extension and its hub.
	NoCockpit bool
	// Speed is the cockpit speed mode: watch, brisk or turbo.
	Speed string
	// CockpitDir holds unpacked extension builds (default: <BrowsersDir>/../extension).
	CockpitDir string
	// CockpitFiles replaces the embedded extension build (tests: a stale or broken build).
	CockpitFiles fs.FS
	// Cockpit tunes the hub (tests: MaxBlock, Seed). Logger, Speed and ExtensionID are filled in.
	Cockpit cockpit.Options
	// Browser tunes the launch (tests: window size, extra args). The fields above win.
	Browser browser.Options

	// Approve is the approval policy: risky (default), all or none.
	Approve guard.Policy
	// AskWait bounds how long one tool call waits for the human (default 50 s).
	AskWait time.Duration
	// AllowedHosts restricts navigation, popups and form submissions (empty: everything).
	AllowedHosts guard.Hosts
	// Human is asked together with the Cockpit for approvals, handoffs and questions (tests: a
	// scripted human).
	Human guard.Asker

	// Record is the recording mode: timeline (default: events + a picture per action), full
	// (also a screencast while the AI acts) or off.
	Record record.Mode
	// RecordHuman keeps recording while the human drives (default: paused, for privacy).
	RecordHuman bool
	// RecordingsDir overrides ~/.daisybell/recordings; RecordKeep is how many sessions are kept.
	RecordingsDir string
	RecordKeep    int
	// RecordMaxTotal caps all recordings together (--record-max; default 1 GB): the oldest
	// sessions go first.
	RecordMaxTotal int64
	// NoFlows leaves out flow_save / flow_list / flow_run. FlowsHome overrides ~/.daisybell (flows
	// go to <FlowsHome>/flows) and WorkDir the project directory (<WorkDir>/.daisybell/flows).
	NoFlows   bool
	FlowsHome string
	WorkDir   string
	// Lang is the human-facing language (--lang: en or pt-BR) of the Cockpit and of elicitation
	// forms; "" follows the browser (Cockpit) and the OS locale (forms).
	Lang string
	// PageLang is the language pages see (--page-lang; default en-US), independent of Lang.
	PageLang string
	// Permissions are site permissions granted to every site (--permissions); the rest are denied.
	Permissions []string
	// Tools are the tool groups clients see (--tools; nil: tools.DefaultGroups). Recording runs
	// per Record whether or not the record tool is listed.
	Tools tools.Groups
}

Options configures the server.

type ProbeResult

type ProbeResult struct {
	// Cockpit is false with NoCockpit or when the hub could not start.
	Cockpit bool
	// Connected: the Cockpit's service worker said hello.
	Connected bool
	// Reinstalled: the extension had to be installed a second time in this launch.
	Reinstalled bool
	// StaleWorker: because the profile held a worker speaking another protocol version (left by
	// an older build), which the launch replaced: the next launches on that profile connect at once.
	StaleWorker bool
}

ProbeResult is what a probe launch saw.

func Probe

func Probe(ctx context.Context, opts Options, wait time.Duration) (ProbeResult, error)

Probe assembles the stack with opts, opens a page (launching the browser on opts' profile) and waits up to wait for the Cockpit to connect. doctor runs it on a fresh profile and on the default one. The browser is the managed one, never the user's (SPEC §2).

type Stack

type Stack struct {
	Server  *mcp.Server
	Browser *browser.Manager
	// Cockpit is nil with NoCockpit or when the hub could not start.
	Cockpit *cockpit.Hub
	Catalog *tools.Catalog
	// Recorder is nil with --record off.
	Recorder *record.Recorder
}

Stack is a wired Daisybell: the MCP server, its browser and (unless disabled) the Cockpit hub.

func New

func New(opts Options) *Stack

New assembles the server. The browser launches lazily on the first tool call.

func (*Stack) Close

func (st *Stack) Close() error

Close stops the browser and the hub.

Jump to

Keyboard shortcuts

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