app

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 20 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 app wires configuration, the profile store, transports, the domain client and the MCP server together for the CLI.

Index

Constants

View Source
const (
	EnvCookies     = "NOTEBOOKLM_COOKIES"
	EnvCookiesFile = "NOTEBOOKLM_COOKIES_FILE"
)

Sign-in without `sourcebolt login`, for containers (Docker MCP Toolkit, docker run): the cookie export itself, or the path of a file holding it (a Docker secret under /run/secrets). Same formats as `login --import`.

Variables

This section is empty.

Functions

func EnvProfile added in v0.3.2

func EnvProfile(c Config) (*session.Profile, string, error)

EnvProfile builds an in-memory profile from EnvCookies or EnvCookiesFile, and the name of the variable used. It returns nil, "", nil when neither is set (an empty value counts as unset: catalogs pass "" for a secret nobody filled in). Build calls it; call it directly only where Build is not used (status).

Both variables are removed from the process environment before anything else happens, valid or not, so a child process (the fallback browser) never inherits the cookies.

Errors name the variable and, for an incomplete jar, the missing cookie names. They never include the input: a parser error can quote it.

Types

type Config

type Config struct {
	ConfigDir string       // NOTEBOOKLM_CONFIG_DIR, default %USERPROFILE%\.sourcebolt (Windows) or <user config>/sourcebolt
	Profile   string       // NOTEBOOKLM_PROFILE, default "default"
	Host      session.Host // NOTEBOOKLM_HOST overrides the profile's host
	RPCIDs    string       // NOTEBOOKLM_RPC_IDS, default <config>/rpc-ids.json if present
	// BrowserFallback enables the lazy headless-browser fallback transport.
	// Default true; NOTEBOOKLM_BROWSER_FALLBACK=0 (or false/off/no) disables.
	BrowserFallback bool
	// contains filtered or unexported fields
}

Config comes from flags and environment.

func ConfigFromEnv

func ConfigFromEnv() (Config, error)

ConfigFromEnv reads the NOTEBOOKLM_* variables.

func (Config) Store

func (c Config) Store() session.Store

Store opens the encrypted profile store. With the default folder on Windows it first copies profiles that are only in the old %APPDATA% folder (see session.MigrateProfiles); the old folder is left as it is.

type Option

type Option func(*options)

Option customizes ForProfile.

func WithBrowserFallback

func WithBrowserFallback(configDir string) Option

WithBrowserFallback adds the lazy browser fallback; its profile dir is <configDir>/browser/<profile>. No browser starts before the first call that the fallback policy allows.

type Runtime

type Runtime struct {
	Deps      mcpserver.Deps
	Transport *rpc.Transport      // the rpc transport (Warm, doctor)
	Active    transport.Transport // what the nlm client calls: Router, or Transport when fallback is off
	Router    *transport.Router   // nil when the browser fallback is disabled
	Profile   *session.Profile
	Store     session.Store // nil for env cookies: nothing is written to disk
	// CookieSource names the environment variable the cookies came from
	// (EnvCookies or EnvCookiesFile); empty for a saved profile.
	CookieSource string
	// ProfileErr is why the saved profile could not be read (wrong or
	// missing key, corrupt file); nil otherwise. The server still starts
	// and tool calls report AUTH_REQUIRED until `sourcebolt login`
	// replaces the profile.
	ProfileErr error
	// contains filtered or unexported fields
}

Runtime is a fully wired server for one profile.

func Build

func Build(c Config) (*Runtime, error)

Build loads the profile (or an empty one, so tools report AUTH_REQUIRED instead of the server failing to start) and wires every layer.

func ForProfile

func ForProfile(p *session.Profile, store session.Store, opts ...Option) *Runtime

ForProfile wires a runtime around an in-memory profile. Without options the nlm client uses the bare rpc transport.

func (*Runtime) Close

func (rt *Runtime) Close() error

Close cancels running detached jobs and stops the fallback browser (if one was ever launched). It is idempotent and safe on a runtime that never used the browser.

func (*Runtime) Warm added in v0.3.3

func (rt *Runtime) Warm(ctx context.Context) error

Warm fetches page tokens ahead of the first tool call. While the saved profile cannot be read it sends nothing and returns the auth error.

Jump to

Keyboard shortcuts

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