sessions

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sessions maintains ~/.ape/registry.json — the cross-project list of live `ape chat` / `ape pipeline` (web mode) invocations so users can list, prune, and reopen them. PLAN-5 / C5.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns ~/.ape/registry.json. Falls back to a temp-directory path if $HOME is unset (best-effort — the registry is non-load-bearing, so a missing home dir should not crash ape).

func Deregister

func Deregister(path string, pid int) error

Deregister removes the entry whose PID matches s.PID. No-op if not found (best-effort cleanup; we want shutdown to always succeed).

func Register

func Register(path string, s Session) error

Register appends s to the registry at path. Acquires an exclusive flock for the write so concurrent ape invocations cannot interleave. Creates the parent directory if missing.

Types

type Session

type Session struct {
	PID       int       `json:"pid"`
	CWD       string    `json:"cwd"`
	Command   string    `json:"command"`
	Port      int       `json:"port"`
	URL       string    `json:"url"`
	StartedAt time.Time `json:"started_at"`
}

Session is one row in the registry.

func List

func List(path string) ([]Session, error)

List reads the registry without taking the write lock or pruning. Useful for `ape sessions` (which prunes first via Prune).

func Prune

func Prune(path string) ([]Session, error)

Prune drops rows whose PID is no longer running. Returns the rows that survived. Called by every startup and by `ape sessions prune`.

Jump to

Keyboard shortcuts

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