adapterservice

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package adapterservice provides the per-user adapter daemon and its protected local management protocol. Each profile owns one fixed platform session.

Index

Constants

View Source
const LocalCredentialHeader = "X-MCP-Local-Token" // #nosec G101 -- this is an HTTP header name, not a credential value.
View Source
const ProtocolVersion = 1

Variables

This section is empty.

Functions

func CheckPrivate

func CheckPrivate(path string, dir bool) error

CheckPrivate refuses symlinks, foreign owners and group/world access rather than silently adopting an existing path with unsafe permissions.

func Token

func Token() (string, error)

func ValidateProfiles

func ValidateProfiles(profiles []Profile) error

Types

type Credential

type Credential struct {
	Certificate tls.Certificate
	Roots       *x509.CertPool
	Expires     time.Time
}

type Daemon

type Daemon struct {
	Store Store
	Issue Issue
	// contains filtered or unexported fields
}

func (*Daemon) Handler

func (d *Daemon) Handler() http.Handler

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

func (*Daemon) Status

func (d *Daemon) Status() Status

type Event

type Event struct {
	At      time.Time `json:"at"`
	Profile string    `json:"profile"`
	Message string    `json:"message"`
}

type Issue

type Issue func(context.Context, Profile) (Credential, error)

Issue must renew only the profile's recorded session, never create a session.

type Profile

type Profile struct {
	Name           string    `json:"name"`
	PlatformURL    string    `json:"platform_url"`
	RuntimeURL     string    `json:"runtime_url"`
	Namespace      string    `json:"namespace"`
	Server         string    `json:"server"`
	Agent          string    `json:"agent"`
	Human          string    `json:"human"`
	Team           string    `json:"team"`
	Session        string    `json:"session"`
	TrustDomain    string    `json:"trust_domain"`
	SessionExpires time.Time `json:"session_expires"`
	Listen         string    `json:"listen"`
	PlatformToken  string    `json:"platform_token"`
	LocalToken     string    `json:"local_token"`
}

Profile is stored only in the owner-protected store, never returned as status. PlatformToken authenticates certificate renewal, LocalToken authenticates the local MCP client. Neither is an upstream OAuth bearer.

type ProfileStatus

type ProfileStatus struct {
	Name               string    `json:"name"`
	PlatformURL        string    `json:"platform_url"`
	Namespace          string    `json:"namespace"`
	Server             string    `json:"server"`
	Agent              string    `json:"agent"`
	Human              string    `json:"human"`
	Team               string    `json:"team"`
	Endpoint           string    `json:"endpoint"`
	LocalReady         bool      `json:"local_ready"`
	Upstream           string    `json:"upstream"`
	Authentication     string    `json:"authentication"`
	CertificateExpires time.Time `json:"certificate_expires"`
	SessionExpires     time.Time `json:"session_expires"`
	LastCheck          time.Time `json:"last_check"`
	LastRenewalError   string    `json:"last_renewal_error,omitempty"`
}

type Status

type Status struct {
	Version      int             `json:"version"`
	Running      bool            `json:"running"`
	StartAtLogin bool            `json:"start_at_login"`
	Profiles     []ProfileStatus `json:"profiles"`
	Events       []Event         `json:"events"`
}

type Store

type Store struct{ Dir string }

func DefaultStore

func DefaultStore() (Store, error)

func (Store) Init

func (s Store) Init() error

func (Store) Install

func (s Store) Install(ctx context.Context, executable string) error

Install places a stable daemon binary outside the source checkout. Replace that binary only after stopping the previous service. Profiles are preserved.

func (Store) Installed

func (s Store) Installed() bool

func (Store) Label

func (s Store) Label() string

func (Store) LaunchAgentPath

func (s Store) LaunchAgentPath() string

func (Store) Load

func (s Store) Load() ([]Profile, error)

func (Store) Lock

func (s Store) Lock(name string) (*os.File, error)

Lock serializes daemon starts and interactive profile changes across processes.

func (Store) Plist

func (s Store) Plist(executable string) []byte

func (Store) Request

func (s Store) Request(ctx context.Context, method, path string) (Status, error)

Request uses only the protected per-user Unix socket, never TCP or a proxy.

func (Store) Save

func (s Store) Save(profiles []Profile) error

func (Store) Socket

func (s Store) Socket() string

func (Store) Start

func (s Store) Start(ctx context.Context) error

func (Store) Stop

func (s Store) Stop(ctx context.Context) error

func (Store) Uninstall

func (s Store) Uninstall(ctx context.Context, purge bool) error

Jump to

Keyboard shortcuts

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