programresume

package
v1.168.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 20 Imported by: ? 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 programresume implements authenticated OSC 7577 reports and private per-instance state storage for terminal session restoration.

Index

Constants

View Source
const (
	StaleInstanceMaxAge = 30 * 24 * time.Hour
)
View Source
const TokenEnv = "OSC7577_TOKEN"

Variables

This section is empty.

Functions

func Clear

func Clear(token string, pid int, now time.Time) string

func NewInstanceID

func NewInstanceID() (string, error)

NewInstanceID generates a random 128-bit hex instance identifier.

func PermissionsHash

func PermissionsHash(allow, ask, deny []string) string

PermissionsHash returns a deterministic SHA-256 fingerprint for a session's permission rules, or "" when no rules are present.

func Report

func Report(token string, pid int, now time.Time, argv []string, cwd string) string

Report returns an empty string if the command cannot be safely represented.

func ValidInstanceID

func ValidInstanceID(id string) bool

ValidInstanceID reports whether id is a valid generated instance identifier.

func ValidToken

func ValidToken(s string) bool

func Version

func Version() int

Version returns the currently supported on-disk instance format.

Types

type Instance

type Instance struct {
	Version        int    `json:"version"`
	Agent          string `json:"agent"`
	AgentCanonical string `json:"agent_canonical"`
	ConfigDir      string `json:"config_dir"`
	DataDir        string `json:"data_dir"`
	SessionDB      string `json:"session_db"`
	Tabs           []Tab  `json:"tabs"`
	Active         string `json:"active"`
}

Instance contains only the launch context and persisted tab identities, not conversation contents, credentials, or one-shot inputs.

func (Instance) Validate

func (i Instance) Validate() error

type InstanceStore

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

InstanceStore confines reads and atomic replacements to the private state directory.

func OpenExistingInstanceStore

func OpenExistingInstanceStore(dataDir string) (*InstanceStore, error)

OpenExistingInstanceStore opens an already-existing private instance state directory without creating missing directories.

func OpenInstanceStore

func OpenInstanceStore(dataDir string) (*InstanceStore, error)

OpenInstanceStore opens (creating if necessary) the private instance state directory inside a verified dataDir.

func (*InstanceStore) Close

func (s *InstanceStore) Close() error

func (*InstanceStore) Delete

func (s *InstanceStore) Delete(id string) error

func (*InstanceStore) Exists

func (s *InstanceStore) Exists(id string) bool

Exists reports whether a regular private instance state file currently exists for id.

func (*InstanceStore) Load

func (s *InstanceStore) Load(id string) (Instance, error)

func (*InstanceStore) Prune

func (s *InstanceStore) Prune(now time.Time, maxAge time.Duration, keepID string)

Prune removes abandoned instance files and leftover temporary files older than maxAge, never removing keepID.

func (*InstanceStore) Save

func (s *InstanceStore) Save(id string, state Instance) error

type Tab

type Tab struct {
	SessionID       string `json:"session_id"`
	WorkingDir      string `json:"working_dir"`
	Canonical       string `json:"canonical"`
	Safety          string `json:"safety"`
	PermissionsHash string `json:"permissions_hash,omitempty"`
}

Tab identifies one persisted session tab inside an instance.

Jump to

Keyboard shortcuts

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