apiservice

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 16 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 apiservice manages the per-user UI API process, never tmux.

Index

Constants

View Source
const ActivationRequired = "SIDECAR_API_SOCKET_ACTIVATION"

ActivationRequired marks jobs that must never fall back to binding the browser port themselves. A broken supervisor configuration fails closed.

View Source
const Label = "com.haplab.sidecar.api"
View Source
const SocketUnit = "sidecar-api.socket"
View Source
const Unit = "sidecar-api.service"

Variables

This section is empty.

Functions

func CloseActivated

func CloseActivated(listeners []ActivatedListener)

func ServicePath

func ServicePath(path string, uid int) string

ServicePath keeps the PATH entries a background job can trust for as long as it stays installed: absolute, existing directories owned by root or uid that no other user can write to. It drops empty and relative entries (they resolve against the manager's working directory), directories that do not exist yet (another user could create them, as under /tmp), world-writable directories, and directories owned by another user, any of which would let another local user plant a tmux, git or agent binary that the service then runs as the owner. Group-writable directories are kept: on macOS /usr/local/bin is commonly writable by the admin group, whose members can already act as root. Duplicates keep their first position.

func StableExecutable

func StableExecutable(executable, invoked, path string) string

StableExecutable preserves an argv/PATH link only when it currently names this exact executable. Following that link covers managed and brew upgrades.

Types

type ActivatedListener

type ActivatedListener struct {
	Name     string
	Listener net.Listener
}

ActivatedListener is one descriptor received from the service manager. Empty names (sd_listen_fds) and sidecar-api names are classified by address.

func Activate

func Activate() ([]ActivatedListener, error)

Activate consumes manager descriptors and clears the systemd environment so children cannot mistake them for their own. The manager retains its copies. The systemd protocol is also available on macOS for isolated ExtraFiles proofs.

type Exit

type Exit struct {
	Code   int    `json:"code"`
	Signal string `json:"signal,omitempty"`
}

Exit is the last termination reported by the manager. Nil means unknown.

type Manager

type Manager interface {
	Install(context.Context) error
	Uninstall(context.Context) error
	Status(context.Context) (Status, error)
}

Manager is the service-manager seam. Tests and headless callers inject it.

type Native

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

func New

func New(options Options) (*Native, error)

func (*Native) Install

func (n *Native) Install(ctx context.Context) error

func (*Native) Status

func (n *Native) Status(ctx context.Context) (Status, error)

func (*Native) Uninstall

func (n *Native) Uninstall(ctx context.Context) error

type Options

type Options struct {
	OS         string
	Home       string
	ConfigHome string
	StateDir   string
	ConfigPath string
	Executable string
	Path       string
	UID        int
	Run        Runner
}

Options pins the user's paths and the stable executable link into the job.

type Runner

type Runner func(context.Context, string, ...string) ([]byte, error)

Runner is the only process boundary; it never runs a shell.

type SocketStatus

type SocketStatus struct {
	File      string `json:"file"`
	Installed bool   `json:"installed"`
	Loaded    bool   `json:"loaded"`
	Listening bool   `json:"listening"`
}

type Status

type Status struct {
	Socket        SocketStatus `json:"socket"`
	Manager       string       `json:"manager"`
	Label         string       `json:"label"`
	File          string       `json:"file"`
	Installed     bool         `json:"installed"`
	Loaded        bool         `json:"loaded"`
	Running       bool         `json:"running"`
	PID           int          `json:"pid"`
	Version       string       `json:"version"`
	UIDir         *string      `json:"ui_dir"`
	UIConfigError string       `json:"ui_config_error,omitempty"`
	LastExit      *Exit        `json:"last_exit"`
	Log           string       `json:"log"`
	Message       string       `json:"message"`
}

Jump to

Keyboard shortcuts

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